发布于 2016-04-23 02:46:26 | 210 次阅读 | 评论: 1 | 来源: 网友投递

这里有新鲜出炉的Nginx中文文档,程序狗速度看过来!

Nginx WEB服务器

Nginx 是一个高性能的 HTTP 和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器。 Nginx 是由 Igor Sysoev 为俄罗斯访问量第二的 Rambler.ru 站点开发的,第一个公开版本0.1.0发布于2004年10月4日。其将源代码以类BSD许可证的形式发布,因它的稳定性、丰富的功能集、示例配置文件和低系统资源的消耗而闻名。


这篇文章主要介绍了Nginx+CI出现404错误怎么解决的相关资料,需要的朋友可以参考下

最近刚学ci框架,做了个简单的项目,在本地搭服务器的环境都调通了,但是部署到远程服务器时:

http://example.com/(index.php)/ 可以访问(为配置的默认controller-class)

http://example.com/(index.php)/[controller-class]/[controller-method] 不可以访问(提示404错误!)

最后百度原因:

对于/index.php/abc这种url,Apache和Lighttpd会按”index.php?abc”来解释,而nginx会认为是请求名字是“index.php”的目录下的abc文件的内容。所以CI在nginx下不配置rewrite是无法运行的,而在Apache和Lighttpd则正常。

解决方案(要点加粗,重点标红):



server {

listen ;

server_name example.com;

root /data/wwwroot/example/ index index.php index.html index.htm;

location ~* \.(css|js|swf|htm|jpg|png|gif|json|atlas)?$ {

expires d;

add_header Pragma public;

add_header Cache-Control "public";

}

location /controller-class/ {

if (!-e $request_filename) {

rewrite ^/controller-class/(.*)$ /controller-class/index.php?q=$uri&$args;

}

}

location ~ \.php$ {

fastcgi_pass ...:;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

fastcgi_param PHP_VALUE open_basedir=$document_root:/tmp/:/proc/;

include fastcgi_params;

}

}

以上内容是小编给大家分享的Nginx+CI出现404错误怎么解决的相关内容,希望对大家有所帮助!



最新网友评论  共有(1)条评论 发布评论 返回顶部
jqvwexy 发布于2016-08-07 18:17:30
前排
支持(0)  反对(0)  回复

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务