I’m with a problem while deploying Django
in my VPS with Centos 7.3
and WHM. It seems to work, except for a socket problem with mod_wsgi
.
[Sun Jun 25 00:37:03.254774 2017] [wsgi:error] [pid 29756] (13)Permission denied: [client 66.249.83.220:35523] mod_wsgi (pid=29756): Unable to connect to WSGI daemon process 'brunamaiahair.com.br' on '/var/run/apache2/wsgi.721.27.1.sock' as user with uid=1004.
I read to insert WSGISocketPrefix as a directive, so I edited httpd.conf
and put:
WSGISocketPrefix /var/run/apache2/wsgi
But I’m receiving the same error. Here is the log with the modified httpd.conf
after an Apache restart:
[Sat Jun 24 21:10:56.084269 2017] [mpm_prefork:notice] [pid 721] AH00163: Apache/2.4.25 (cPanel) OpenSSL/1.0.2k mod_bwlimited/1.4 mod_wsgi/4.5.7 Python/2.7 configured -- resuming normal operations
Here is my VirtualHost
configuration:
WSGIDaemonProcess brunamaiahair.com.br socket-user=#1004 python-path=/home/bmhair/public_html/django/framework:/home/bmhair/public_html/django/denv/lib/python2.7/site-packages
WSGIProcessGroup brunamaiahair.com.br
WSGIScriptAlias / /home/bmhair/public_html/django/framework/framework/wsgi.py
2
Answers
See
socket-user
option in:Recent CPanel installations seem to use
PrivilegesMode
set toSECURE
so you will need to declare who should own the socket. It should be the user/uid Apache changes to when handling requests for you, rather than the default of the Apache user.If for example the user which CPanel is setup to run your request as under Apache is
bmhair
, you need to add to theWSGIDaemonProcess
directive in the Apache configuration the option:After a restart of Apache, check in the directory where the socket file is placed, eg.,
/var/run/apache2
and check that socket file is owned by userbmhair
.Note that this will require that the directory
/var/run/apache2
provides access to other users, ie., not justroot
or the user Apache runs your code as. If that is not the case, then useWSGISocketPrefix
to move the socket file to another directory which is accessible to the userbmhair
. Generally you should not need to even overrideWSGISocketPrefix
as the default location used is fine. If you had set it explicitly for some reason, and didn’t allow the default to be used, that could also be part of the problem.The path /var/run/apache2 bmhair do not have access to that folder.Only root and approved users have.
So we need to show apache a path for wsgi socket.
Or
As I can see you are in bmhair user so for you 2nd one will work.