How to solve CodeIgniter 404 error on Nginx+PHP5 FPM (VestaCP)

Recently, I configured Nginx + PHP FPM using VestaCP on my cloud server. After configuring DNS and all other basic stuff, I deployed a CodeIgniter project on my domain. Deployment was successful but whenever I tried to hit the domain it gave me 404 error. After a lot of searching I found the solution.

  • Log in to your server via SSH
  • Open Nginx configuration file for your domain
 sudo nano /home/<username>/conf/web/<domain-address>.nginx.conf
  • Add the following code in conf file
location / {
try_files $uri $uri/ /index.php; //add this line
}
  • Validate configuration file by running this command
sudo nginx -t
  • At the end, restart Nginx service
 sudo systemctl reload nginx


You May Also Like

2 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.