Main problem
When user uploads image to the rest admin portal, permission error is thrown. The backend model is a simple one with only ImageField and TextField.
My setup
Ubuntu 16.04 LTS
Python 3.6
Apache2 with mod_wgsi compiled for python3.6
The upload destination is owned by my account and wwwdatagroup(I created this group for www-data and grant 760 on the upload destination)
Here is the output of ls -l This folder is under my home directory, the image is uploaded to a subfolder of media folder.
drwxrw---- 3 MYUSERNAME wwwdatagroup 4096 Jul 30 17:48 media
This was set by chmod -R 760 media I suppose this will set the permission recursively.
Question
My wsgi process has no specific user set, so it should run under the user which apache is running on. In my case www-data. As shown above, obviously this folder and all is subfolders can be read, written(rw) by wwwdatagroup which contains www-data. So WHY PERMISSION DENIED?
Help...
I am staring at the error page and crying. Real tears.
I solved this problem by setting 770 for wwwdatagroup on the media folder. My guess is that Django is doing some listing(require x permission) or trying to mkdir(this requires x too? I don't know).
I will keep this question open and will give the accepted answer to person who explains this well. Thanks!
Related
I am using SQLite3, Ubuntu server. I have checked the read and write permissions of the database file. It is:
-rw-r--r--
Doesn't this mean that the file has read and write access? So why is Django error saying attempt to write a readonly database?
Thanks in advance!
I configured with el user and group that inside of httpd.conf (/opt/lampp/etc/)
of following code :
user#server:/opt/lampp$ sudo chown --recursive daemon:daemon htdocs/website/
user#server:/opt/lampp$ sudo ./lampp restart
//PD : the name user daemon is in the archive httpd.conf
While Submitting a form having media input its showing
[Errno 13] Permission denied: '/home/ubuntu/django/media/pictures'
I have searched in google but no one told giving permissions for media files , they ever all telling about static files only . Can any one please tell me which permission i have to give to it with chmod no.
You're having permissions issues. To fix it, you need to allow the Apache process access to the folder and it's content.
This can be done through the following steps
Change the permissions to read and write
chmod 664 /home/ubuntu/django/media/pictures -R
Give the group Apache runs under (www-data group) group ownership of the folder and its content
sudo chown -R :www-data ~/home/ubuntu/django/media/pictures
Restart the Apache service
sudo service apache2 restart
If you want to ensure Django behaves as it should, you can also add the following to your settings.py
FILE_UPLOAD_DIRECTORY_PERMISSIONS = 0o755
FILE_UPLOAD_PERMISSIONS = 0o644
I have created a Laravel project in laravel 5.4 and i have made it live using AWS server . Now the issue I face is I have to provide the 777 permission to storage folder very frequently and due to this the site is not working properly. Can anyone help me with this as what can be the issue ? I have already given 777 permission to storage folder but somehow the permission changes and site stops as it cannot write log in log file. Thanks in advance
Ideally giving 777 permissions means who have open the access to ANYONE in the world who can access your storage with all Read/Write permissions.
You need to assign permission to your Web server to access the Directories and files which you can do in following way:
www-XXX can be your webserver user
sudo chown -R www-xxx:www-xxx /path/to/your/laravel/root/directory
Now in order to grant the storage level permissions to your webserver you need to execute the below commands
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
I'm trying to upload a google webmaster file to aws root folder with Filezilla. I'm getting the following error
and my root folder permission is set to 755. But still i'm getting file permission error.
You are not authorized to access this directory. Ask your administrator/Root user to run this command.
sudo chown -R USER_NAME:USER_NAME FOLDER_PATH
USER_NAME: Your username
FOLDER_PATH: Folder path
I have also faced the same issue earlier so I sorted it like this.
I've tried everything that i've found regarding this problem, but nothing helped me to solve this issue.
When i try to upload something on my web site i get this error:
OSError: [Errno 13] Permission denied: '/home/****/www/site.com/media/news/some_file.pdf'
ls -l media gives me next:
drwxrwxr-x 2 www-data www-data 4096 Oct 11 23:13 news
so permissions are OK.
Everything was working well with development server but now in production i just cant upload anything.
How to fix this?
As a noob for linux/apache I didn't know that default user for apache in CentOS (that i'm running on my server) is apache and not www-data.
So chown -R apache:apache media did the trick.
In last few days i've searched a bunch of topics regarding this problem and none of them did mention that there's other default user but www-data. It looks like that most of users are runing Ubuntu as everyone is talking about www-data.