Ubuntu – 403 Forbidden Error after copy a project in htdocs

14.04htdocslampxampp

I successfully installed xampp-linux-x64-1.8.3-4 in my ubuntu 14.04. The XAMPP is installed in /opt/lampp.
I get an 403 Forbidden Error message after I copied a HTML project in htdocs Folder.

What I did and tried:

  1. I copied the project by gksudo nautilus /opt/lampp/htdocs
  2. I tried to change the ownership of the /opt/lampp/htdocs/ to me.
  3. I changed the folder's permissions.

Best Answer

About the error

The 403 Forbidden Error means that the web server (httpd daemon) cannot access the public documents (the web pages) that need to be served.

Possible results of what you did:

  1. All actions in 1 done by the root user resulting all files owned by root so the httpd daemon cannot access them.

  2. You now have the ownership of /opt/lampp/htdocs/ and this has the same results as number 1 above.

  3. You did not mentioned how the permissions are set now thus it is unclear what is accessible right now.

Possible solution:

In my server, I host all public documents at /srv/www/ but the solution will be the same.

Give the ownership to the httpd daemon (Apache, Nginx, etc), that is:

sudo chown -R www-data:www-data /opt/lampp/htdocs/

Assuming that the httpd daemon is named www-data and belongs to the www-data group, else you will have to adapt it accordingly.

In general when setting a web server you want the server user to be the owner of what will be served. Note this is not the case with languages such like Python where say a Django based project must not live inside the public directory.