![如何在 apache 中使用与子目录相同的虚拟环境运行多个 django 站点?](https://linux22.com/image/732686/%E5%A6%82%E4%BD%95%E5%9C%A8%20apache%20%E4%B8%AD%E4%BD%BF%E7%94%A8%E4%B8%8E%E5%AD%90%E7%9B%AE%E5%BD%95%E7%9B%B8%E5%90%8C%E7%9A%84%E8%99%9A%E6%8B%9F%E7%8E%AF%E5%A2%83%E8%BF%90%E8%A1%8C%E5%A4%9A%E4%B8%AA%20django%20%E7%AB%99%E7%82%B9%EF%BC%9F.png)
我有一个非托管的 vps。我有 3 个 django 站点 sitename_dev、sitename_staging、sitename_live,它们使用虚拟环境运行。所有 3 个都是默认的 django 实例,没有进行任何更改。我已按如下方式配置了我的 apache。
在/etc/apache2/conf-available/wsgi.conf
#from virtual env
LoadModule wsgi_module "/path/to/virtualenv/lib/python3.6/site-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so"
WSGIPythonHome "/path/to/virtualenv"
# dev site
Include /path/to/sitename_dev.conf
#staging
#Include /path/to/sitename_staging.conf
在path/to/sitename_dev.conf
WSGIScriptAlias /sitename_dev /path/to/sitename_dev/sitename_dev/wsgi.py
WSGIPythonPath /path/to/sitename_dev
<Directory /path/to/sitename_dev/sitename_dev>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
在path/to/sitename_staging.conf
WSGIScriptAlias /sitename_staging /path/to/sitename_staging/sitename_staging/wsgi.py
WSGIPythonPath /path/to/sitename_staging
<Directory /path/to/sitename_staging/sitename_staging>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
使用此配置我的.ip/站点名称_dev/打开。但是,如果我取消注释暂存站点行,将暂存站点包含在 /etc/apache2/conf-available/wsgi.conf 中,则my.ip/站点名称_dev和my.ip/站点名称_staging给出 500 错误。我怎样才能将 3 个站点作为子目录运行?
specs: OS: ubuntu 16.4 LTS server: apache2 2.4.18 python version of virtual env & wsgi: 3.6