2012-10-02 3 views
0

J'ai perdu 3 jours à essayer de faire fonctionner Apache avec django et devenir très frustré. Ive luDjango 1.4 mod_wsgi - 403 interdit, accès à/refusé

https://docs.djangoproject.com/en/1.4/howto/deployment/wsgi/modwsgi/

http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango

La configuration est différente entre les liens et je pense qu'ils sont un peu dépassées maintenant avec django 1.4 L'im d'erreur face dans le journal apache est

(13) Autorisation refusée: accès à/refusé

Environnement:

Python 2,62

Centos 6.2 sur Windows Azure

Apache/2.2.15

Django 1.4

chemins:

/home/craig/django /myproject/myproject/wsgi.py

Autorisations:

/home /: drwxrwxr-x

/home/craig /: drwxrwxr-x

/home/craig/django /: drwxrwxr-x

/home/craig/django/myproject /: drwxrwxr-x

/home/craig/django/myproject/myproject /: drwxrwxr-x

/home/craig/django/myproject/myproject/wsgi.py: -rw- r - r -

http.conf:

DocumentRoot "/var/www/html" 

<Directory /> 
Options FollowSymLinks 
AllowOverride All 
</Directory> 

<Directory /home/craig/django/myproject/myproject> 
<Files wsgi.py> 
Order deny,allow 
Allow from all 
</Files> 
</Directory> 

WSGIScriptAlias//home/craig/django/myproject/myproject/wsgi.py 
WSGIPythonPath /home/craig/django/myproject 

<VirtualHost *:80> 
ServerName myserver.domain.net 
</VirtualHost> 

wsgi.py

import os 

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings") 
from django.core.wsgi import get_wsgi_application 
application = get_wsgi_application() 
+0

Ceci est un double de http : //serverfault.com/questions/434020/django-1-4-mod-wsgi-403-forbidden-access-to-denied –

Répondre

0

Ce problème a été immédiatement fixé par la désactivation SELINUX en exécutant la commande suivante: setenforce 0

Ce meilleur pratice probablement isnt, mais à des fins de développement, il a fait le travail pour moi

0

Quand je suis passé de Django 1,3 à 1,4, je le processus démon (je ne suis pas avec les anciennes versions de Django). Cela a fonctionné pour moi avec les fichiers Django 1.4 wsgi.py générés par createprojet. Voici une version simplifiée d'un de mes configs:

Listen 8091 

<VirtualHost 127.0.0.1:8091> 

    ServerAdmin [email protected] 
    ServerName foobar.com 

    # Django 1.4 project and virtualenv 
    WSGIDaemonProcess foobar python-path=/home/micah/www/foobar.com/foobar:/home/micah/www/foobar.com/venv/lib/python2.6/site-packages 
    WSGIProcessGroup foobar 
    WSGIScriptAlias//home/micah/www/foobar.com/foobar/foobar/wsgi.py 

</VirtualHost> 

Je note que Apache était derrière un proxy Nginx (d'où l'adresse IP de l'hôte virtuel) et que j'utilisais environnement virtuel (d'où le python-path).