By Abdo
I am using virtual host. I created a website. I am uploading images to the specific folder. Te problem I am facing is: 1: Cannot upload. 2: The solution I am doing now, I enter using file zilla. I select the folder then I make the permission 777. I can upload for 5 or 6 photos then It back. I really need help. I need to make it 777 for live. The problem I heard that 777 is problem for a website. Please give me an advice. Thanks
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!
Using a chmod of 777 grants world read, write, and execute, so it’s not exactly secure and I would not recommend keeping those permissions.
With properly setup user and group permissions, you shouldn’t need such open access – generally all files are at least 644 and directories 755. Since you’re using Apache, the files and directories need to be owned by the user that Apache is running as.
In most cases, www-data is the user and group that Apache uses, unless you’ve configured it to use another user or the repository you’re using has done so.
So what you need to check is ownership. You can see what user and group owns a file or directory by using ls -al on a directory.
You’ll see something like:
drwx------ 5 root root 4096 Apr 19 21:20 .
drwxr-xr-x 23 root root 4096 Apr 19 02:05 ..
If you’re seeing root on the third and fourth column in the directory where your files are located, then that’s probably the issue.
You can change ownership permissions using chown which also supports recursion, like chmod.
For example, to change ownership of files in /var/www/html to www-data, we’d use:
chown -R www-data:www-data /var/www/html
SSH to the machine then cd to the directory and run the following.
sudo chmod -R 777 /path/to/dir
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.