我目前正尝试在Centos服务器上使用mod_wsgi在Apache上设置Django应用程序。这设置为在https上运行。它是关于virtualenv。
但是,目前它提供了504网关超时错误。
错误日志:
(2)No such file or directory: mod_wsgi (pid=15007): Unable to stat Python home /bin/virtualenv:/var/www/django/mysite/mysite/lib/python3.6/site-packages. Python interpreter may not be able to be initialized correctly. Verify the supplied path and access permissions for whole of the path.
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'
的httpd.conf
<VirtualHost *:443>
ServerName mysite.example.com
ServerAlias www.mysite.example.com
# DocumentRoot /var/www/django/mysite
LogLevel info
ErrorLog /etc/httpd/logs/mysite_error.log
Alias /static /var/www/django/mysite/static
<Directory /var/www/django/mysite/static>
Require all granted
</Directory>
<Directory /var/www/django/mysite/mysite>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess mysite python-home=/bin/virtualenv:/var/www/django/mysite/mysite/lib/python3.6/site-packages
WSGIProcessGroup mysite
WSGIScriptAlias / /var/www/django/mysite/mysite/wsgi.py
WSGIApplicationGroup %{GLOBAL}
SSLEngine on
SSLProtocol all -SSLv2
SSLCompression off
SSLCertificateFile /etc/pki/tls/certs/mysite.cert.pem
SSLCertificateKeyFile /etc/pki/tls/private/mysite.key.pem
SSLCertificateChainFile /etc/pki/tls/certs/mysite.chain.pem
</VirtualHost>
答案 0 :(得分:0)
这是不正确的:
WSGIDaemonProcess mysite python-home=/bin/virtualenv:/var/www/django/mysite/mysite/lib/python3.6/site-packages
修改:
python-home
值应该是单个目录,与使用虚拟环境时Python的sys.prefix
相同。不要添加site-packages
目录。
最重要的是,mod_wsgi的编译必须与用于创建虚拟环境的Python版本相同。您不能将使用Python 3.6编译的mod_wsgi与使用Python 3.6创建的虚拟环境一起使用。
检查编译的Python mod_wsgi的使用版本是什么版本: