Problem getting virtual hosts to work

Discussion in 'Apache' started by shabda, Aug 27, 2007.

  1. #1
    I want to get two sites working with one apache instance. SO I am trying to get virtual hosts to work by making changes to my httpd.conf file.
    I added the following code to end of httpd.conf
    
    <VirtualHost example.com>
    DocumentRoot "/var/www/html"
    <Directory "/var/www/html">
    allow from all
    Options +Indexes
    </Directory>
    </VirtualHost>
    
    <VirtualHost example2.com>
    DocumentRoot "/var/www/html/name"
    <Directory "/var/www/html/name">
    allow from all
    Options +Indexes
    </Directory>
    </VirtualHost>
    
    Code (markup):
    But both sites are still picking up the content to show from the /var/www/html directory, and the second ,virtualhost? directive is not working. Pointers?
     
    shabda, Aug 27, 2007 IP
  2. powerspike

    powerspike Peon

    Messages:
    312
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #2
    try this
    (change 1.2.3.4:80 with the ipaddress the websites sit on)
    
    NameVirtualHost 1.2.3.4:80
    
    <VirtualHost 1.2.3.4:80>
    ServerName www.example1.com
    ServerAlias example1.com sub.example1.com
    DocumentRoot /var/www/html/name
    CustomLog /var/log/httpd/example1.com.access log Combined
    </VirtualHost>
    
    Code (markup):
    Ok that should work fine
    a couple of things, you want that Customlog line in there, so you can run stuff like awstats - and get referer and browser information into the stats.
    you can add in your other virtualhost settings like the <directory> stuff as you need.
     
    powerspike, Aug 27, 2007 IP