I made mistake - sudo chown /var/www/html/htaccess.txt www-data:www-data
5,460
Solution 1
The 2 commands ABOVE the one you quoted in the questions messed your system up.
These 2 fix permissions for directories and files:
sudo find /var/www/html -type d -exec chmod 755 {} \;
sudo find /var/www/html -type f -exec chmod 644 {} \;
Your
sudo chmod 644 /var/www/html
removed execute permissions for your directories.
Solution 2
You need to reset the permissions on /var/www/html
back to 0755
:
sudo chmod 755 /var/www/html
Explanation: the execute bit in file permissions (x
) determines whether the contents of the directory can be enumerated. Turning this bit off (0644
) will prevent the web server from being able to see what is in the directory.
Related videos on Youtube
Author by
Igor_77
Updated on September 18, 2022Comments
-
Igor_77 almost 2 years
I made mistake when use Chown command. I write
sudo chown /var/www/html/htaccess.txt www-data:www-data
insted of
sudo chown www-data:www-data /var/www/html/htaccess.txt
The answer was -
So - All my stuff from /var/www/html disappeared, and my site
Forbidden You don't have permission to access / on this server. Apache/2.4.7 (Ubuntu) Server at www.a-r-c-h.net Port 80
-
Igor_77 over 7 yearsPLEASE - HELP!! How can I return it back?
-
Rinzwind over 7 yearsyour 1st command cant have done anything... there is not a file "www-data:www-data" so nothing got changed... please add results from
ls -l
for/var/www/html/
edit: looked at the image now :D see! it shows an error so that did -nothing- -
Nathan Osman over 7 years
/var/www/html/htaccess.txt
isn't a valid user either (as the error message states).
-
-
Igor_77 over 7 yearsThaks!!!!! It helps me! :))
-
Igor_77 over 7 yearsBut why it works so, that that command change rights but not the owner?
-
Rinzwind over 7 yearsthese 2 only change permissions to the files; not the owner; not the group.
-
Igor_77 over 7 yearsI got it! I thought the problem was in sudo chown, but it was in sudo chmod 644 for folder, but not the file, thats why all files in Html disappeared. I made mistake - should be 755 for folders and 644 for files!