Reputation: 2831
I was having some trouble in configuring virtual hosts in Apache 2.2.3 CentOS, I have the following configuration:
httpd.conf
NameVirtualHost mydomain.site.ch
<VirtualHost mydomain.site.ch>
ServerName mydomain.site.ch
DocumentRoot /home/django_www/hello
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/html
</VirtualHost>
/etc/hosts
127.0.0.1 localhost.localdomain localhost
x.y.z.89 mydomain.site.ch
I need to match all the requests that comes to this server with the second VirtualHost entry except the one coming with this domain name "mydomain.site.ch" . But the result: with this configuration i get all the requests handled by the first VirtualHost entry.. (the configuration syntax is OK!) Any ideas in how to correct this problem?
Upvotes: 0
Views: 25097
Reputation: 7295
Change it in this way:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName mydomain.site.ch
DocumentRoot /home/django_www/hello
WSGIScriptAlias / /home/django_www/hello/django.wsgi
<Directory /home/django_www/hello>
Options FollowSymLinks MultiViews
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName localhost
DocumentRoot /var/www/html
<Directory /home/www/html>
Options FollowSymLinks MultiViews
AllowOverride all
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
If this will not help then try next:
NameVirtualHost *:80
<VirtualHost x.y.z.89:80>
ServerName mydomain.site.ch
DocumentRoot /home/django_www/hello
WSGIScriptAlias / /home/django_www/hello/django.wsgi
<Directory /home/django_www/hello>
Options FollowSymLinks MultiViews
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
<VirtualHost 127.0.0.1:80>
ServerName localhost
DocumentRoot /var/www/html
<Directory /home/www/html>
Options FollowSymLinks MultiViews
AllowOverride all
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
UPDATE - /etc/hosts
If you want to serve the requests from outside with your localhost VirtualHost, you'll might have to set it explicitly in /etc/hosts
:
127.0.0.1 localhost
x.y.z.89 localhost
x.y.z.89 mydomain.site.ch
Then try to open in browser:
http://mydomain.site.ch
and http://x.y.z.89/
Upvotes: 1