【发布时间】:2018-03-05 18:12:23
【问题描述】:
我想使用 apache 和 mod_wsgi 打开 django 服务器。 我写了如下
sudo apt-get install apache2
sudo apt-get install libapache2-mod-wsgi
并创建 django 项目和应用程序,并将我的机器人添加到 setting.py 并创建虚拟环境并使用 并在seoultech/wsgi.py /django = mydirctory/seoultech=project/bot =app / 中添加以下代码/
import os, sys
sys.path.append('/home/django')
sys.path.append('/home/django/venv/lib/python2.7/site-packages')
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "seoultech.settings")
application = get_wsgi_application()
和 cd /etc/apache2/site-available/000-default.conf 添加代码
WSGIDaemonProcess seoultech python-path=/home/django/seoultech=home/django
/venv/lib/python2.7/site-packages
<VirtualHost *:80>
ServerAdmin webmaster@localhost
WSGIScriptAlias / /home/django/seoultech/wsgi.py
<Directory /home/django/seoultech>
<Files wsgi.py>
Require all granted
</Files>
</Directory
</VirtualHost>
但是 sudo apachectl-k start 我得到了错误
'AH00526: Syntax error on line 1 of /etc/apache2/sites-enabled
/000default.conf:Invalid command 'WSGIDaemonProcess', perhaps misspelled
or defined by a module not included in the server configuration Action '-k
start' failed.The Apache error log may have more information.'
期待帮助
【问题讨论】:
-
正确加载/启用 mod_wsgi 后,如错误所示,您缺少
WSGIProcessGroup指令并且未正确配置 Python 虚拟环境。见modwsgi.readthedocs.io/en/develop/user-guides/…
标签: python django apache mod-wsgi