Skip to content

How to Fix 403 forbidden error After Changing the Root Directory in NGINX

1 min read

When accessed PHP files through a browser, may see "NGINX 403 forbidden error".


Here's the error message from NGINX error log /var/log/nginx/error.log.


[error] 11044#11044: *4 "/home/html/index.php" is forbidden (13: Permission denied)


It is because of the root directory has been changed to the home directory.


Then do the following steps:


Enter the given command:


sudo chmod o+x /home/html


The above command gives others who don't own /home/html and aren't in its group owner achieve permissions on /home/html. It permits the user running NGINX daemon to execute the files on /home/html.


Then restart it.


To restart the Nginx daemon run the following command:


sudo systemctl restart nginx


or


sudo service nginx restart


Then 403 forbidden error will vanish and permitting you to see the actual page.

 

Related services

KVM VPS hosting

NVMe SSD and full root access, with Free Basic Managed Support.

Managed cPanel VPS

cPanel included; we handle updates, security and monitoring.

Server management

on-demand administration, hardening, migrations and monitoring.

Was this answer helpful?

Still stuck? Open a ticket