I have created a virtualHost setup according to this website: https://ourcodeworld.com/articles/read/302/how-to-setup-a-virtual-host-locally-with-xampp-in-ubuntu

This part of the setup apparently works. However, I want to have the project folder in another location than htdocs so that the work gets backed up automatically to the cloud with my other documents.

The VirtualHost file looks like this:

    DocumentRoot "/home/dave/Dropbox/Documents/Projects/MyApp"
    ServerName lcover.local
    DirectoryIndex index.html

    <Directory "/home/dave/Dropbox/Documents/Projects/MyApp">
        Options All
        AllowOverride All
        Require all granted
    ErrorLog "logs/lcover.local-error_log"
    CustomLog "logs/lcover.local-access_log" common

When I go to http://lcover.local, I get the 403 error.

I am pretty sure that this is an owner / permissions problem and I have tried several combinations but cannot get it to work.

How should I set the permissions for the directory & files?

  • Hello, change <VirtualHost> to <VirtualHost *:80>, modify the relevant line in /etc/hosts in a way as this: localhost.localdomain localhost lcover.local, restart Apache2 and then try to access https://lcover.local (from the same machine). The other things look good. – pa4080 Jun 27 at 14:19
  • Thanks for the answer but it didn't help I'm afraid. I'm still getting the 403. I don't actually see how this answer could have helped as it didn't actually address any of the permission problems. Perhaps I am missing something in your idea? – Craig Morgan Jun 27 at 20:43
  • Hello again. The above is a comment not an answer :) Within the default permissions the Apache's user (www-data within the native Apache2 installation, maybe httpd in your case) should have readable access to the files in your home directories and in this case you should tweak only the Apache's configuration. However, maybe in your some permissions are changed. In order to help you I've wrote the answer below. – pa4080 Jun 27 at 22:29

In order to have readable access to the files the user (any user) must have also read-execute permissions to the whole path of parent directories. The typical/default permissions of the user's home directories and the files inside are:

  • drwxr-xr-x (or 755 in octal) for the directories and
  • -rw-r--r-- (or 644) for the files.

That means all other users (the third trinity, or the third bit in octal) have readable access to the home directory (and the regular files inside) of each user.

Within these circumstances, let's assume the Apache's user, which is not owner of the discussed items, but is a member of the other users (of course), can't read files from the directory ~/Dropbox/Documents/Projects/MyApp and we want to change that - the steps are:

# Grant to `other` users read-execute permissions for the path
chmod o+rx ~/Dropbox ~/Dropbox/Documents ~/Dropbox/Documents/Projects

# For the next levels we can apply the permissions recursively 
find ~/Dropbox/Documents/Projects/MyApp -type d -exec chmod o+rx {} \;
find ~/Dropbox/Documents/Projects/MyApp -type f -exec chmod o+r {} \;
  • Thanks but this still makes no difference. The directories Projects and MyApp now have 755 permissions. The file index.html within myApp has 644. This was actually already the case. Going directly to that file in the browser (lcover.local/index.html) still gives a 403 error. – Craig Morgan Jun 28 at 5:46
  • This answer was correct after all. I managed to create a typo in my virtual hosts file somewhere in between trying to sort all of this out which was not showing up due to my missing a net-apps package. Thanks for your help! – Craig Morgan Jul 1 at 8:03
  • @CraigMorgan, you are welcome! IMO, it is better to try the native LAMP stack instead of XAMPP. XAMPP is good tool for Windows users, but in Ubuntu you can get this and much more in a more convenient way. Thus you could get much help in this community... – pa4080 Jul 1 at 8:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.