Nginx + codeigniter configuration not working on CentOS 7

codeigniterdigital-oceannginxPHP

I am new on nginx and try to find the issue on StackOverflow but not found the exact one on forums.
After successful installation of nginx, MySQL and php-fpm I test the php.info that was working fine.

I am moving the CodeIgniter project to the nginx from apache server. I edit the nginx.conf file that has code

server {
    listen       80;
    server_name  173.249.40.xxx;

    # note that these lines are originally from the "location /" block
    root   /usr/share/nginx/html/ci;
    index index.html index.htm index.php;

    location /ci {
        try_files $uri $uri/ /index.php;
    }        

    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

it was working fine for php.info like my path is http://173.249.40.xxx/ci/info.php but not working for CodeIgniter controller name like http://173.249.40.xxx/ci/index.php/Welcome when called.

The CodeIgniter application path is '/usr/share/nginx/html/ci/;'

Please suggest me something. how can I fix it?

Best Answer

Here is the error:

    location /ci {

Because of this, only URL paths which start with /ci will be processed by the enclosing try_files. This is not what you want.

Instead, you should have all URLs processed, with

    location / {