1

I get this error when i try to upload an image:

OSError at /upload/

[Errno 13] Permission denied: '/var/www/p/p/media/imgupload/img.png'

my virtualhost:

<VirtualHost *:80>
    ServerAdmin myemail@gmail.com
    ServerName p.com
    ServerAlias www.p.com
    DocumentRoot /var/www/p/
    LogLevel warn
    WSGIDaemonProcess processes=2 maximum-requests=500 threads=1
    WSGIProcessGroup %{GLOBAL}
    WSGIScriptAlias / /var/www/p/p/wsgi.py
    Alias /media /var/www/p/p/media/
    Alias /static /var/www/p/p/static/
</VirtualHost>

Here is the sec for the files:

drwxr-xr-x 3 ubuntu root     4096 Jun 16 13:10 www
drwxr-xr-x 4 ubuntu ubuntu 4096 Jun 16 13:10 p
(all other folders are ubuntu ubuntu)

while i got this:

drwxr-xr-x 36 ubuntu root     4096 Jun 11 06:33 lib
drwx------ 6 mysql  mysql   4096 Jun 17 14:19 mysql

I can't cd through mysql with my ubuntu user... Is it some security issue??

Must be...

Thanks in advance

Tony
  • 2,382
  • 7
  • 32
  • 51
  • This has nothing at all to do with mysql. – Daniel Roseman Jun 17 '12 at 15:44
  • 1
    I don't know what more to tell you. mysql is a database. This clearly has nothing to do with databases: at no point is a database involved in writing a file to disk, and you haven't shown any code that would hint that a db is to blame. – Daniel Roseman Jun 17 '12 at 15:51

1 Answers1

3

This is a simple fix. Your django process is probably not running under the same user as the owner of the media location. Either check your config for how you have django set up through apache and make sure the owner of the media dir matches, or just open up permissions more to get it working:

chmod -R a+w /var/www/p/p/media

Or

chown -R right-user /var/www/p/p/media
david.barkhuizen
  • 5,239
  • 4
  • 36
  • 38
jdi
  • 90,542
  • 19
  • 167
  • 203
  • Did you delete the existing contents or make sure that any existing sub directories also have opened write perms? – jdi Jun 17 '12 at 16:34