[3 Basic Solutions] ‘Apache’s Forbidden Error on your Domain’
Apache is a web server software that is used by almost 67% of all the webservers in the world. This software is developed and distributed by Apache Software Distribution. It is open-source and available for free. Apache is fast, secure and reliable which is one of the reasons for its popularity. However, quite recently a lot of users have been experiencing the “Forbidden – You Don’t Have Permission To Access / on this Server” Error while trying to set up Apache for their domain.
What Causes the “Forbidden – You Don’t Have Permission To Access / on this Server” Error?
After receiving numerous reports from multiple users, we decided to investigate the issue and devised a set of solutions to fix it completely. Also, we looked into the reasons due to which it is triggered and listed them as follows.
- Incorrect Global Directory Settings: It is possible that the settings for the Global Directory haven’t been configured properly which isn’t allowing enough directive to the site. If the site does not have a correct directive it might trigger this error.
- Incorrect Permissions: Apache requires permissions up to the root folder of the directory in order to function correctly, if these permissions aren’t granted the error might be triggered.
- No Username: In the “httpd.conf” the actual username of the user has to be entered in some cases to get rid of the error. This works for some people while for some it doesn’t.
Now that you have a basic understanding of the nature of the problem, we will move on towards the solutions. Make sure to implement these in the specific order in which they are presented.
Solution 1: Changing Global Directory Settings
Certain Settings need to be configured properly in order to fix this issue. Therefore, in this step, we will be adding the Options Directive in the Global Directory Settings which is located in the “httpd.conf” or the “httpd–vhosts.conf” depending upon the user. For that:
- Once you are in the “httpd.conf” or the “httpd-vhosts.conf”, look for the directory settings, they should be similar to the below-mentioned code.
<Directory /> Options FollowSymLinks AllowOverride All Order deny,allow Allow from all </Directory>
Note: It is possible that the code has “Deny From All” in place of “Allow From All“. It is important that you modify it to “Allow From All” or “Require All Granted” as indicated below.
- Make sure you add the “Options Indexes FollowSymLinks Includes ExecCGI” line to it in such a way that it looks similar to the following code.
<Directory /> #Options FollowSymLinks Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Order deny,allow Allow from all </Directory>
- Check to see if the issue persists.
- If the problem isn’t solved modify the code by removing “Allow from All” to “Require All Granted“.
- Check to see if the issue persists
Solution 2: Changing Permissions
When the user is linking Apache to their domain they provide permissions to the software to be able to read and write the files. It is important that these permissions are provided properly. Below we will indicate the proper way of providing permissions.
- Conventionally, users provide permissions in the following way.
chgrp -R www-data /username/home/Dropbox/myamazingsite/ chmod -R 2750 /username/home/Dropbox/myamazingsite/
- These commands are wrong and need to be replaced with
chgrp -R www-data /username chmod -R 2750 /username
- Also, keep in mind that you are using the correct level of “chmod“, use one that provides read permissions to users such as the “chmod 755“.
- Check to see if the issue persists after trying the suggestions.
Solution 3: Adding Username
In the “httpd.conf“, make sure to add your exact username instead of the words “User” or “Group”. In some cases, adding the user name fixes the issue.