Apache – You don’t have permissions

Apache – You don’t have permission to access the requested directory.

If you get this error after creating a new virtual site on Apache2:

"You don't have permission to access the requested directory"

This is probably because a Deny from all or theĀ  no existence of the Allow from all directive.

Suppose you have a <VirtualHost> configuration as below:

<VirtualHost *:80>
    ServerAdmin admin@example.com
    DocumentRoot /srv/www/htdocs/example.com/
    ServerName www.example.com
    ServerAlias example.com *.example.com
    ErrorLog /var/log/apache2/example-error.log
    CustomLog /var/log/apache2/example-access.log combined
 </VirtualHost>

You need to have something like this inside <VirtualHost> tags.

<Directory /srv/www/htdocs/example.com/>
Options +FollowSymLinks Indexes
AllowOverride All
order allow,deny
allow from all
</Directory>

So the whole configuration should look like this:

<VirtualHost *:80>
    ServerAdmin admin@example.com
    DocumentRoot /srv/www/htdocs/example.com/
    ServerName www.example.com
    ServerAlias example.com *.example.com
    ErrorLog /var/log/apache2/example-error.log
    CustomLog /var/log/apache2/example-access.log combined

   <Directory /srv/www/htdocs/example.com/>
      Options +FollowSymLinks Indexes
      AllowOverride All
      order allow,deny
      allow from all
      </Directory>
 </VirtualHost>

I hope this information has been helpful.
I.T. Tone

Leave a Reply

Your email address will not be published.Email address is required.