1

I'm trying to deploy my Django(1.10) project on Ubuntu 18.04 with Apache2 using Mode_WSGI

I have set up my project folder inside home as Fetchors directory and add permissions to it as:

total 40
drwxr-xr-x 6 abdul abdul    4096 Feb 10 15:48 .
drwxr-xr-x 5 root  root     4096 Feb 11 04:40 ..
-rw------- 1 abdul abdul    3930 Feb 11 02:14 .bash_history
-rw-r--r-- 1 abdul abdul     220 Apr  4  2018 .bash_logout
-rw-r--r-- 1 abdul abdul    3771 Apr  4  2018 .bashrc
drwx------ 3 abdul abdul    4096 Feb 10 15:37 .cache
drwx------ 3 abdul abdul    4096 Feb 10 15:34 .gnupg
-rw-r--r-- 1 abdul abdul     807 Apr  4  2018 .profile
drwx------ 2 abdul abdul    4096 Feb 10 15:34 .ssh
drwxrwxr-x 9 abdul www-data 4096 Feb 11 06:27 Fetchors

And here are the permissions inside media directory:

total 16
drwxrwxr-x 4 abdul www-data 4096 Feb 10 15:37 .
drwxrwxr-x 9 abdul www-data 4096 Feb 11 06:27 ..
drwxrwxr-x 2 abdul www-data 4096 Feb 10 15:37 driver_image
drwxrwxr-x 2 abdul www-data 4096 Feb 10 15:46 product_image

I'm creating a proudct object which need to save the product image inside product_image folder but it says:

[Errno 13] Permission denied: 'media/product_image'

How can I fix this issue?

Thanks in advance!

Abdul Rehman
  • 5,326
  • 9
  • 77
  • 150
  • Have you given permission to `media` folder in `.conf` file? – DPS Feb 11 '19 at 06:57
  • Possible duplicate of [Django \[Errno 13\] Permission denied: '/var/www/media/animals/user\_uploads'](https://stackoverflow.com/questions/21797372/django-errno-13-permission-denied-var-www-media-animals-user-uploads) – Bhawesh Chandola Feb 11 '19 at 07:42

2 Answers2

2

Give permission to your media folder by running this command in the terminal

sudo chmod -R 777 media

but this is a bad solution follow the advice on this answer https://stackoverflow.com/a/21797786/5301788

Bhawesh Chandola
  • 511
  • 5
  • 19
0

I have solved this issue by changing my MEDIA_ROOT path in settings.py as:

MEDIA_ROOT = os.path.join(BASE_DIR,'media')

Then, it will grab the appropriate permissions of the Project.

Abdul Rehman
  • 5,326
  • 9
  • 77
  • 150