【发布时间】:2016-03-21 16:55:54
【问题描述】:
我做了什么:
- 我下载了 python 3.5 源,提取并编译它们
`
./configure --enable-shared --prefix=/usr/local/lib
make&&make install
Then python couldn't find a libpython3.5m.so.1.0 so i've ran
export LD_LIBRARY_PATH=/usr/local/lib
-
我已经使用
pip3.5 install mod_wsgi安装了 mod_wsgi。我还尝试使用
从源代码(从这里http://modwsgi.googlecode.com/files/mod_wsgi-3.4.tar.gz)安装它./configure --with-python=/usr/local/bin/python3.5 make make install但它就这样结束了
`
/usr/lib64/apr-1/build/libtool --silent --mode=link gcc -o mod_wsgi.la -rpath /usr/lib64/httpd/modules -module -avoid-version mod_wsgi.lo -L/usr/local/lib -L/usr/local/lib/python3.5/config -lpython3.5 -lpthread -ldl -lutil -lrt -lm
/usr/bin/ld: cannot find -lpython3.5
collect2: ld returned 1 exit status
apxs:Error: Command failed with rc=65536
...
所以我继续使用 modwsgi form pip 但 lld 说它仍然是第 2 个 python,所以在其中
`
(env) [root@spiralarms mod_wsgi-3.4]# ldd /usr/lib64/httpd/modules/mod_wsgi.so
linux-vdso.so.1 => (0x00007fffc3fae000)
libpython2.6.so.1.0 => /usr/lib64/libpython2.6.so.1.0 (0x00007fa1ea4c4000)
-
我在 /srv/modwsgi/env 中创建了 virtualenv 并安装了 pyramid
使用
pcreate -s starter myapp创建了一个启动脚手架,激活了venv,运行python setup.py install并创建了guestbook.wsgi 脚本
from pyramid.paster import get_app, setup_logging
ini_path = '/srv/env/bin/myapp/production.ini'
setup_logging(ini_path)
application = get_app(ini_path, 'main')
然后我将整个 env 目录改成 apache:apache
- 在 /etc/httpd/conf.d/ 我创建了 guestbook.conf
`
WSGIApplicationGroup %{GLOBAL}
WSGIPassAuthorization On
WSGIDaemonProcess guestbook user=apache group=apache threads=4 \
python-path=/srv/modwsgi/env/lib/python3.5/site-packages
WSGIPythonHome /srv/modwsgi/env/lib/python3.5/
WSGIScriptAlias /guestbook /srv/modwsgi/env/guestbook.wsgi
<Directory /srv/modwsgi/env>
WSGIProcessGroup guestbook
Order allow,deny
Allow from all
</Directory>
最后我在浏览器中运行它,它说
服务暂时不可用
由于维护停机或容量问题,服务器暂时无法满足您的请求。请稍后再试。 Apache/2.2.15 (CentOS) 服务器位于spiralarms.org 80 端口
当我尝试访问此页面时,错误日志中没有任何新内容
更新:
我尝试运行一个简单的 wsgi 应用程序
import sys
def application(environ, start_response):
status = '200 OK'
output = 'Hello World!'+str(sys.version_info)
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
看来 mod_wsgi 使用 python 2,但它应该使用 3。
更新: 我终于编译并安装了 modwsgi(按照https://github.com/GrahamDumpleton/mod_wsgi/issues/101(参见最后一篇文章)),现在它在导入编码模块时遇到了问题
Current thread 0x00007f45a4cfd7e0 (most recent call first):
[Mon Mar 21 16:33:56 2016] [notice] child pid 7325 exit signal Aborted (6)
[Mon Mar 21 16:33:56 2016] [notice] child pid 7326 exit signal Aborted (6)
[Mon Mar 21 16:33:56 2016] [notice] child pid 7327 exit signal Aborted (6)
Fatal Python error: Py_Initialize: Unable to get the locale encoding
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Current thread 0x00007f45a4cfd7e0 (most recent call first):
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Current thread 0x00007f45a4cfd7e0 (most recent call first):
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Current thread 0x00007f45a4cfd7e0 (most recent call first):
ImportError: No module named 'encodings'
更新:如果没有 WSGIPythonHome,它不会抱怨 编码,但现在它会给出“内部服务器错误”
更新:终于找到了名称奇怪的日志“虚拟主机”,错误是我的配置中没有这一行WSGISocketPrefix /var/run/wsgi
【问题讨论】:
标签: apache python-3.x mod-wsgi pyramid