tildaslash / RatticWeb

Password Management for Humans
http://rattic.org/
GNU General Public License v2.0
473 stars 149 forks source link

Python module cannot be loaded #460

Closed Dwijad closed 7 years ago

Dwijad commented 7 years ago

Hi I am trying to install ratticDB in ubuntu 16. Installed python3 module for apache. The default-ssl.conf configuration looks like this-

ServerAdmin webmaster@demohost.com # DocumentRoot /var/www/html SSLEngine on SSLCertificateFile /etc/ssl/certs/demohost.com.crt SSLCertificateKeyFile /etc/ssl/private/demohost.com.key SSLOptions +StdEnvVars SSLOptions +StdEnvVars BrowserMatch "MSIE [2-6]" \ nokeepalive ssl-unclean-shutdown \ downgrade-1.0 force-response-1.0 # MSIE 7 and newer should be able to use keepalive BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown Alias /robots.txt /opt/apps/RatticWeb/static/robots.txt Alias /favicon.ico /opt/apps/RatticWeb/static/favicon.ico AliasMatch ^/([^/]*\.css) /opt/apps/RatticWeb/static/styles/$1 Alias /media/ /opt/apps/RatticWeb/media/ Alias /static/ /opt/apps/RatticWeb/static/ Require all granted Require all granted WSGIScriptAlias / /opt/apps/RatticWeb/ratticweb/wsgi.py WSGIPassAuthorization On WSGIDaemonProcess rattic processes=2 threads=25 home=/opt/apps/RatticWeb/ python-path=/opt/apps/RatticWeb display-name=%{GROUP} WSGIProcessGroup rattic Require all granted

But i get 500 internal server error. ( Target WSGI script '/opt/apps/RatticWeb/ratticweb/wsgi.py' cannot be loaded as Python module.)

Does python3 module for apache works with RatticDB ?

Thanks

Dwijad commented 7 years ago

I am attaching more information as it looks mod_wsgi is compiled against python3 and apache2 is using python3 module ( apt-get install libapache2-mod-wsgi-py3 ).

root@demohost:~# cat /etc/apache2/mods-available/wsgi.load LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so

root@demohost:~# ldd /usr/lib/apache2/modules/mod_wsgi.so linux-vdso.so.1 => (0x00007ffe7f9ea000) libpython3.5m.so.1.0 => /usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0 (0x00007f9f26c1a000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f9f269fd000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f9f26633000) libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f9f2640a000) libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f9f261f0000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f9f25feb000) libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f9f25de8000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f9f25adf000) /lib64/ld-linux-x86-64.so.2 (0x0000563d3323d000) root@demohost:~#

Apache Logs (Debug mode) [Thu Jan 26 07:07:09.156047 2017] [wsgi:info] [pid 4064] mod_wsgi (pid=4064): Initializing Python. [Thu Jan 26 07:07:09.171233 2017] [wsgi:info] [pid 4064] mod_wsgi (pid=4064): Attach interpreter ''. [Thu Jan 26 07:07:09.908074 2017] [ssl:debug] [pid 4004] ssl_engine_kernel.c(2023): [client 117.227.65.236:34900] AH02041: Protocol: TLSv1.2, Cipher: ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits) [Thu Jan 26 07:07:09.908272 2017] [ssl:debug] [pid 4004] ssl_engine_kernel.c(354): [client 117.227.65.236:34900] AH02034: Initial (No.1) HTTPS request received for child 2 (server demohost.com:443) [Thu Jan 26 07:07:09.908395 2017] [authz_core:debug] [pid 4004] mod_authz_core.c(809): [client 117.227.65.236:34900] AH01626: authorization result of Require all granted: granted [Thu Jan 26 07:07:09.908440 2017] [authz_core:debug] [pid 4004] mod_authz_core.c(809): [client 117.227.65.236:34900] AH01626: authorization result of : granted [Thu Jan 26 07:07:09.908563 2017] [authz_core:debug] [pid 4004] mod_authz_core.c(809): [client 117.227.65.236:34900] AH01626: authorization result of Require all granted: granted [Thu Jan 26 07:07:09.908608 2017] [authz_core:debug] [pid 4004] mod_authz_core.c(809): [client 117.227.65.236:34900] AH01626: authorization result of : granted [Thu Jan 26 07:07:09.921327 2017] [wsgi:info] [pid 4001] mod_wsgi (pid=4001): Create interpreter 'demohost.com|'. [Thu Jan 26 07:07:09.933245 2017] [wsgi:info] [pid 4001] mod_wsgi (pid=4001): Adding '/opt/apps/RatticWeb' to path. [Thu Jan 26 07:07:09.933819 2017] [wsgi:info] [pid 4001] [remote 117.227.65.236:57350] mod_wsgi (pid=4001, process='rattic', application='demohost.com|'): Loading WSGI script '/opt/apps/RatticWeb/ratticweb/wsgi.py'. [Thu Jan 26 07:07:09.934173 2017] [wsgi:error] [pid 4001] [remote 117.227.65.236:57350] mod_wsgi (pid=4001): Target WSGI script '/opt/apps/RatticWeb/ratticweb/wsgi.py' cannot be loaded as Python module. [Thu Jan 26 07:07:09.934233 2017] [wsgi:error] [pid 4001] [remote 117.227.65.236:57350] mod_wsgi (pid=4001): Exception occurred processing WSGI script '/opt/apps/RatticWeb/ratticweb/wsgi.py'. [Thu Jan 26 07:07:09.934410 2017] [wsgi:error] [pid 4001] [remote 117.227.65.236:57350] Traceback (most recent call last): [Thu Jan 26 07:07:09.934479 2017] [wsgi:error] [pid 4001] [remote 117.227.65.236:57350] File "/opt/apps/RatticWeb/ratticweb/wsgi.py", line 22, in [Thu Jan 26 07:07:09.934510 2017] [wsgi:error] [pid 4001] [remote 117.227.65.236:57350] from django.core.wsgi import get_wsgi_application [Thu Jan 26 07:07:09.934549 2017] [wsgi:error] [pid 4001] [remote 117.227.65.236:57350] ImportError: No module named 'django' [Thu Jan 26 07:07:09.934753 2017] [ssl:debug] [pid 4004] ssl_engine_io.c(1016): [client 117.227.65.236:34900] AH02001: Connection closed to child 2 with standard shutdown (server demohost.com:443)

Thanks

Dwijad commented 7 years ago

Hi Able to solve the problem by compiling mod_wsgi against python3.5 and then creating apache configuration for wsgi (wsgi.load). The steps are given below if someone wants to compile and install mod_wsgi in ubuntu 16.04 . Also i have removed apache module for python3 that i have installed earlier using apt-get.

root@demohost:~# apt-get purge libapache2-mod-wsgi-py3
root@demohost:~# wget https://github.com/GrahamDumpleton/mod_wsgi/archive/develop.zip
root@demohost:~# unzip develop.zip
root@demohost:~# cd mod_wsgi-develop
root@demohost:~/mod_wsgi-develop#./configure --with-python=/usr/bin/python3.5
root@demohost:~/mod_wsgi-develop# make
root@demohost:~/mod_wsgi-develop# make install

root@demohost:~/mod_wsgi-develop# cd /etc/apache2/mods-available
root@demohost:/etc/apache2/mods-available# vi wsgi.load
LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so

root@demohost:/etc/apache2/mods-available# cd /etc/apache2/mods-enabled
root@demohost:/etc/apache2/mods-enabled# ln -s ../mods-available/wsgi.load .

root@demohost:/etc/apache2/mods-enabled# service apache2 start

Hope it helps others. Thanks