Reputation: 1380
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. I try from
https://www.nginx.com/resources/wiki/start/topics/recipes/codeigniter/#
for CodeIgniter application but it also not work for me.
The CodeIgniter application path is '/usr/share/nginx/html/ci/;'
Please suggest me something. how can I fix it?
Upvotes: 0
Views: 1401
Reputation: 950
The codeigniter has it's own routing mechanism so in order to work you need from web server to pass everything you can't find to the index.php
not to toss 404 messages.
So try to change your location / {...}
block to the following:
location /ci/ {
# Check if a file or directory index file exists, else route it to index.php.
try_files $uri $uri/ /ci/index.php;
}
The above it's taken from the link in your question.
Upvotes: 1