views:

170

answers:

2

I get this problem when I visit my domain.com. I have compared this with my other website with the SAME set-up (just different username!!!) For some reason that website works and this one doesn't.

Forbidden
You don't have permission to access / on this server.
Apache/2.2.3 (Red Hat) Server at www.mydomain.com Port 80

In terms of permission issues, I have added user "apache" to the group "dver" and "svn" that own the folders that everything is located on.

$ ls -l
total 4
drwxr-xr-x 4 dver svn 4096 Oct 13 19:49 tv

This is my django.wsgi:

import os
import sys
sys.path.append('/home/dver/tv')
os.environ['PYTHON_EGG_CACHE'] = '/home/dver'
os.environ['DJANGO_SETTINGS_MODULE'] = 'mtv.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

This is in my httpd.conf:

WSGIScriptAlias / /home/dver/tv/mtv/wsgi/django.wsgi
DocumentRoot "/home/dver/tv/mtv/"
Alias /media/ /home/dver/tv/mtv/media/
<Directory /home/dver/tv/mtv/media>
Order deny,allow
Allow from all
</Directory>

<Directory /home/dver/tv/mtv>
Order deny,allow
Allow from all
</Directory>

If anyone can help me I'll really appreciate it.

Thanks!

A: 

There are three potential problems that I notice.

The first depends on the OS you're running — are you sure the user you should add to the groups is called apache and not www-data?

The second is that you have your wsgi script under the directory wsgi but you have no httpd.conf Directory definition for it. I would add that and try again.

The third is that your /home/dver egg directory might have the wrong permissions.

lemonad
+2  A: 

As the code will run as the Apache user, all directories from the root of the file system down to '/home/dver/tv/mtv/wsgi' must be readable/executable to others, or at least somehow the Apache user, not just your Django site directory.

Thus, if '/home/dver' has permissions 'rwxr-x---' then it will not work. This is the most common problem where people go and stick the WSGI script file under their own home account. Manipulating groups may work, but you don't indicate if that group ownership also applies to '/home/dver'.

Although it will not matter as refers to a parent directory, but more secure to have:

<Directory /home/dver/tv/mtv/wsgi>
Order deny,allow
Allow from all
</Directory>

That is, use '/home/dver/tv/mtv/wsgi' rather than '/home/dver/tv/mtv'.

One other possibility is that you have SELinux extensions enabled for operating systems. You should configure SELinux correctly if it is, or possibly disable it just to see if it then works.

Graham Dumpleton