已经每天在 CentOS7 上运行一个 django 程序。
我希望将 centos7 移动为 centos8。
我正在尝试 CentOS8。这是 wsgi 设置。
# dnf -y install python3-mod_wsgi
# vi /etc/httpd/conf.d/python3_wsgi.conf
这是新文件。写入新文件。
WSGIScriptAlias /test_wsgi /var/www/html/test_wsgi.py
def application(environ, start_response):
status = '200 OK'
html = '<html>\n' \
'<body>\n' \
'<div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">\n' \
'WSGI TEST PAGE\n' \
'</div>\n' \
'</body>\n' \
'</html>\n'.encode("utf-8")
response_header = [('Content-type','text/html')]
start_response(status,response_header)
return [html]
# systemctl restart httpd
url 输入到 chrome http://153.127.13.226/test_wsgi。
好的!有用!与wsgi!
但是用venv创建django项目然后就不行了。
url 输入到 chrome http://153.127.13.226/test_wsgi。
铬是......哦,不!503!
Service Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
venv 目录是...
# python -c 'import sys; print(sys.prefix)'
/home/op/venv
django 项目是...
# tree /var/www/html
/var/www/html
├ index.html
├ test_wsgi.py
└ testproject
├ manage.py
└ testproject
├ __init__.py
├ asgi.py
├ settings.py
├ urls.py
└ wsgi.py
WSGIDaemonProcess test_app python-path=/var/www/html/testproject python-home=/home/op/venv
WSGIProcessGroup test_app
WSGIScriptAlias /test_wsgi /var/www/html/testproject/testproject/wsgi.py
<Directory /var/www/html/testproject>
Require all granted
</Directory>
错误日志是……似乎无穷无尽。
# tail -f /var/log/httpd/error_log
Current thread 0x00007f65e9c55900 (most recent call first):
[Mon Mar 23 21:13:57.702501 2020] [core:notice] [pid 26583:tid 140075690449152] AH00052: child pid 7780 exit signal Aborted (6)
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'
我已经在流中搜索堆栈但尚未解决。
我认为它有点多,但我的堆栈溢出了。