Shortly what i've done:
`
./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
I've installed mod_wsgi using pip3.5 install mod_wsgi
.
I also tried to install it from sources (from here http://modwsgi.googlecode.com/files/mod_wsgi-3.4.tar.gz
) using
./configure --with-python=/usr/local/bin/python3.5
make
make install
But it finished like that
`
/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
...
So i proceeded with modwsgi form pip but lld said that it's still 2th python so in it
`
(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)
I've created virtualenv in /srv/modwsgi/env and installed pyramid
Created a started scaffold with pcreate -s starter myapp
,activated venv, ran python setup.py install
and created the guestbook.wsgi script
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')
then i chowned the whole env dir to apache:apache
`
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>
and finally i ran it in browser and it says
Service Temporarily Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later. Apache/2.2.15 (CentOS) Server at spiralarms.org Port 80
There's nothing new in error log when i try to access this page
UPDATE:
I tried running a simple wsgi application
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]
and it appears that mod_wsgi uses python 2, but it should use 3.
UPDATE: I finally compiled and installed modwsgi (following this https://github.com/GrahamDumpleton/mod_wsgi/issues/101 (see last post)) and now it have problems with importing encodings module
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'
UPDATE: Without WSGIPythonHome it doesn't complains about encodings but now it gives 'internal server error'
UPDATE: Finally found logs with weird name 'dummy host' and the error was i didn't have this line in my config WSGISocketPrefix /var/run/wsgi
Finally got it to work!
The log file is called (by default) dummy-host.example.com-error_log and located in the apache log directory
Here are my configs (they are designed with no VirtualHosts for simplicity)
guestbook.conf (for pyramid apps)
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>
Here is guestbook.wsgi
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')
For non-pyramid apps (hello world example that shows our python version)
hellowsgi.conf:
#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
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
Also don't forget to give access to apache for all the files.
I have written an article on this (in russian)