【发布时间】:2023-03-06 12:33:02
【问题描述】:
我试图让两个 apache 虚拟主机与 mod_wsgi 和 python 一起工作,我想访问不同文件夹中的两个站点:即 example.com/sh 和 example.com/th 这是我尝试过的:
WSGISocketPrefix /var/run/moin-wsg
<VirtualHost *:80>
ServerAdmin sth@domain.com
serverName sub.example.com
serverAlias www.sub.example.com
WSGIScriptAlias /sh /opt/source/sh/moin.wsgi
WSGIDaemonProcess sh user=th group=apache threads=5 python-path=/opt/source/sh/env/lib/python2.7/site-packages
WSGIProcessGroup sh
ErrorLog logs/sh.foo.info-error_log
CustomLog logs/sh.foo.info-access_log common
<Location /sh>
WSGIProcessGroup sh
</Location>
<Directory /opt/source/sh>
Options Indexes FollowSymLinks
Order allow,deny
allow from all
</Directory>
</VirtualHost>
WSGISocketPrefix /var/run/th
<VirtualHost *:80>
ServerAdmin example@domain.com
serverName sub.example.com
serverAlias www.sub.example.com
WSGIScriptAlias /site1 /opt/source/th/moin.wsgi
WSGIDaemonProcess th user=th group=apache threads=5 python-path=/opt/source/th/env/lib/python2.7/site-packages
ErrorLog logs/th.foo.info-error_log
CustomLog logs/th.foo.info-access_log common
<Location /th>
WSGIProcessGroup th
</Location>
<Directory /opt/source/th/>
Options Indexes FollowSymLinks
Order allow,deny
allow from all
</Directory>
</VirtualHost>
此时只有第一个站点有效,第二个站点给出 404 未找到,我该如何解决? 这两个站点都是基于 python 的 wiki 的
【问题讨论】:
-
两个站点的 ServerName/ServerAlias 值必须不同。如果您希望每个应用程序在同一主机下运行,请不要使用两个 VirtualHost 定义,使用一个并将两者的配置都放在其中。
标签: apache python-2.7 mod-wsgi