我想使用apache和mod_wsgi打开Django服务器。 我写下如下django apache wsgi问题
sudo apt-get install apache2
sudo apt-get install libapache2-mod-wsgi
,并创建Django项目和应用程序,并添加我的机器人在setting.py 和创建虚拟环境,并使用 和seoultech/wsgi.py/Django的= mydirctory添加下面的代码/ seoultech =项目/ BOT =应用程序/
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 [email protected]
WSGIScriptAlias//home/django/seoultech/wsgi.py
<Directory /home/django/seoultech>
<Files wsgi.py>
Require all granted
</Files>
</Directory
</VirtualHost>
但须藤的apachectl-K开始我得到错误
'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.'
IM期待帮助
正确加载/启用mod_wsgi后,由于错误提示存在问题,因此缺少WSGIProcessGroup指令,并且没有正确配置Python虚拟环境。见http://modwsgi.readthedocs.io/en/develop/user-guides/virtual-environments.html –