python - 使用 Apache 部署 Django 2.1 并且 mod_wsgi 提供超时
问题描述
我真的很难让我的 Django-App 2.1 (Python3) 与 Apache2 和 mod_wsgi 一起工作。也许这里的一些好人可以帮助我?
我不得不将我的 80 和 443 的 VHost 放入一个文件中,因为 certbot 只对 VHost 进行复制和粘贴,并且由于需要唯一的 WSGI 进程命名等而导致错误。
所以这是我的 VHost(apache2 configtest 都很好):
WSGIDaemonProcess my.domain.co processes=2 threads=15 display-name=%{GROUP} python-home=/var/www/site/project/venv/lib/python3.6
WSGIProcessGroup my.domain.co
WSGIScriptAlias / /var/www/site/project/wsgi.py
<VirtualHost *:80>
ServerName my.domain.co
DocumentRoot /var/www/site
<directory /var/www/site>
AllowOverride all
Require all granted
Options FollowSymlinks
</directory>
Alias /static/ /var/www/site/static/
<Directory /var/www/site/static>
Require all granted
</Directory>
RewriteEngine on
RewriteCond %{SERVER_NAME} =my.domain.co
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<VirtualHost *:443>
ServerName my.domain.co
DocumentRoot /var/www/site
<directory /var/www/site>
AllowOverride all
Require all granted
Options FollowSymlinks
</directory>
Alias /static/ /var/www/site/project/
<Directory /var/www/site/static>
Require all granted
</Directory>
SSLCertificateFile ...
SSLCertificateKeyFile ...
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
我的项目结构显然在哪里: /var/www/site 作为 venv 所在的主目录,并创建了 django-project。项目目录包含 wsgi.py 和 settings.py。
因此,当我尝试打开我的网站时,我遇到了超时错误。当我在做: python3 manage.py runserver 127.0.0.1:8080 并在其上放置一个反向代理时,它可以工作-但这当然不是它应该如何工作的。
有谁知道我错过了什么?:/
感谢您的帮助,非常感谢!
编辑:
日志:
Current thread 0x00007f8064915bc0 (most recent call first):
[Sun Oct 14 06:28:55.988638 2018] [core:notice] [pid 47497] AH00051: child pid 36608 exit signal Aborted (6), possible coredump in /etc/apache2
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'
错误:
524
解决方案
推荐阅读
- python - python没有响应
- xamarin.forms - 在最大长度为 1 之后关注下一个条目
- entity-framework-core - 在与多个实体的一对一关系中具有可为空的外键
- javascript - 按下空格键时在图像之间切换(js)
- python-3.x - Django pypdftk - subprocess.CalledProcessError
- r - 使用 rjags 的贝叶斯逻辑回归
- iis - IIS UrlRewrite:如何从域重写为域和路径
- python - 无法让我的函数在 Python 中满足 while 循环条件
- redis - 如何为redis流定义TTL?
- reactjs - 与 MUI TextField 等控制组件一起使用时,React Hook Form 是否会减少重新渲染