Installed Nginx and PHP-FPM for processing PHP files on CentOS server. To my surprise when accessed PHP files through browser, I see “NGINX 403 forbidden error”. Here’s the error message from NGINX error log
[error] 11044#11044: *4 "/home/html/index.php" is forbidden (13: Permission denied)
I have followed the NGINX installation tutorial.
The only deviation from the guide is the root directory is been changed to my home directory. So how did I fix this error? Read below.
How to Fix NGINX 403 forbidden
After googling, found few people suggesting to disable SELinux, which is a bad Idea! It means, you are shutting off one of the security feature. Seriously, stop disabling SELinux, as it is designed to help protect your server from serious security holes. Dan Walsh explains better on why SELinux shouldn’t be disabled.
For. eg., if you run a web server and have some “vulnerable” code that allows for an attacker to run arbitrary commands then SELinux can help mitigate this, by preventing your web server from accessing files it’s not allowed to see.
Instead follow the below:
sudo chmod o+x /home/html
The above command provides others- that is, people who don’t own
/home/html and aren’t in its group owner either — execute permissions on
/home/html. This will allow the user who’s running NGINX daemon to execute the files under
Restart the nginx daemon as shown below:
sudo systemctl restart nginx
sudo service nginx restart
Hope this tip will help and now the 403 forbidden error will vanish, allowing you to see the actual page.
is a Web Designer and content creator. A freelance writer on latest trends in technology, gadget reviews, How to’s and many more.