David Daniel
David Daniel

Reputation: 535

Pinax (13, 'Permission denied')

I'm a noob but I made my application work beautifully using python manage.py runserver but when I brought it to Apache + mod_wsgi, I keep getting this error. The debug messages aren't much help. Here is a screenshot of the entire debug image: http://img694.imageshack.us/img694/6723/screenshotfb.png

Here is the dump of my http.conf file.

WWSGIDaemonProcess cloud-tester python-path=/home/ubuntu/.virtualenvs/pinax-env/lib/python2.6/site-packages
WSGIProcessGroup cloud-tester

WSGIScriptAlias /cloudrunner /home/ubuntu/projects/cloudfly/deploy/pinax.wsgi
<Directory /home/ubuntu/projects/cloudfly/deploy>
    Order deny,allow
    Allow from all
</Directory>

The contents of pinax.wsgi is what comes with Pinax. I didn't change anything.

I created a sample "basic_project", and that works fine. This doesn't.

Thanks in advance! Any advice on what I should do?

Upvotes: 0

Views: 477

Answers (2)

Plahcinski
Plahcinski

Reputation: 335

You are logging in as root when you use 'python manage.py runserver' which is why it is allowed to write to that director but when apache launches your wsgi script it will be under its user name which isnt allowed to write in the directory you have your python scripts in.

Assuming you are using ubuntu server, i had the same issue. I fixed it using

chown www-data:www-data -R media

I keep all my py scripts in /var/pyproj/. The media folder would be in /var/pyproj//pysrc(my pinax install director)/site_media/

I keep my wsgi script, nginx conf and vhost.conf in /var/pyproj//server.

Best of luck fellow django user. I hope this helps.

Upvotes: 0

Graham Dumpleton
Graham Dumpleton

Reputation: 58563

Under Apache/mod_wsgi your code will run as Apache user and will not usually have access rights to write to directories that you as a user has. Read:

http://code.google.com/p/modwsgi/wiki/ApplicationIssues#Access_Rights_Of_Apache_User

The easiest way around that is run make the daemon process run as same user as you manually run the code. Use the 'user/group' options to WSGIDaemonProcess for this purpose. Read:

http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIDaemonProcess

A further problem may be that you have used relative pathnames in your code. This will not work under Apache as the current working directory could be anything. You should really always use absolute path names, or at least calculate them relative to os.path.dirname() of __file__ for the code file it is being done in.

A way around this if you really don't want to deal with it, is to use the 'home' option to WSGIDaemonProcess to set current working directory of daemon process to same directory where you are running server by hand. See same documentation for WSGIDaemonProcess referenced above.

Upvotes: 4

Related Questions