我有两个指向相同IP的域,这是一个带有apache2的Ubuntu VPS。我需要从apache服务这两个域。我在http://httpd.apache.org/docs/2.0/vhosts/examples.html#purename阅读了配置手册,并添加了以下两个文件:
1)webikenconsultants
<VirtualHost *:80>
ServerName www.webikenconsultants.com
DocumentRoot /var/www/coming_soon
<Directory /var/www/coming_soon>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
2)webikentrading
<VirtualHost *:80>
ServerName www.webikentrading.net
#WSGIScriptAlias / /opt/webikentrading/current/src/webikentrading/django.wsgi
DocumentRoot /var/www
<Directory /var/www >
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
正如你所看到的,webikentrading是一个Django项目,但暂时只是为了让事情有效,我将它作为一个静态网站服务,直到我弄清楚发生了什么。问题是当我访问任一域时,只有come_soon内容出现,我做错了什么?
答案 0 :(得分:1)
我弄明白了这个问题。 vhost入口指向www.webikentrading.net但是,浏览器使用webikentrading.net所以我为webikentrading.net添加了一个单独的条目,一切都很好
编辑:
这是相当古老的,但我现在有了一种新的改进方法,我希望它可以帮助别人。
使用mod_wsgi守护程序指令,该指令允许您添加所选的python路径。示例配置为:
<VirtualHost *:80>
ServerName qa.webiken.net
....
WSGIDaemonProcess qa.webiken.net processes=2 threads=15 python-path=/usr/local/pythonenv/QA-WEBIKEN-1/lib/python2.5/site-packages display-name=%{GROUP}
WSGIProcessGroup qa.webiken.net
</VirtualHost>
<VirtualHost *:80>
ServerName staging.webiken.net
....
WSGIDaemonProcess staging.webiken.net processes=2 threads=15 python-path=/usr/local/pythonenv/staging-WEBIKEN-1/lib/python2.5/site-packages display-name=%{GROUP}
WSGIProcessGroup staging.webiken.net
</VirtualHost>