I am raging here more than 3 hours how to make Apache2 work for me how I want.
I want when I access IP address directly, Apache2 serve me content from /var/www/html and not from virtualhost.
I tested everything including 000-default.conf file:
<VirtualHost *>
ServerName 'baterka.xyz'
ServerAlias 'MY_IP'
DocumentRoot /var/www/html
</VirtualHost>
Nothing works. Apache2 (or Virtualmin) everytime use first VirtualHost in list but not my default file. How to make it works!
Related
I want to customize my client's site with virtual host block. Manually I did this request on the Ubuntu server 18.04. But now I have the cPanel and the WHM access.
I read these official links.
Modify Apache Virtual Hosts with Include Files
Modify Virtualhost Containers With Include Files
But I messed regrading the include files and those directories as,
/usr/local/apache/conf/userdata/ssl/2_2/$user/$domain/$includename.conf
and
/etc/apache2/conf.d/userdata/ssl/2_4/user/domain/includename.conf
And the following scripts
To rebuild the httpd.conf file, run the following script:
/usr/local/cpanel/scripts/rebuildhttpdconf
To restart Apache, run the following script:
/usr/local/cpanel/scripts/restartsrv_httpd
Please clearly tell how can I merge this to be put using cPanel and WHM.
vhost
<VirtualHost *:9876>
ServerName 139.59.xxx.xxx
DocumentRoot /home/username/newfile/doneapi/public
<Directory /home/username/newfile/doneapi/public>
AllowOverride All
</Directory>
</VirtualHost>
hosts file
127.0.0.1 139.59.xxx.xxx
ports.conf
Listen 9876
Thanks in advance
I am trying to tunnel the localhost in travis ci with ngrok. So far I have been able to expose the site, but unfortunately any curl request to a simple text file gives me 404 error. Only index pages are visible/downloadable. How can I configure it, so that files can be downloaded.
This is my virtual host config:
<VirtualHost *:80>
DocumentRoot $1
<Directory $1>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
DirectoryIndex index.php index.html
</VirtualHost>
$1 is the random subdomain name given by ngrok (I am storing the virtual host config as a string) .
This is the /etc/hosts file at some point:
127.0.0.1 a3a1a93a.ngrok.io
127.0.0.1 8dbc2f3e.ngrok.io
## cookbook:: travis_build_environment
## file:: templates/default/etc/cloud/templates/hosts.tmpl.erb
127.0.1.1 testing-gce-478a98cf-1fda-48f0-9b75-4c72e55e1305 testing-gce-478a98cf-1fda-48f0-9b75-4c72e55e1305 ip4-loopback trusty64
The first two entries are the tunneled subdomains by ngrok.
Here is the task
When user enters in browser domain.com/something/something,
get files not from domain.com/something/something as was expected, but from
domain.com/something/something/www
In my /etc/apache2/sites-available folder I've found domain.com.conf
And it contains only this
<virtualhost *:80>
ServerName domain.com
DocumentRoot /var/www/main
</virtualhost>
So how should I edit my domain.com.conf file ?
You are on the right path.
If you have only one domain
in /etc/apache2/sites-available/default modify the line :
DocumentRoot /var/www/domain/www/
And then restart apache :
$ sudo service apache2 restart
This will change the path for the default host.
If you have several domains
You need VirtualHosts. If you have already VirtualHosts, you probably have multiple files in /etc/apache2/sites-available/, find the one managing your domain. Otherwise create one from default by sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/domain.com. It should contains something like this at the begining :
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName domain.com
DocumentRoot /var/www/domain/www/
<Directory /var/www/domain/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
....many stuff
</VirtualHost>
Then enable the site and restart apache :
$ sudo a2ensite domain.com
$ sudo service apache2 restart
If you just want that a particular path /something/something/ be served from /domain.com/something/something/www/, set up an alias :
Alias /something/something /something/something/www
I want to develop facebook app locally and was trying to follow instructions on
https://devcenter.heroku.com/articles/facebook#working-locally
I installed lamp on Linux Mint 13 and created /etc/apache2/conf/extra/httpd-vhosts.conf as below.
NameVirtualHost *:80
VirtualHost *:80>
DocumentRoot "/home/ashish"
ServerName localhost
/VirtualHost>
VirtualHost *:80>
DocumentRoot /home/ashish/savefromiad/blooming-stream-1211/
ServerName mycoolapp-dev.localhost
SetEnv FACEBOOK_APP_ID 461561000551920
SetEnv FACEBOOK_SECRET 00000000000000000000000
/VirtualHost>
In my browser localhost works good, but trying to access mycoolapp-dev.localhost in browser fails.
"Oops! Google Chrome could not find mycoolapp-dev.localhost"
Any ideas?
I also get this error when I restarts apache
NameVirtualHost *:80 has no VirtualHosts
PS: Before all "VirtualHost" there is a "less then" sign.
You also have to edit /etc/hosts file.
Add there something like
127.0.0.1 mycoolapp-dev.localhost
Also, double check your /etc/apache2/conf/extra/httpd-vhosts.conf i think you dont need two DocumentRoot and ServerName for one virtual host(as you pasted in your question)
I got this.
I needed a separate entry in /etc/hosts as below.
127.0.0.1 localhost
127.0.0.1 mycoolapp-dev.localhost
Thanks icrew for pointing to /etc/hosts.
Also I commented out "NameVirtualHost *:80" in "/etc/apache2/ports.conf" as it was already there in "/etc/apache2/conf/extra/httpd-vhosts.conf".
So i've been at this for 2 days now and i cannot get it to work together.
I have installed Wamp 2.2 in a standard manner at c:\wamp, nothing special.
I downloaded and extracted the Zend Frameworkm folder and placed the folder it in the C:\wamp\library folder.
So it looks like this :
C:\wamp
- www
- ht.acces
- index.php
- bin
- library
- ZendFramework
- bin
- library
- etc.
- logs
- tools
- etc.
Now as instructed i added both the php location and the Zend framework library to the system variable called PATH wich looks like this : ..;C:\wamp\library\ZendFramework\bin\;C:\wamp\bin\php\php5.3.10\;
Now i can open cmd and type zf create project quickstart, i directed it to create the folder in the www. directory of wamp like this :
C:\wamp
- www
- quickstart
- application
- data
- library
- etc
- ht.acces
- index.php
- bin
- library
- ZendFramework
- bin
- library
- etc.
- logs
- tools
- etc.
Now starts the fun part. All the guides around the internet tell me that i should include the location of the library folder inside the ZendFramework folder in the php.ini at the windows version of include_path: "C:\wamp\library\ZendFramework\library".
Now the fun part is that no one mentions exactly wich php.ini file! There are 2 of them as most of you know one in the php directory and one in the apache directory.
And so i come with my first part of my question, wich one do i need?
Wich is soon after followed by part 2, how to propperly set up the virtual host that is supposedly needed to correctly run the zend application in the folder C:\wamp\www\quickstart.
From what i could gather i need to change the file httpd.conf file in the folder C:\wamp\bin\Apache2.2.21\conf\
I need to add something along the lines of
<VirtualHost 127.0.0.1>
ServerName quickstart
DocumentRoot "c:\wamp\www\quickstart\public"
<Directory "c:\wamp\www\quickstart\public">
AllowOveride all
Order Allow,Deny
Allow from all
<\directory>
<\VirtualHost>
Then after doing so i need to change the host file in the directory c:\windows\system32\drivers\etc. However at that point i am completely lost.
My host file looks like this :
--- standard commented wall of text ---
127.0.0.1 localhost
And at this point the only thing i know that seems to get close to it is that i need to add the line :
127.0.0.1 localhost quickstart
Or something along those lines.
So is there anyone out there with experience regarding Zend Framework that could provide me with an answer? It would be much appriciated :)
Björn
-
First I'm pretty sure that the php.ini you need to change for web display is the one in the apache folder. (it's been awhile since I've used WAMP).
Next don't build your vhost in your apache config httpd.conf, do it instead in httpd-vhosts.conf. (you don't want to accidently break apache),
The way you stting your vhost at the moment you url will look like http:quickstart/
these two links will help:
Setup Apache vhost
Zend Server Vhosts
One of the key thing with using vhosts is to remember to redo localhost so it doesn't go away.
With you windows hosts file, remeber it must be edited in admin mode and you can have many hosts on the same number, here is an example:
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
# ::1 localhost
127.0.0.1 iam.local
127.0.0.1 zfcms.local
127.0.0.1 home.local
127.0.0.1 places.local
127.0.0.1 RentAFlat.local
127.0.0.1 zf2-tutorial.local
127.0.0.1 mp3.local
127.0.0.1 quickstart
and an example from httpd-vhosts.conf, note: localhost is the first vhost...This is important.
<VirtualHost *:80>
DocumentRoot "C:\Zend\Apache2/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:\www\iam\public"
ServerName iam.local
ErrorLog "C:\Zend\ZendServer\logs\iam.local.log"
<directory "C:\www\iam">
Options Indexes FollowSymlinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</directory>
</VirtualHost>
I hope this helps..
Looks like You're missing (first of all)
<VirtualHost 127.0.0.1>
ServerName quickstart
(...)
<\VirtualHost>