views:

285

answers:

0

Migrated to Server Fault

Apache virtual host configuration on debian

Im new to apache configuration and would be really glad if someone helped me with the following.Im running apache on a virtual private server, running the debian operating system.

In /etc/apache2/sites-available, i have two virtual hosts defined,site1.com.conf and site2.com.conf. In /etc/apache2/sites-enabled,i have a symlink to site1.com.conf . The virtual hosts are defined as follows:

site1.com.conf

<VirtualHost *:80>
  ServerAdmin [email protected]
  ServerName  site1.com
  ServerAlias www.site1.com site1.com
  DirectoryIndex index.html index.htm index.php
  DocumentRoot /var/www/site1
        <Directory /var/www/site1>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>
  LogLevel warn
  ErrorLog /var/log/apache2/site1_error.log
  CustomLog /var/log/apache2/site1_access.log combined
  ServerSignature Off
</VirtualHost>

site2.com.conf

<VirtualHost *:80>
  ServerAdmin hostmaster@wharfage
  ServerName  site2.com
  ServerAlias www.site2.com site2.com
  DirectoryIndex index.html index.htm index.php
  DocumentRoot /var/www
  LogLevel debug
  ErrorLog /var/log/apache2/site2_error.log
  CustomLog /var/log/apache2/site2_access.log combined
  ServerSignature Off

  <Location />
    Options -Indexes
  </Location>

  Alias /favicon.ico /srv/site2/static/favicon.ico

  Alias /static /srv/site2/static
#  Alias /media  /usr/local/lib/python2.5/site-packages/django/contrib/admin/media

Alias /admin/media /var/lib/python-support/python2.5/django/contrib/admin/media 

  WSGIScriptAlias / /srv/site2/wsgi/django.wsgi

  WSGIDaemonProcess site2 user=samj group=samj processes=1 threads=10
  WSGIProcessGroup site2
</VirtualHost>

However, a strange thing is happening. Im able to navigate to www.site1.com as expected. It loads the content in /var/www/site which i have defined as the DocumentRoot in site1.com.conf. But if i navigate to www.site2.com,instead of loading index.html which is present in /var/www, which is defined as the DocumentRoot for site2.com.conf, as shown above, it loads the content in /var/www/site1. The url in the address bar remains www.site2.com. So, i have the following two questions :

Q.1) Why is www.site2.com showing the contents of /var/www/site1 when the DocumentRoot for it has been defined as /var/www ?

Q.2) Since, site2.com.conf does not have a symlink in sites-enabled, how come im able to navigate to www.site2.com ?

Sorry, if my questions sound noobish, but ill be really happy if someone could explain this.

Thank You.