[Django]-Django apache configuration with WSGIDaemonProcess not working

14👍

WSGIDaemonProcess   Rent  python-path=/var/www/rent:/root/.virtualenvs/rent/lib/python2.7/site-packages

This is the most likely cause of the problem. You have created a virtualenv inside the super user’s home folder. But that folder is unlikely to be accessible to apache. A user’s home folder is not accessible to any other user by default.

The web server and the WSGI process will be running as a non privileged user typically named nobody, httpd, apache or something similar. While you can fix this problem by changing the permissions on /root/ that’s a big no no. It would be less dangerous if it was an ordinary user but still not a good idea to do this.

The best solution is to put the virtualenv in a location accessible by the unprivileged user. /usr/local/virtualenv is a good location.

Please note that moving /root/.virtualenvs/ to /usr/local/virtualenv you will have to recreate it as follows

 source /root/.virtualenvs/rent/bin/activate
 pip freeze > /tmp/requirements.txt
 cd /usr/local/
 virtualenv virtualenv
 source virtualenv/bin/activate
 pip install -r /tmp/requirements.txt

then edit the httpd.conf file to reflect the new path.

👤e4c5

Leave a comment