Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Environment Details:

Amazon Ec2 Ubuntu 12.04
Django + mod_wsgi + python 2.6
web server: apache2

I have mounted a 10GB ebs volume to an instance to /mnt/ebs1/. After mounting the volume and formatting, I have placed all my project files in /mnt/ebs1/project. the wsgi file is in /mnt/ebs1/project/apache/django.wsgi. The content of wsgi file is:

import os, sys

sys.path.insert(0, '/mnt/ebs1/project')
sys.path.insert(1, '/mnt/ebs1')

os.environ['DJANGO_SETTINGS_MODULE'] = 'project.configs.common.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

My httpd.conf file looks as:

LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so
WSGIPythonHome /usr/bin/python2.6

WSGIScriptAlias / /mnt/ebs1/project/apache/django.wsgi

<Directory /mnt/ebs1/project>
Order allow,deny
Allow from all
</Directory>

<Directory /mnt/ebs1/project/apache>
Order allow,deny
Allow from all
</Directory>

Alias /static/ /mnt/ebs1/project/static/
<Directory /mnt/ebs1/project/static>
Order deny,allow
Allow from all
</Directory>

The above configurations gives me Forbidden: You don't have permission to access / on this server.

I tried to find the user which is running apache using ps aux which is www-data and has group www-data. I have tried to change the ownership of /mnt/ebs1 and its subdirectories using chown -R www-data:www-data /mnt/ebs1 but that still does not solve the problem. Can any one tell me what I am doing wrong or have missed?

share|improve this question

2 Answers 2

To troubleshoot, please try modifying the following directive:

WSGIScriptAlias / /mnt/ebs1/project/apache/django.wsgi

to something like this:

WSGIScriptAlias /test /mnt/ebs1/project/apache/django.wsgi

See if this produces functionality when you attempt to access http://yoururl.com/test.

share|improve this answer
    
I did and restarted the server it says The requested URL /test was not found on this server. I found in this Terminating Python. 'import site' failed; use -v for traceback in the error log also, may be that will give some hint?? –  Aamir Adnan Oct 23 '12 at 18:36
    
Comment out 'WSGIPythonHome /usr/bin/python2.6', it is wrong. If mod_wsgi was compiled for version 2.6 of Python it should work without needing to set WSGIPythonHome. Even when setting WSGIPythonHome, you don't set it to the Python binary. If your mod_wsgi was not compiled for 2.6, you will need to recompile mod_wsgi against 2.6. This will possibly get rid of import issue, but not the permission issue. –  Graham Dumpleton Oct 23 '12 at 20:46

The error message:

Forbidden: You don't have permission to access / on this server

is what you would see in the browser. You need to go look at the Apache error log to see the error message there added at same time, because there can be two different messages output corresponding to that and they mean different things.

Go find the message and add it to your question.

The different possibilities for the error are, Apache access controls, file system access controls and SELinux being enabled and prohibiting access to mounted volume.

Also go watch:

http://lanyrd.com/2010/pycon-au/szgqq/

as it goes through the permissions issue, showing the different messages in the log for that browser message.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.