Ubuntu access rights - Mod_Python Permission denied

1.1k views Asked by At

I am running Ubuntu with an Apache webserver with Mod_python. The root directory of the web server is /var/www I have a form for uploading files. The uploaded files should be stored in folder /var/www/xy/uploads by a python script. But when I use this script, I receive an error:

Permission denied: '/var/www/xy/uploads/316.jpg'

Here the relevant parts of the code, that should handle the received files:

targetdir_path = "/var/www/xy/uploads"
newid = 316
f = open(os.path.join(targetdir_path,str(newid)+'.jpg'),"w")

I assume, there is a problem with the access rights of the uploads directory. They are set to: drwxr-xr-x

Can anyone explain me, what I need to change? Thanks for the help!

1

There are 1 answers

0
Uku Loskit On BEST ANSWER

Your directory permissions are set for only allowing writing for the owner of the directory. try this:

sudo chown www-data:www-data /var/www/xy/
sudo chmod -R g+rw /var/wwww/xy/uploads

Also, I'd advise against using mod_python as it is deprecated, look into mod_wsgi instead.