我有一个为python3.6构建的烧瓶式网站。我正在尝试使用apache部署我的网站,但一直存在问题。
我使用以下命令安装了wsgi:
sudo apt-get install libapache2-mod-wsgi-py3
我使用以下方式安装了python3.6:
sudo apt-get install python3.6
.
因为它是一个专用于这个站点的服务器,所以我使用pip3.6而不是在virtualenv中全局安装了python模块,所以我所有需要/安装的模块都位于
/usr/local/lib/python3.6/dist-packages/
.
我还没有弄清楚如何让apache使用python3.6及其模块。默认情况下,apache使用的python版本是3.5,系统默认的python3版本(我通过打印验证了这一点
sys.version_info
在我的。wsgi文件)。因此,路径中没有我的模块。
环顾四周后,我找到了apache配置选项
WSGIPythonHome
和
WSGIPythonPath
. 我已尝试将这些添加到
apache.conf
在不同的组合中,但没有任何效果。下面是我尝试的内容和错误。
# /etc/apache2/apache.conf
WSGIPythonHome /usr/local/lib/python3.6
# /var/log/apache2/error.log
Current thread 0x00007fc69bac4e00 (most recent call first):
[Sun Jan 14 23:02:04.732187 2018] [core:notice] [pid 7139:tid 140490992012800] AH00051: child pid 7154 exit signal Aborted (6), possible coredump in /etc/apache2
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
# /etc/apache2/apache.conf
WSGIPythonHome /usr/local/lib/python3.6
WSGIPythonPath /usr/local/lib/python3.6
# /var/log/apache2/error.log
Current thread 0x00007fc69bac4e00 (most recent call first):
[Sun Jan 14 23:02:04.732187 2018] [core:notice] [pid 7139:tid 140490992012800] AH00051: child pid 7154 exit signal Aborted (6), possible coredump in /etc/apache2
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
# /etc/apache2/apache.conf
WSGIPythonHome /usr/local/
WSGIPythonPath /usr/local/lib/python3.6
# /var/log/apache2/error.log
Current thread 0x00007fc69bac4e00 (most recent call first):
[Sun Jan 14 23:02:04.732187 2018] [core:notice] [pid 7139:tid 140490992012800] AH00051: child pid 7154 exit signal Aborted (6), possible coredump in /etc/apache2
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
WSGIPythonHome/usr/local/lib/python3.6
WSGIPythonPath/usr/local/lib/python3.6
当前线程0x00007fc69bac4e00(最新调用优先):
【Sun Jan 14 23:02:04.732187 2018】【核心:通知】【pid 7139:tid 140490992012800】AH00051:子pid 7154退出信号中止(6),可能在/etc/apache2中转储核心
致命的Python错误:Py\u Initialize:无法获取区域设置编码
ImportError:没有名为“encodings”的模块
# /etc/apache2/apache.conf
WSGIPythonHome /usr/local/lib/python3.6
WSGIPythonPath /usr/local/lib/python3.6/dist-packages
# /var/log/apache2/error.log
Current thread 0x00007fc69bac4e00 (most recent call first):
[Sun Jan 14 23:02:04.732187 2018] [core:notice] [pid 7139:tid 140490992012800] AH00051: child pid 7154 exit signal Aborted (6), possible coredump in /etc/apache2
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
WSGIPythonPath /usr/local/lib/python3.6
Using python version 3.5
Module flask not found
WSGIPythonPath /usr/local/lib/python3.6/dist-packages
Using python version 3.5
Module flask not found
无论如何,我认为我走的是对的,但我不知道我做错了什么。似乎我没有使用正确的
PythonHome
但我不确定如果不是上面提到的一个,它应该是什么。
任何帮助都将不胜感激。