samedi 29 novembre 2014

Django + Apache + mod_wsgi permission refusée - Stack Overflow


Posted this at ServerFault, but I'm hoping a Django ninja can help me out here on SO. I finished the tutorial on Django's site about using mod_wsgi (https://docs.djangoproject.com/en/1.3/howto/deployment/modwsgi/), 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.




I had the same problem with permission denied. http://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




Not an answer to this problem, but may help others searching like I was...


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.




I had the same issue,Sometimes this happends if the WSGI application is located outside of any directories already configured to be accessible to Apache, particularly when it is on your home directory, its good to specify user=username directive.


/etc/apahe2/sites-avaliable/myvhost [section]


WSGIDaemonProcess localhost python-path=/home/hemanth/ecm:/home/env/lib/python2.7/site-packages  user=hemanth
WSGIProcessGroup localhost

/etc/apahe2/sites-avaliable/myvhost [full]


    <VirtualHost *:80>
ServerAdmin xy@gmail.om
ServerName localhost
ServerAlias localhost

DocumentRoot /home/hemanth/ecm

<Directory /home/hemanth/ecm>
Order allow,deny
Allow from all
</Directory>

WSGIScriptAlias / /home/hemanth/ecm/index.wsgi
WSGIDaemonProcess localhost python-path=/home/hemanth/ecm:/home/env/lib/python2.7/site-packages user=hemanth
WSGIProcessGroup localhost


Alias /static/ /home/hemanth/ecm/static/

Alias /media/ /home/hemanth/ecm/media/
<Directory /home/hemanth/ecm/media/>
Order allow,deny
Allow from all
</Directory>

<Location "/static/">
Options -Indexes
</Location>

ErrorLog /home/hemanth/ecm/error.log
</VirtualHost>

index.wsgi


import os
import sys
import site

# Add the site-packages of the chosen virtualenv to work with
site.addsitedir('/home/hemanth/env/local/lib/python2.7/site-packages')

# Add the app's directory to the PYTHONPATH
sys.path.append('/home/hemanth/ecm')
sys.path.append('/home/hemanth/ecm/ecm')

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ecm.settings")

# Activate your virtual env
activate_env="/home/hemanth/env/bin/activate_this.py"
execfile(activate_env, dict(__file__=activate_env))

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()


Posted this at ServerFault, but I'm hoping a Django ninja can help me out here on SO. I finished the tutorial on Django's site about using mod_wsgi (https://docs.djangoproject.com/en/1.3/howto/deployment/modwsgi/), 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.



Not an answer to this problem, but may help others searching like I was...


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.



I had the same issue,Sometimes this happends if the WSGI application is located outside of any directories already configured to be accessible to Apache, particularly when it is on your home directory, its good to specify user=username directive.


/etc/apahe2/sites-avaliable/myvhost [section]


WSGIDaemonProcess localhost python-path=/home/hemanth/ecm:/home/env/lib/python2.7/site-packages  user=hemanth
WSGIProcessGroup localhost

/etc/apahe2/sites-avaliable/myvhost [full]


    <VirtualHost *:80>
ServerAdmin xy@gmail.om
ServerName localhost
ServerAlias localhost

DocumentRoot /home/hemanth/ecm

<Directory /home/hemanth/ecm>
Order allow,deny
Allow from all
</Directory>

WSGIScriptAlias / /home/hemanth/ecm/index.wsgi
WSGIDaemonProcess localhost python-path=/home/hemanth/ecm:/home/env/lib/python2.7/site-packages user=hemanth
WSGIProcessGroup localhost


Alias /static/ /home/hemanth/ecm/static/

Alias /media/ /home/hemanth/ecm/media/
<Directory /home/hemanth/ecm/media/>
Order allow,deny
Allow from all
</Directory>

<Location "/static/">
Options -Indexes
</Location>

ErrorLog /home/hemanth/ecm/error.log
</VirtualHost>

index.wsgi


import os
import sys
import site

# Add the site-packages of the chosen virtualenv to work with
site.addsitedir('/home/hemanth/env/local/lib/python2.7/site-packages')

# Add the app's directory to the PYTHONPATH
sys.path.append('/home/hemanth/ecm')
sys.path.append('/home/hemanth/ecm/ecm')

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ecm.settings")

# Activate your virtual env
activate_env="/home/hemanth/env/bin/activate_this.py"
execfile(activate_env, dict(__file__=activate_env))

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

0 commentaires:

Enregistrer un commentaire