I'm trying to setup a couple of Virtual Host files on my Localhost PC running Fedora Core 15.
Now I get this working, but now onloy one Virtual Host site works, and if I type in 127.0.0.1/test/testApp.php which is not related to the Virtual Host site , I get redirected to the Virtual Host site.
Here's what I did.
- I created a new folder called virtualhosts in /etc/httpd/ where all my host files are stored in the following format site.conf
- In /etc/conf/httpd.conf I enabled
NameVirtualHost *:80
and included the host files at the bottom of the config page like thisInclude virtualhosts/*.conf
- In /etc/hosts I added the line 127.0.0.1 website
No when I run sudo httpd -t
I get Syntax OK
I restart apache and then the Virtualhost works, but as soon as I add other hosts and only use 127.0.0.1 as above it still links to the original host.
Am I doing anything wrong here or left out something?
An example of my Virtual Host file looks like this
<VirtualHost *:80>
ServerAdmin test@test.com
DocumentRoot /var/www/html/website/
ServerName website
ServerAlias website
ErrorLog logs/dev-error_log
CustomLog logs/dev-access_log common
Alias /blog /var/www/html/blog/
<Directory /var/www/html/website/>
Options FollowSymLinks
Allow Override
All Order allow,deny allow from all
</Directory>
#php_value error_reporting E_ALL & ~E_NOTICE & ~E_DEPRECATED
php_flag display_errors On
php_value date.timezone Europe/London
</VirtualHost>
Best Answer
If you are setting up a name based virtual host then I think you should access it by ServerName instead of the 127.0.0.1 depending on what is on your virtualhosts config file. This is true if you have multiple virtual hosts (websites) bound to a single IP.
Update - You can try setting up your virtual hosts on different ports (for testing purposes only)
<VirtualHost *:80>
open in browser via website:80<VirtualHost *:81>
open in browser via website:81