【发布时间】:2018-10-14 09:57:44
【问题描述】:
在让我的 Django 应用程序在生产中运行的过程中,我意识到 apt-get mod_wsgi 没有安装正确版本的 mod_wsgi。建议是在我的虚拟环境中安装 mod_wsgi。
我正在运行 AWS Small Ubuntu 16.04.4 LTS 服务器和 Python 3.5。
我的虚拟环境是 /usr/local/pulseenv 并且包含 mod-wsgi 4.6.4。
我的虚拟主机文件(/etc/apache2/sites-available/000-default.conf)有:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
#DocumentRoot /var/www/html
DocumentRoot /var/www/pulsemanager/pulsemanager
Alias /static /var/www/pulsemanager/pulsemanager/static
<Directory /var/www/pulsemanager/pulsemanager/static>
Require all granted
</Directory>
<Directory /var/www/pulsemanager/config>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIScriptAlias / /var/www/pulsemanager/config/wsgi.py
#WSGIDaemonProcess pulsemanager
WSGIPythonHome /usr/local/pulseenv
WSGIPythonPath /var/www/pulsemanager
#WSGIProcessGroup pulsemanager
WSGIApplicationGroup %{GLOBAL}
</VirtualHost>
但是当我尝试启动 apache 时,我得到了这个错误:
ubuntu@ip-172-31-84-213:~$ systemctl status apache2.service
● apache2.service - LSB: Apache2 web server
Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: failed (Result: exit-code) since Fri 2018-05-04 01:35:16 UTC; 13s ago
Docs: man:systemd-sysv-generator(8)
Process: 6697 ExecStart=/etc/init.d/apache2 start (code=exited, status=1/FAILURE)
May 04 01:35:16 ip-172-31-84-213 apache2[6697]: * The apache2 configtest failed.
May 04 01:35:16 ip-172-31-84-213 apache2[6697]: Output of config test was:
May 04 01:35:16 ip-172-31-84-213 apache2[6697]: AH00526: Syntax error on line 42 of /etc/apache2/sites-enabled/000-default.conf:
May 04 01:35:16 ip-172-31-84-213 apache2[6697]: Invalid command 'WSGIScriptAlias', perhaps misspelled or defined by a module not included
May 04 01:35:16 ip-172-31-84-213 apache2[6697]: Action 'configtest' failed.
May 04 01:35:16 ip-172-31-84-213 apache2[6697]: The Apache error log may have more information.
May 04 01:35:16 ip-172-31-84-213 systemd[1]: apache2.service: Control process exited, code=exited status=1
May 04 01:35:16 ip-172-31-84-213 systemd[1]: Failed to start LSB: Apache2 web server.
May 04 01:35:16 ip-172-31-84-213 systemd[1]: apache2.service: Unit entered failed state.
May 04 01:35:16 ip-172-31-84-213 systemd[1]: apache2.service: Failed with result 'exit-code'.
lines 1-18/18 (END)
所以看起来 mod_wsgi 不能被 Apache 找到。 (那是 WSGI* 命令所在的地方吗?)那么如何使用 pip install mod_wsgi 配置 Apache?
【问题讨论】:
-
您是否运行
mod_wsgi-express module-config并将结果添加到您的Apache 配置中? pypi.org/project/mod_wsgi的“连接到 Apache 安装”部分中的详细信息 -
顺便说一句,你真的应该使用守护模式,因为它是推荐的部署方法。有关如何配置虚拟环境的详细信息,请参阅modwsgi.readthedocs.io/en/develop/user-guides/…
-
这正是我所需要的。那个问题解决了!如果您将此放在答案中,我会接受。
标签: python django python-3.x apache mod-wsgi