Forbidden you don't have permission to access ... on centos 7


Incase you receive "Forbidden you don't have permission to access" message while setting up the virtual host on the new machine - you can take following steps:


1. Back up httpd.conf and open it using vim or nano:

#Take backup of httpd.conf before modifying
→ cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.bak.conf

#Open the httpd.conf on vim or nano
→ sudo vim /etc/httpd/conf/httpd.conf

2. On httpd.conf make following changes:

<Directory />
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Require all granted
</Directory>
<Directory "/var/www/html">
   Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

3. If it is still not working, you can disable SELinux by running following command:

selinuxenabled
sudo setenforce 0

4. You may need to set correct permission to the .htaccess file on your web root


5. Restart apache

→ sudo apachectl restart

On most of the case above steps will fix the problem. However, If it is still displaying the "Forbidden ... " message then check /var/log/httpd/error.log and take necessary actions.



Done!