Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django + Apache + mod_wsgi permission denied

I finished the tutorial on Django's site about using mod_wsgi (here), and having substituted my paths as appropriate, results in a big fat "Permission denied." when I try to access /. Here is the stuff I added to httpd.conf (mod_wsgi is enabled earlier in the conf file):

# Django configuration

WSGIScriptAlias / /usr/local/django/billing/apache/django.wsgi

<Directory /usr/local/django/billing/apache/django.wsgi>
Order allow,deny
Allow from all
</Directory>

AliasMatch ^/([^/]*\.css) /usr/local/wsgi/static/styles/$1

Alias /media/ /usr/local/django/billing/media/
Alias /static/ /usr/local/django/billing/static/

<Directory /usr/local/django/billing/static>
Order deny,allow
Allow from all
</Directory>

<Directory /usr/local/django/billing/media>
Order deny,allow
Allow from all
</Directory>

Edit #1:

I've gone through the slides multiple times, from the start: still no joy. Even after opening up the path to the script, chmod'ing every relevant directory to be readable, and chmod'ing the .wsgi script, I still get permission denied. If I change the directory path from /usr/local/django/billing/apache/django.wsgi to have the django.wsgi truncated, the server returns a configuration error, despite that being how it's configured in the slides.

like image 277
patrickn Avatar asked Feb 21 '12 22:02

patrickn


2 Answers

Same configuration, same environment... but everything was working except a simple call to Popen() in one of my django/python routines...

"Permission denied"

Turned out to be SELINUX (enforcing mode) blocking apache.

You can make SELINUX happy with your application by running the following commands:

# semanage fcontext -a -t httpd_sys_rw_content_t '/path/to/your/app(/.*)?'
# restorecon -R -v /path/to/your/app
like image 104
pedwards Avatar answered Nov 03 '22 22:11

pedwards


I had the same problem with permission denied. https://serverfault.com/questions/357804/apache2-mod-wsgi-django-named-virtual-servers

The specific error is described in: http://code.google.com/p/modwsgi/wiki/WhereToGetHelp?tm=6#Conference_Presentations

like image 6
dm03514 Avatar answered Nov 03 '22 22:11

dm03514