You don't have permission to access / on this server. error for html app on apache server
No, you should not install anything more, but you should change the owner of the content to www-data
, which is the user that runs apache. Consider for instance the folder js
, where the owner (root
) have full access, but all other users (including www-data
which runs the webserver) have no access.
The letters drwx------
:
First character is special, d means directory. Then there is groups of three. The three first in this case rwx
indicates that the file owner has Read, Write and eXecute permissions. The rest is - indicating no access.
If it had been drwxr-xr--
it would have indicated that owner had all permissions, group (e.g. members of the group that owns the file) would have read and execute, but not write, and others would have read.
To be able to serv a file the webserver needs read permission on the file, and in addition execute permission on all directories in the path leading to the file.
To change ownership to www-data, run the command
sudo chown -R www-data.www-data /var/www/html
This is makes www-data the owner of the files, and your webserver will be able to serve the files.
hristof kuallamp
Updated on September 18, 2022Comments
-
hristof kuallamp over 1 year
root@ubuntu-512mb: /var/www/html# ls about.html fonts images self-image.html whatnow.html audio frozenyogurtshop.iml index.html singlepost.html css frozenyogurtshop.psd js whatidid.html
this is my project from localhost. i only installed apache and put my project there.
i searched some and i got those
root@ubuntu-512mb:/var/www/html# grep DocumentRoot /etc/apache2/sites-enabled/000-default.conf DocumentRoot /var/www/html
so i put to true place.
those are permissions
root@ubuntu-512mb:/var/www/html# ls -al /var/www/html total 50920 drwx------ 8 root root 4096 Dec 24 01:04 . drwxr-xr-x 3 root root 4096 Dec 24 00:35 .. -rw-r--r-- 1 root root 2380 Dec 23 23:05 about.html drwxr-xr-x 2 root root 4096 Dec 23 23:11 audio drwx------ 2 root root 4096 Dec 23 22:20 css drwx------ 2 root root 4096 Nov 21 2015 fonts -rw-r--r-- 1 root root 335 Dec 23 20:25 frozenyogurtshop.iml -rw-r--r-- 1 root root 52076522 Nov 21 2015 frozenyogurtshop.psd drwxr-xr-x 2 root root 4096 Dec 24 00:06 .idea drwx------ 3 root root 4096 Dec 23 21:37 images -rw-r--r-- 1 root root 6920 Dec 23 23:00 index.html drwx------ 2 root root 4096 Nov 21 2015 js -rw-r--r-- 1 root root 2295 Dec 23 23:14 self-image.html -rw-r--r-- 1 root root 2992 Dec 23 22:37 singlepost.html -rw-r--r-- 1 root root 2111 Dec 23 23:10 whatidid.html -rw-r--r-- 1 root root 2758 Dec 23 23:12 whatnow.html
at first it was working for indexhtml but then i deleted.
should i install another thing?
-
hristof kuallamp over 6 yearsok thank you.i did not hav e sudo user so first i created auser and than thosehttps://askubuntu.com/questions/46331/how-to-avoid-using-sudo-when-working-in-var-www
-
vidarlo over 6 yearssudo is not an user, it's a command got running other commands as root. But yes, that answer should work just fine:)