I've deployed my web on Digital Ocean VPS - Ubuntu 14.04. I have a ImageField
in one of my models which I choose in Django admin (browse pc and upload the image). The problem is that this image can't be saved into /media/categories/
. It's raising:
[Errno 13] Permission denied: '/home/django/project/media/categories/television_d3q3EM0.png'
I thought that it is, because Nginx hasn't write privileges to /media/
directory so I run these commands:
sudo chown -R www-data /media/
which didn't help
sudo chown -R django /media/
which didn't help neither
I'm a newbie in Linux rights so I can't figure out what am I doing wrong.
Media folder is in /project/
directory (where the manage.py
is).
Here are permissions of the /media/
folder.
Owner has rights so I don't know why sudo chown -R www-data /media/
didn't work.
GUNICORN OWNER
ps aux | grep gunicorn
django 16636 0.3 2.7 66040 13616 ? Ss 08:16 0:00 /usr/bin/python /usr/bin/gunicorn --name=project --pythonpath=project --bind=127.0.0.1:9000 --config /etc/gunicorn.d/gunicorn.py project.wsgi:application
django 16642 1.1 7.8 174800 39164 ? S 08:16 0:00 /usr/bin/python /usr/bin/gunicorn --name=project --pythonpath=project --bind=127.0.0.1:9000 --config /etc/gunicorn.d/gunicorn.py project.wsgi:application
django 16643 1.9 10.5 214244 52808 ? S 08:16 0:01 /usr/bin/python /usr/bin/gunicorn --name=project --pythonpath=project --bind=127.0.0.1:9000 --config /etc/gunicorn.d/gunicorn.py project.wsgi:application
django 16644 2.3 10.4 209232 52224 ? S 08:16 0:01 /usr/bin/python /usr/bin/gunicorn --name=project --pythonpath=project --bind=127.0.0.1:9000 --config /etc/gunicorn.d/gunicorn.py project.wsgi:application
root 16667 0.0 0.1 11744 932 pts/0 S+ 08:17 0:00 grep --color=auto gunicorn
755
not311
. – themanatufsudo chown -R yourusername:www-data /home/django/project/media
– Aaron