我正在使用wsgi运行Django。我有两个域和一个子域指向三个单独的apache2虚拟主机。对于某些(可能非常明显)原因,每个域都登陆到同一个站点(第一个使用a2iteite在线放置)。我的配置如下:
<VirtualHost *:80>
ServerName www.one.com/
ServerAlias one.com
ServerAdmin andy@one.com
DocumentRoot /srv/www/one.com/public_html
<Directory /srv/www/one.com/application>
Order allow,deny
Allow from all
</Directory>
WSGIDaemonProcess one.com processes=2 threads=15 display-name=%{GROUP}
WSGIProcessGroup one.com
WSGIScriptAlias / /srv/www/one/application/apache/one.wsgi
Alias /robots.txt /srv/www/one.com/public_html/robots.txt
Alias /favicon.ico /srv/www/one.com/public_html/favicon.ico
Alias /media /srv/www/one.com/public_html/media
Alias /static /srv/www/one.com/public_html/static
ErrorLog /srv/www/one.com/logs/error.log
CustomLog /srv/www/one.com/logs/access.log combined
</VirtualHost>
////// /// one.wsgi //////////
import os
import sys
sys.path.append('/srv/www/one.com/application')
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
//////////////////
<VirtualHost *:80>
ServerName dev.one.co.uk/
ServerAlias www.dev.one.co.uk/
ServerAdmin andy@one.com
DocumentRoot /srv/www/dev.one.com/public_html
<Directory /srv/www/dev.one.com/application>
Order allow,deny
Allow from all
</Directory>
WSGIScriptAlias / /srv/www/dev.one.com/application/apache/devone.wsgi
Alias /robots.txt /srv/www/dev.one.com/public_html/robots.txt
Alias /favicon.ico /srv/www/dev.one.com/public_html/favicon.ico
Alias /media /srv/www/dev.one.com/public_html/media
Alias /static /srv/www/dev.one.com/public_html/static
ErrorLog /srv/www/dev.one.com/logs/error.log
CustomLog /srv/www/dev.one.com/logs/access.log combined
</VirtualHost>
//////// devone.wsgi ///////////
import os
import sys
sys.path.append('/srv/www/dev.one.com/application')
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
/////////////
<VirtualHost *:80>
ServerName dev.two.com/
ServerAlias www.dev.two.com/
ServerAdmin andy@two.com
DocumentRoot /srv/www/dev.two.com/public_html
<Directory /srv/www/dev.two.com/application>
Order allow,deny
Allow from all
</Directory>
WSGIScriptAlias / /srv/www/dev.two.com/application/apache/devtwo.wsgi
Alias /robots.txt /srv/www/dev.two.com/public_html/robots.txt
Alias /favicon.ico /srv/www/dev.two.com/public_html/favicon.ico
Alias /media /srv/www/dev.two.com/public_html/media
Alias /static /srv/www/dev.two.com/public_html/static
ErrorLog /srv/www/dev.two.com/logs/error.log
CustomLog /srv/www/dev.two.com/logs/access.log combined
</VirtualHost>
//////// devtwo.wsgi /////
import os
import sys
sys.path.append('/srv/www/dev.two.com/application')
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
域名都在我的服务器IP上正常,但它们都落在同一页面上。我错过了什么?提前谢谢!
更新
NameVirtualHost *:80
在ports.conf中声明
答案 0 :(得分:1)
10_dev.two.com.conf
,20_dev.one.com.conf
,30_one.com.conf
)ServerName
和ServerAlias
指令不应包含/