By margalimited
Hi For my photos to be uploaded to my drupal website and to show on the web pages
I have to change all my file and image folders to 777 permission which seems a bit of a security risk
Any suggestions?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
I think this should be fine as they are static content.
Just make sure that you don’t give permission to modify your PHP files, They should all have read-only access by the web server.
Also you can add some security rules in the htaccess files to disallow malicious code in those folders which have 777. Allow files only with specific extensions.
I wholeheartedly disagree with @freelancer . There is never a time where you need 777.
For ubuntu/Debian, run this (changing the value for web_folder if it’s not right):
web_folder='/var/www/html/'
chown www-data:www-data $web_folder -R; find $web_folder -type f -print0 |xargs -0 chmod 644; find $web_folder -type d -print0 |xargs -0 chmod 755;
For Fedora/CentOS (Again, change the value for web_folder if it’s not right):
web_folder='/var/www/html/'
chown apache:apache $web_folder -R; find $web_folder -type f -print0 |xargs -0 chmod 644; find $web_folder -type d -print0 |xargs -0 chmod 755;
The simple rule is you only give permissions that you need. Never more. Any good admin will say the same thing.
EDIT: here’s what the script does:
Can I do it the same way as wordpress?
sudo chown -R www-data:www-data ~/wordpress/
i.e
sudo chown -R www-data:www-data ~/sites/defaults/files/images
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.