Apache httpd mod_wsgi python3金字塔服务暂时不可用
简而言之,我所做的是:Apache httpd mod_wsgi python3金字塔服务暂时不可用,apache,python-3.x,mod-wsgi,pyramid,Apache,Python 3.x,Mod Wsgi,Pyramid,简而言之,我所做的是: 我下载了python 3.5源代码,并用 ` 我已经使用pip3.5安装mod_wsgi安装了mod_wsgi 我还尝试从源代码安装它(从这里http://modwsgi.googlecode.com/files/mod_wsgi-3.4.tar.gz)使用 /configure--with python=/usr/local/bin/python3.5 制作 进行安装 但是它就这样结束了 ` 所以我继续使用modwsgi表单pip,但是lld说它仍然是第2个python
pip3.5安装mod_wsgi
安装了mod_wsgi
我还尝试从源代码安装它(从这里http://modwsgi.googlecode.com/files/mod_wsgi-3.4.tar.gz
)使用
/configure--with python=/usr/local/bin/python3.5
制作
进行安装
但是它就这样结束了pcreate-s starter myapp
创建已启动的scaffold,激活venv,运行python setup.py安装
并创建guestbook.wsgi脚本
从pyramid.paster导入获取应用程序,设置日志
ini_path='/srv/env/bin/myapp/production.ini'
设置日志(ini路径)
应用程序=获取应用程序(ini\u路径,“主”)
然后,我将整个env目录转换为apache:apache
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
终于让它开始工作了
将调用日志文件(默认情况下)
dummy-host.example.com-error_log,位于apache日志目录中
这是我的配置(为了简单起见,它们的设计没有虚拟主机)
guestbook.conf(用于金字塔应用程序)
用于非金字塔应用程序(hello world示例显示了我们的python版本)
hellowsgi.conf:
hello.wsgi:
另外,不要忘记为所有文件授予apache访问权限
我已经(用俄语)写过了
/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
...
(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)
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>
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]
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'
LoadModule wsgi_module modules/mod_wsgi.so
WSGISocketPrefix /var/run/wsgi #don't forget this line
WSGIApplicationGroup %{GLOBAL}
WSGIPassAuthorization On
WSGIDaemonProcess guestbook user=apache group=apache threads=4 \
python-path=/srv/modwsgi/env/lib/python3.5/site-packages
#python-path=/usr/local/lib/python3.5/site-packages
WSGIScriptAlias /guestbook /srv/modwsgi/env/guestbook.wsgi
<Directory /srv/modwsgi/env>
WSGIProcessGroup guestbook
Order allow,deny
Allow from all
</Directory>
from pyramid.paster import get_app, setup_logging
ini_path = '/srv/modwsgi/env/guestbook-0.0/production.ini' #use a full path cause it will be runned from apache directory
setup_logging(ini_path)
application = get_app(ini_path, 'main')
#LoadModule wsgi_module modules/mod_wsgi.so uncomment this if it's not in other configs or better put it in the global config
WSGIScriptAlias /hello /srv/modwsgi/hello.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 [bytes(output,'utf-8')] # use bytes for python 3 wsgi