Apologies for the late reply!
I realised I had missed a few errors in my apache restart log. Even though
the final message I received was "httpd restarted successfully.", some
errors like the "(13)Permission denied" one were being reported as well (I
just didn't scroll up far enough to notice them). Oddly enough, these
errors didn't always show up in the actual error_log file.
So I restarted from scratch again, following the same steps as outlined in
my opening post, but using a conda environment (djangotest), conda
virtualenv (djangoenv) and non-conda (base python) virtualenv.
pre_main_global.conf
# conda env
LoadModule wsgi_module
"/home/user/.conda/envs/djangotest/lib/python3.6/site-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so"
WSGIPythonHome "/home/user/.conda/envs/djangotest"
# conda virtualenv
#LoadModule wsgi_module
"/home/user/public_html/django/djangoenv/lib/python3.6/site-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so"
#WSGIPythonHome "/home/user/public_html/django/djangoenv"
# non-conda virtualenv
LoadModule wsgi_module
"/home/user/public_html/django/django-base-env/django-base-env/lib/python3.6/site-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so"
WSGIPythonHome
"/home/user/public_html/django/django-base-env/django-base-env
virtual host
Alias /static /home/user/public_html/django/myproject/static
<Directory /home/user/public_html/django/myproject/static>
Require all granted
</Directory>
<Directory /home/user/public_html/django/myproject/myproject>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess djangotest python-home=/home/user/.conda/envs/djangotest
#WSGIDaemonProcess djangotest
python-home=/home/user/public_html/django/djangoenv
#WSGIDaemonProcess djangotest socket-user=#1000
python-home=/home/user/public_html/django/django-base-env
WSGIProcessGroup djangotest
WSGIScriptAlias / /home/user/public_html/django/myproject/myproject/wsgi.py
Results for conda environment (after rebuilding conf files and restarting
apache):
[Tue Jul 03 12:38:02.882573 2018] [wsgi:error] [pid 10269] (13)Permission
denied: [client 143.129.70.74:35706] mod_wsgi (pid=10269): Unable to
connect to WSGI daemon process 'djangotest' on
'/var/run/apache2/wsgi.13810.95.1.sock' as user with uid=1000.
- Adding `LoadFile /opt/miniconda3/lib/libpython3.6m.so.1.0` to the
pre_main_global.conf file does not seem to do anything.
- Adding a `WSGISocketPrefix /tmp/wsgi` line does not seem to change
this error.
- Neither does adding socket-user=#1000
The actual error log shows:
[Tue Jul 03 13:40:25.878834 2018] [mpm_prefork:notice] [pid 13810] AH00171:
Graceful restart requested, doing restart
[Tue Jul 03 13:40:25.972140 2018] [ssl:warn] [pid 13810] AH01909: proxy-
subdomains-ssl-default-vhost.localhost:443:0 server certificate does NOT
include an ID which matches the server name
[Tue Jul 03 13:40:25.981758 2018] [:notice] [pid 13810] mod_ruid2/0.9.8
enabled
[Tue Jul 03 13:40:25.984009 2018] [mpm_prefork:notice] [pid 13810] AH00163:
Apache/2.4.33 (cPanel) OpenSSL/1.0.2o mod_bwlimited/1.4 mod_wsgi/4.6.4
Python/3.6 configured -- resuming normal operations
[Tue Jul 03 13:40:25.984046 2018] [core:notice] [pid 13810] AH00094: Command
line: '/usr/sbin/httpd'
Results for virtualenv:
[Tue Jul 03 12:38:03.541889 2018] [wsgi:error] [pid 10270] (13)Permission
denied: [client 143.129.70.74:35712] mod_wsgi (pid=10270): Unable to
connect to WSGI daemon process 'djangotest' on
'/var/run/apache2/wsgi.13810.95.1.sock' as user with uid=1000.
- Adding `LoadFile /opt/miniconda3/lib/libpython3.6m.so.1.0` to the
pre_main_global.conf file does not seem to do anything.
- Adding a `WSGISocketPrefix /tmp/wsgi` line does not seem to change
this error.
- Neither does adding socket-user=#1000
Results for non-conda python3.6 virtualenv
[Tue Jul 03 12:38:02.882573 2018] [wsgi:error] [pid 10269] (13)
Permission denied: [client 143.129.70.74:35706] mod_wsgi (pid=10269): Unable
to connect to WSGI daemon process 'djangotest' on
'/var/run/apache2/wsgi.13810.95.1.sock' as user with uid=1000.
Adding ` socket-user=#1000` DOES result in a successfull apache restart
without any errors in the output. However, the apache error log then reads:
Current thread 0x00007f8ed2d49880 (most recent call first):
[Tue Jul 03 20:24:57.474778 2018] [core:notice] [pid 13810] AH00052: child
pid 27489 exit signal Aborted (6)
[Tue Jul 03 20:24:57.476480 2018] [wsgi:warn] [pid 27493] (2)No such file or
directory: mod_wsgi (pid=27493): Unable to stat Python home /home/user/
public_html/django/django-base-env/django-base-env. Python interpreter may
not be able to be initialized correctly. Verify the supplied path and
access permissions for whole of the path.
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'
I wanted to add a new LoadFile statement, but it seems that the mod_wsgi
version, installed via pip in a non-conda virtualenv (base python3.6) was
still associated with conda somehow:
ldd django-base-env/lib/python3.6/site-packages/mod_wsgi/server/mod_wsgi-
py36.cpython-36m-x86_64-linux-gnu.so
linux-vdso.so.1 => (0x00007ffeeefda000)
libpython3.6m.so.1.0 => /opt/miniconda3/lib/libpython3.6m.so.1.0 (
0x00007f3813c24000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f38139fa000)
libc.so.6 => /lib64/libc.so.6 (0x00007f381362d000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f3813429000)
libutil.so.1 => /lib64/libutil.so.1 (0x00007f3813225000)
librt.so.1 => /lib64/librt.so.1 (0x00007f381301d000)
libm.so.6 => /lib64/libm.so.6 (0x00007f3812d1b000)
/lib64/ld-linux-x86-64.so.2 (0x00007f38143a6000)
The weird thing is that I explicitly used the base python3.6 and its pip
binaries to create this environment.
/usr/local/bin/virtualenv -p /usr/bin/python3.6 django-base-env
I suspect this is caused by the fact that the original 3.6 install wasn't
configured with the shared_library option and that it is somehow defaulting
back to conda's shared library?
Adding the original LoadFile statement (using the /opt/miniconda path)
doesn't change the apache error log.
In all cases, `httpd -M` shows Loaded Modules: wsgi_module (shared)
Perhaps I should try installing a second python 3.6 (non-conda) version?
Although I'm a bit afraid I'll mess up my system if I'm not careful. I
actually tried removing this python3.6 version using yum, but that didn't
remove the actual binaries/symlinkms/paths apparently.
On Friday, June 29, 2018 at 10:33:42 AM UTC+2, Graham Dumpleton wrote:
>
> Looks like your Apache may be running with:
>
> PrivilegesMode SECURE
>
> See:
>
>
> https://httpd.apache.org/docs/2.4/mod/mod_privileges.html#privilegesmode
>
> In that case you will need to supply the socket-user option to
> WSGIDaemonProcess.
>
>
> http://modwsgi.readthedocs.io/en/develop/configuration-directives/WSGIDaemonProcess.html
>
> So add to WSGIDaemonProcess:
>
> socket-user=#1000
>
> You possibly don't then need to override WSGISocketPrefix.
>
> Graham
>
--
You received this message because you are subscribed to the Google Groups
"modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.