Question

403 You don't have permission to access xxxx on this server. (sudo chown www-data:www-data -R /var/www)

Hello,

I’m new using DigitalOcean

I created a Droplets with Ubuntu 14.04, I followed the instructions in the Initial Server Setup, create a new user, change the SSH port, etc., I followed the tutorial for LAMP Stack on Ubuntu 14.04, I have installed Apache2, MySQL, PHP, Secure phpMyAdmin installation, configure the host to run through a domain (Setup Host Name), install WordPress; Postfix, ProFTPd for file transfer over SSH (sftp).

When I was installing a Wordpress theme, I requested for details SSH keys, searching Google I found that assigning changing the public_html owner from my user to www-data, wordpress works fine! sudo chown www-data:www-data -R /var/www/html, the theme was installed without problems, I work several days without errors, until I tried the sftp via ssh.

Using the sftp I had access to my user’s folder but when I went to /var/www/html, there is not files or cannot see them, I realized that changing the permissions to www -data, my user did not have access to them, so I change the owner of the files to my new user, not root, I assign the chown to the new user created in the initial server setup. The page began to launch a 403 Forbidden.

I put back chown to www-data on folder /var/www/ and now I see the index.php (Default page) but can’t navigate or see any post or subfolder, the server say: 403 " You do not have permission to access on this server xxxx."

Any help?

Show comments

Submit an answer

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!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

While I don’t know all of the details, it sounds like not all of your files are owned by www-data. One way to make sure is to run “chown -R www-data /var/www”. The -R makes the command recursive, so it’ll ensure that every file and subdirectory are also owned by www-data. <br> <br>This is a symptom of a larger problem - one of the first problems I encountered in server management - how do you allow Apache to access the files while still being able to create / modify / transfer files using your normal user account? I’m no expert, but you might look into using user groups to solve the issue. <br> <br>All of my public web files in /var/www belong to the www-data group (chgrp -R www-data /var/www) which allows Apache to access the files if permissions are set correctly, regardless of who owns the files. <br> <br>This is only one possible approach; there are several.

Thank you accounts! <br> <br>stuffexchange, I follow the link, this solve my problems! <br> <br> <br>