I'm setting up my local development host and this time I do not want to edit files with sudo as I used to do before, but after installing the Apache virtual host, I'm facing problems with permissions.
My setup is /var/www/html/site1/public_html
I followed this forum post to organize the whole thing, but now I can't edit files on /var/www/html/site/public_html/ and neither access the folders using the terminal.
The commands I ran:
fabio@fabio-thinkpad:~$ sudo chgrp -R www-data /var/www/html
[sudo] password for fabio:
fabio@fabio-thinkpad:~$ sudo find /var/www/html -type d -exec chmod g+rx {} +
fabio@fabio-thinkpad:~$ sudo find /var/www/html -type f -exec chmod g+r {} +
fabio@fabio-thinkpad:~$ sudo chown -R fabio /var/www/html/
fabio@fabio-thinkpad:~$
fabio@fabio-thinkpad:~$ sudo find /var/www/html -type d -exec chmod u+rwx {} +
fabio@fabio-thinkpad:~$ sudo find /var/www/html -type f -exec chmod u+rw {} +
fabio@fabio-thinkpad:~$ sudo find /var/www/html -type d -exec chmod g+s {} +
fabio@fabio-thinkpad:~$ cd /var/www/html
bash: cd: /var/www/html: Permission deniedI also can't save files from the code editor.
Any ideas?
Edit:
fabio@fabio-thinkpad:/$ ls -ld /var/www
drwxrwxr-- 3 www-data www-data 4096 Apr 23 17:30 /var/www
fabio@fabio-thinkpad:/$ groups fabio
fabio : fabio adm cdrom sudo dip www-data plugdev lpadmin sambashare 3 1 Answer
The document root which in your case is /var/www/html should be owned by root.
You will want to edit files inside as root so you don't need to change any of the permissions. It's not supposed to be writable by anyone except root.
To get things back to the way that they are after installing apache:
chown -R root:root /var/www
chmod -R 755 /var/wwwThat will make root the owner of /var/www/html and everything inside and set the permissions so that only root can write to it. With that, you can become root whenever you need to work inside of that directory and you won't have to keep track of the permissions inside.
Also, in the future, be sure to add any information requested in the comments to your question so that they don't lost in the comments if multiple people post them.
9