nginx-500错误-已解决,root cause:nginx的rewrite规则
本帖最后由 chinesebear 于 2014-9-20 22:16 编辑分析记录:
9-20 19:40:暂时感觉是nginx没配置好,导致CI在解析URI的时候,出现了死循环,nginx判断并发过多,给出了500错误,下一步跟踪一下URI解析。
9-20 20:58:前一个分析是错误,现在问题聚焦在nginx的rewrite规则。
9-20 22:08:问题搞定了,感谢57sy.com的提供的nginx配置文件;问题出在nginx的rewrite规则的"location /"。
解决方案如下:
sudo vi /etc/nginx/sites-available/default
----------------------------------------------------
# Make site accessible from http://localhost/
server_name localhost;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php?$args;//修改的地方,原先为“/index.html”
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
php服务器是nginx
CI是最新的2.2,原码没改过
打开连接:http://192.168.3.106/index.php/welcome出现了一下错误
输入http://192.168.3.106/index.php/welcome.php 就没问题了
或者http://192.168.3.106/index.php
或者http://192.168.3.106/都没有问题
这是服务器nginx的问题,还是我配置的问题,哪位大侠帮我看看!
补充:
我以前用CI做的网站在WAMP(LAMP)上,输入http://localhost/dfjg/index.php/home,就不会500这样的错误
错误的意思是说什么并发问题,但是我感觉还是出在,CI本身的机制上,应该在CI的内核上,解析URL出了问题,没有高手就得自己上了。有线索的给我点提示,加快fix的速度。
问题比较蹊跷,大侠帮忙看看! CI2.1.4版本也试过了,还是有这样的问题 这个是你服务器的配置问题。。
####################微网站配置########################
server {
listen 80;
server_namewww.micro.dev micro.dev;
if ($host != 'www.micro.dev' ) {
rewrite ^/(.*)$ http://www.micro.dev/$1 permanent;
}
charset utf-8;
#access_loglogs/host.access.logmain;
#error_page404 /404.html;
root D:/php_work/micro;
indexindex.php index.html index.htm;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504/50x.html;
location = /50x.html {
root D:/php_work/micro;
}
# 1. config
location ~ /config/ {
return 403;
}
# 2. system
location ~ /system/ {
return 403;
}
# 2. application
location ~ /application/ {
return 403;
}
# 9.
#location ~* \.(gif|jpg|png|swf|flv|js)$ {
#valid_referers none blocked www.login.com;
#if ($invalid_referer) {
#rewrite ^/ http://www.login.com/403.html;
# return 404;
#}
#}
# 10.
location / {
# This is cool because no php is touched for static content.
## include the "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/ /index.php?$args;
#rewrite ^/(?!index\.php|robots\.txt|images|js|styles|static|data)(.*)$ /index.php/$1 last;
}
# 11.
location ~ index.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_indexindex.php;
fastcgi_paramSCRIPT_FILENAMED:/php_work/micro$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# denyall;
#}
}
你试试这个吧。。。其中路径你要修改下 还有域名
页:
[1]