【问题标题】:django apache wsgi issuedjango apache wsgi问题
【发布时间】: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.'

期待帮助

【问题讨论】:

标签: python django apache mod-wsgi


【解决方案1】:

将 WSGIDaemonProcess 放在 VirtualHost 中以消除此错误。

<VirtualHost *:80>

    ServerAdmin webmaster@localhost

    WSGIDaemonProcess seoultech python-path=/home/django/seoultech=home/django
/venv/lib/python2.7/site-packages
    WSGIScriptAlias / /home/django/seoultech/wsgi.py


<Directory /home/django/seoultech>
    <Files wsgi.py>
        Require all granted
    </Files>
</Directory
</VirtualHost>

【讨论】:

  • sudo a2enmod wsgi?
  • 错误:模块 wsgi 不存在!
  • 拜托,谷歌如何为 Apache 启用 wsgi 模块。
  • sudo nano /etc/apache2/mods-available/wsgi.load ,我可以 sudo a2enmod wsgi ,但我遇到了同样的错误......我不知道原因
猜你喜欢
  • 1970-01-01
  • 2011-03-04
  • 1970-01-01
  • 2011-11-24
  • 1970-01-01
  • 2020-05-29
  • 2011-06-27
  • 1970-01-01
  • 2013-02-01
相关资源
最近更新 更多