You most likely came here because you got Apache error AH01630. 🙂

This is a quick tip for developers. Lets say you are using xampp. Lets say that you installed it in /opt/lampp. Let us now assume you want the VirtualHost directory root to be placed out of /opt/lampp/htdocs.
Let us also assume for example purposes, that the chosen folder is a sub-directory in your user directory. For example: /home/pargo/projects/example1.
So what we have is:

<VirtualHost *:80>
    DocumentRoot "/home/pargo/projects/example1/public_html"
    ServerName example.com
    ErrorLog "/home/pargo/projects/example1/error.log"
    CustomLog "/home/pargo/projects/example1/access.log" common
</VirtualHost>

Once you test the configuration (which is correct) and restart Apache, you will get the following error when opening example.com in the browser:

[authz_core:error] AH01630: client denied by server configuration: (/home/pargo/projects/example1/public_html)

On the internet you might find a plethora of “solutions” for this problem. Some of them suggest to change the ownership of the project directory to the user and/or group under which Apache is running (in xampp case that would be daemon/daemon). Some even suggest to change access permissions of the project dir to 777.
DO NOT DO ANY OF THESE THINGS!

All you need to do is the following two step solution:

  1. Instead of changing the project directory owner, change the user and group under which Apache is running to the owner of the directory. In our case that would be your own user.
    So open up /opt/lampp/etc/httpd.conf and change the User and Group variables found in <IfModule unixd_module>.
  2. There is one more step you will need to do. Once you change the running user/group and restart Apache, the web server will throw the following error upon visiting example.com:
    (13)Permission denied: AH00035: access to / denied (filesystem path '/home/pargo/projects/example1.com/public_html') because search permissions are missing on a component of the path

    To fix this simply open your /opt/lampp/etc/extra/httpd-vhosts.conf and “Require all granted” in a <Directory> section of the desired virtual host.
    Your final virtual host should look somewhat like this:

    <VirtualHost *:80>
        DocumentRoot "/home/pargo/projects/example1/public_html"
        ServerName example.com
        ErrorLog "/home/pargo/projects/example1/error.log"
        CustomLog "/home/pargo/projects/example1/access.log" common
          <Directory "/home/pargo/projects/example1/public_html">
              Require all granted
          </Directory>
    </VirtualHost>

parg0

Gjoko Pargo

0 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.