Nginx配置Typecho,点击登录login.php页面下载到了本地,怎么解决?


这是我的Nginx的配置

server {
listen 80;
server_name localhost;

charset utf-8;
root /opt/build;
index index.html index.htm index.php;

# location / {
# try_files $uri $uri/ /index.php?$args;
#}

if (!-e $request_filename) {
rewrite ^(.*)$ /index.php$1 last;
}

location ~ .*\.php(\/.*)*$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}


http://server_name/index.php/*
这种格式的路由都能正常访问,但是点击登录
http://server_name/admin/login.php
就是把
login.php
页面下载下来。原因应该是
php-fpm
没有执行这个脚本。可能Nginx配置的路由有问题,我的配置是按照官方文档配的,请问如何解决呢?谢谢。

Nginx: 1.10.3
PHP: 7.1.3



已邀请:

junxxx

赞同来自:


ps -ef |grep nginx 看一下进程里,nginx和php-fpm是否正常。

傅易君

赞同来自:


这是我所使用的配置,请试用一下?

location / {
try_files $uri $uri/ /index.php$uri?$query_string;
}

location ~ .+\.php(/.*)?$ {
fastcgi_split_path_info ^(.+\.php)(/.*)?$;
# save $fastcgi because try_files will reset it
set $path_info $fastcgi_path_info;
# Check that the PHP script exists before passing it
try_files $fastcgi_script_name =404;
# Bypass the fact that try_files resets $fastcgi_path_info
# see: http://trac.nginx.org/nginx/ticket/321
fastcgi_param PATH_INFO $path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_pass unix:/usr/local/var/run/php-fpm.sock;
}

要回复问题请先登录注册