【发布时间】:2018-03-21 19:16:39
【问题描述】:
我是 nginx 的新手,并尝试在 StackOverflow 上找到问题,但在论坛上没有找到确切的问题。 成功安装 nginx、MySQL 和 php-fpm 后,我测试了运行正常的 php.info。
我正在将 CodeIgniter 项目从 apache 服务器移动到 nginx。我编辑了包含代码的nginx.conf 文件
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;
}
}
它对php.info 工作正常,就像我的路径是http://173.249.40.xxx/ci/info.php,但在调用时不适用于CodeIgniter controller name,比如http://173.249.40.xxx/ci/index.php/Welcome。我尝试从
https://www.nginx.com/resources/wiki/start/topics/recipes/codeigniter/#
对于 CodeIgniter 应用程序,但它也不适用于我。
CodeIgniter 应用路径为'/usr/share/nginx/html/ci/;'
请给我一些建议。我该如何解决?
【问题讨论】:
-
检查
root /usr/share/nginx/html;,并确保设置为您的代码所在的目录。在您链接的示例页面中,它是root /var/www/codeignitor;有 index.php 或 html 所在的位置。假设,如果您的代码是您所说的应用程序,则将其更改为:root /usr/share/nginx/html/ci/; -
我试过那个也没用。
root /usr/share/nginx/html/ci/;
标签: php codeigniter nginx digital-ocean