I'm using NLTK with my Django/Apache application, however when loading a page it returns Permission denied: '/var/www/nltk_data' error. I made my user (not root) the owner of /var/www and gave permissions with sudo chmod -R 770 /var/www/. What else can I do to remove this error?
Try sudo chmod -R o+r /var/www/ This will add read permissions to other.
The apache user trying to write to /var/www/nltk_data folder is www-data. So I made this user the owner of nltk_data folder then it worked.
Related
I have created my project in centOS 7 using root.Each time when saving the project after changes its asking the password.How do I change the permissions of the whole project now ?
To make everything writable by anyone run this in directory with your django project:
chmod -R 0777 ./
Are you sure you want to keep it owned by root? I'd suggest to change the owner to whatever services should use the project.
chown -R <some-user> /path/to/project # user may be www-data
chmod -R 755 /path/to/project
I am trying to upload images in django. I have set static directory in settings.py
MEDIA_ROOT = os.path.join(BASE_DIR, '/assets/image/')
MEDIA_URL='http://127.0.0.1:8000/assets/image/'
here is my model image Field
doImage=models.ImageField(upload_to='doImage/%Y/%m/%d',verbose_name='Do Image')
Now when i tried to upload it then i faced permission denied 13 error.
I had tried command chmod with 777 to give a permissions to folder
sudo chmod -R 777 assets
i also had tried change user of file using command
sudo chown -R hassan:hassan assets
But both things didn't worked for me. So anyone have idea that what's going wrong let me know.
Django stores files locally using MEDIA_ROOT and MEDIA_URL. Please refer this doc for more details.
For example you can also check this.
Don't do:
sudo chown -R root:root assets
This way only root user has rights over assets
Do:
sudo chown -R your_user:your_user /path/to/your/assets
I can not add a comment to this post - https://stackoverflow.com/a/21797786/6143954.
So I created a new question.
It was the correct answer before it was edited. In this answer, the line
sudo chmod -R 770 /var/www/
is replaced by
sudo chmod -R 760 /var/www/
Specifically, this solution is not suitable for Django.
The answer should not be changed after it has been marked as the right solution.
That was the correct answer before correcting the original post.
The GOOD solution would be:
sudo groupadd varwwwusers
sudo adduser www-data varwwwusers
sudo chgrp -R varwwwusers /var/www/
sudo chmod -R 770 /var/www/
How correct is this solution?
sudo chmod -R 770 /var/www/ is fine.
This means that owner and group has all rights and others don't have any rights.
This is right way.
If you set 760, group users will get Permission denied on read or write attempts.
For files inside directory you can set them as 760.
i'm typing the following in my working amazon ec2 linux server. (with ENV activated)
pip install pillow
getting this error:
Could not install packages due to an EnvironmentError:
[Errno 13] Permission denied: '/home/ec2-user/env/lib64/python3.5/site-packages/Pillow-5.1.0.dist-info'.
Consider using the `--user` option or check the permissions.
if i use --user i get:
Can not perform a '--user' install. User site-packages are not visible in this virtualenv.
Based on your answers, what happened is that you used sudo when you created the virtualenv so root owns it.
sudo chown ec2-user:ec2-user -R ~ec2-user/env will fix this and make ec2-user the owner of the directory (and subdirectories) again.
When I SSH into my AWS EB instance to run php artisan migrate, I get the following error message:
Link to bigger size of picture below
I am completely confused. First, I don't get this error on the local server. Second, what does a simple log file have to do with migrations anyway? They are ignored by git by default, so no log files are uploaded.
Sigh... Any ideas on how I can be allowed to run my php artisan migrate?
It's always the storage folder. Blank pages or permission denied, it's the darn storage folder.
I don't know how EB works, if it's a regular distro or what, but you should change ownership of the storage folder to the web server (www-data most likely) so it can build the views then set 775 permission so you can write/read logs.
So something like:
sudo chown -R www-data:www-data storage/
sudo chmod -R 775 storage/
I've gone through the same error
As stated here,
AWS AMI uses webapp as the web user, not apache or ec2-user as the
file shows. In that case, the webapp user has no access rights over
those files.
So, going through the steps mentioned in there fixed the problem
sudo chown $USER:webapp ./storage -R
find ./storage -type d -exec chmod 775 {} \;
find ./storage -type f -exec chmod 664 {} \;
Depending on what you're aiming to do afterwards you might need to go through this too.