Apache mod_wsgi Django setup - Forbidden You don't have permission to access /mysite on this server.

2,122 views
Skip to first unread message

justin jools

unread,
Aug 11, 2009, 10:13:04 AM8/11/09
to Django users
Ive been the install instructions in : http://wiki.thinkhole.org/howto:django_on_windows%E2%80%8F
(with mod_wsgi)

install python 26, Apache 2.2, modwsgi ap2.2 py26

and apache loads modwsgi fine.

when I check localhost: apache says - It works!
when I check 127.0.0.1:8000: Django says - It worked!

but when i try to open the Django directory mysite: localhost/mysite i
get :

Forbidden

You don't have permission to access /mysite on this server.

I have re-installed and installed this many times but still the same
thing. The tutorial says should get: It worked

httpd.conf
LoadModule wsgi_module modules/mod_wsgi.so
WSGIScriptAlias / /usr/local/mysite/django.ws

runs fine, as in: http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango

could someone please help with this...

thanks

Gustavo Henrique

unread,
Aug 11, 2009, 12:51:16 PM8/11/09
to django...@googlegroups.com
Do you using a windows ou linux?
if it's linux, try:

create a dir: /home/user/django and put your project inside it and
create a file called mysite.wsgi in same dir containing:

import os, sys
sys.path.append('/usr/lib/python2.6/site-packages/django/')
sys.path.append('/home/user/myproject')
os.environ['DJANGO_SETTINGS_MODULE']='myproject.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()


and modofy the apache configuration (I'm using ubuntu):

# vim /etc/apache2/sites-enabled/000-default

WSGIRestrictStdout Off
<VirtualHost *:80>
LimitInternalRecursion 1000
ServerAdmin webmaster@localhost
ServerName localhost
DocumentRoot /home/user/django/
ErrorLog /home/user/django/apache.log
LogLevel warn
AddHandler wsgi-script .wsgi
<Directory "/home/user/django">
AllowOverride FileInfo
Options ExecCGI MultiViews FollowSymLinks
MultiviewsMatch Handlers
Order deny,allow
Allow from all
</Directory>
Alias /media/ "/home/user/django/myproject/media/"
<Directory "/home/user/django/myproject/media/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
allow from all
</Directory>

</VirtualHost>


--
Gustavo Henrique
http://www.gustavohenrique.net
http://blog.gustavohenrique.net

Graham Dumpleton

unread,
Aug 11, 2009, 5:41:37 PM8/11/09
to Django users
The instructions also say to have configuration:

<Directory /usr/local/django/mysite/apache>
Order deny,allow
Allow from all
</Directory>

as well as other configuration, that being the location where you put
the .wsgi fle. Why haven't you done similar thing for your setup?

You also need an Alias directive and access configuration to make
available the media files. Again, you appear not to have done that.
Please reread the instructions and if above isn't all your
configuration you duplicated from documented instructions, also show
the rest and detail where you installed things on the filesystem.

Graham
Reply all
Reply to author
Forward
0 new messages