2012-08-27 111 views
0

我有在Apache中配置虛擬主機2.2.3 CentOS的, 一些麻煩我具有以下配置:阿帕奇:配置虛擬主機

的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 

我需要匹配所有來到這個服務器的請求與第二個VirtualHost條目,除了這個域名「mydomain.site.ch」來的。 但結果是:使用這種配置,我得到了第一個VirtualHost條目處理的所有請求..(配置語法是OK!)有關如何糾正此問題的任何想法?

回答

0

改變它在這樣:

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> 

如果這不會幫助,然後下一個嘗試:

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> 

更新 - /etc/hosts

如果你想爲從請求外部使用localhost VirtualHost,您可能必須在/etc/hosts

127.0.0.1 localhost 
x.y.z.89  localhost 
x.y.z.89  mydomain.site.ch 

然後嘗試在瀏覽器中打開:

http://mydomain.site.chhttp://x.y.z.89/

+0

謝謝,我會嘗試它現在:) – Kreshnik

+0

只需編輯它 - 添加服務器名到你的第二個虛擬主機。 –

+0

使用這個httpd.conf瘋了,不想工作(我試過很多不同的配置......)!!! – Kreshnik