【问题标题】:how do i place two apache virtualhosts with mod_wsgi and python in the httpd.conf?如何在 httpd.conf 中放置两个带有 mod_wsgi 和 python 的 apache 虚拟主机?
【发布时间】: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


【解决方案1】:

就像邓普顿说的, 这就是我最终这样做的方式:

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>

   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>

【讨论】:

    猜你喜欢
    • 2012-04-22
    • 2015-12-20
    • 2014-01-06
    • 2012-05-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-30
    • 2015-01-31
    相关资源
    最近更新 更多