在.conf 文件中,頂部增加
underscores_in_headers on;
修改 location ~ \.php$ 刪除 後面的$
underscores_in_headers on;
server {
listen 80;
server_name apis.xiaocx.my;
root /apis/api/public;
index index.php index.html index.htm;
client_max_body_size 20m;
fastcgi_read_timeout 600;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_comp_level 2;
gzip_vary off;
gzip_disable "MSIE [1-6]\.";
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
try_files $uri $uri/ /index.php?$query_string;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
#rewrite (.*) https://www.xiaocx.org$1;
root /var/www/leyou/api;
}
#location @rewrite { rewrite ^ /index.php;
#}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php {
# root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
set $path_info "";
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
}
以上問題花了半天時間才解決;