[Answered ]-Unable to connect to WSGI daemon process mod_wsgi in Centos7 with Cpanel/WHM

2👍

See socket-user option in:

Recent CPanel installations seem to use PrivilegesMode set to SECURE 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 the WSGIDaemonProcess directive in the Apache configuration the option:

socket-user=bmhair

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 user bmhair.

Note that this will require that the directory /var/run/apache2 provides access to other users, ie., not just root or the user Apache runs your code as. If that is not the case, then use WSGISocketPrefix to move the socket file to another directory which is accessible to the user bmhair. Generally you should not need to even override WSGISocketPrefix 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.

0👍

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.

  • If it is VPS:

WSGISocketPrefix /var/run/wsgi

  • If you are in a shared hosting:

WSGISocketPrefix ../../var/run/wsgi

Or

WSGISocketPrefix /home/bmhair/var/run/wsgi

As I can see you are in bmhair user so for you 2nd one will work.

Leave a comment