You don’t have permission to access http://localhost files or folders on this server in Ubuntu (Linux)

If you are getting the following error while browsing any local website in Ubuntu like:

You don’t have permission to access http://localhost on this server files or folders

then you may not be having the full rights to access that folder or file(s). On the other end, you may be accessing the folders and files through the File Browser (while using gnome-terminal command sudo nautilus etc), but while browsing them through any web browser like Firefox etc., you may be getting the permissions error as mentioned:

403 Forbidden

You don’t have permission to access http://localhost on this server (or any of localhost’s subdirectory)

Apache/2.2.11 (Ubuntu) PHP/5.2.6-3ubuntu4.5 with Suhosin-Patch Server at localhost Port 80
etc.

For the solution, simply do the following method to grant yourself and all of the users, including admin, groups and other users, the read, write and execute rights, to stop getting such errors:

Goto Applications -> Accessories -> Terminal

and write the following code:

chmod a+rwx foldername or filename

with full path, for example:

Granting Rights on Folder:

If you are getting such error on the directory:
/var/www/webtechquery/

then the command should be:

chmod a+rwx /var/www/webtechquery/
or
chmod a+rwx /var/www/webtechquery/*

Granting Rights on File:

If you want to grant full rights on files e.g. abc.php, then the command should be:

chmod a+rwx /var/www/webtechquery/abc.php

If you want the rights to be granted to only the owner, group or specific user(s), then use the following commands:

For Owner:

chmod o+rwx /var/www/webtechquery/abc.php

For Group:

chmod g+rwx /var/www/webtechquery/abc.php

For User:

chmod u+rwx /var/www/webtechquery/abc.php

where:

o = owner
u = user
g = group

and

r = read
w = write
x = execute

Uncategorised

Leave a Reply

Your email address will not be published. Required fields are marked *