Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

  1. I created a new folder called virtualhosts in /etc/httpd/ where all my host files are stored in the following format site.conf
  2. In /etc/conf/httpd.conf I enabled NameVirtualHost *:80 and included the host files at the bottom of the config page like this Include virtualhosts/*.conf
  3. 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>
share|improve this question
    
What does Virtual Host config look like? –  quanta Sep 11 '11 at 9:12
    
@quanta - it looks like <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 AllowOverride 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> –  Roland Sep 11 '11 at 9:34
    
Do you have 2 virtual hosts? What about the remaining? Please show us the directory structure in /var/www/html? –  quanta Sep 11 '11 at 13:14
    
Add the moment there are to many to list, not all of them should be Virtual Hosts. So in other words, I need to add as many virtual hosts files to the Virtualhosts folder and it should pick it up. –  Roland Sep 11 '11 at 20:53
    
check your virtualhost priorities with httpd -S –  c4f4t0r Dec 3 '13 at 13:52

1 Answer 1

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

share|improve this answer
    
I need to access it both ways with 127.0.0.1 and via name, since some of my devsites do not have virtuehosts –  Roland Sep 11 '11 at 9:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.