一 环境介绍:
win10, LNMP
二 错误描述:
访问网站时,提示"No input file specified"错误.
排错阶段:
1. 查看nginx access日志 (access.log)
发现提示404 错误
2. 分析原因:
这时,在同目录下创建一个txt文件,访问就可以正常输出了
这说明 现在nginx 访问php 没有输出,意味着没有对php文件进行解析
这样问题就明朗了,多半和 cgi 以及 location的定义有关
3. 解决方案:
在对应域名的vhost配置文件中添加对php文件的解析
注: 在项目中,我们经常会用到redis,而有时我们项目出现莫名的错误,很可能就和redis有关,所以,我们要养成一旦项目出现错误, 首先排查redis , 看redis 是否可以正常连接 .
4. 具体配置文件代码如下:
server {
listen 80;
server_name test.kk.com;
charset utf-8;
access_log logs/access/test.kk.com.access.log main;
error_log logs/error/test.kk.com.error.log debug;
root "E:/PHP/phpstudy/WWW/Project/kk";
index index.html index.htm index.php;
location /favicon.ico {
log_not_found off;
access_log off;
}
location /static/original {
}
location /static {
access_log off;
}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
location / {
if (!-e $request_filename) {
rewrite ^/comic-detail-(\d+)/ /mh-$1/ permanent;
rewrite ^/comic-detail-(\d+)/(\d+)/ /mh-$1/$2/ permanent;
rewrite ^/show-(\d+)-(\d+)/ /mh-$1/$2/ permanent;
rewrite ^/show-(\d+)-(\d+)-(\d+)/ /mh-$1/$2-$3/ permanent;
rewrite ^/mh-(\d+)/(\d+)/$ /read-comic-$1-$2/ last;
rewrite ^/mh-(\d+)/(\d+)-(\d+)/$ /read-comic-$1-$2-$3/ last;
rewrite "^/uploads/manhua/\d+/\d{4}-(\d{3})-(\d{2})-(\d{2})-(\d{2})-(\d+)-(.*)$" /static/comic2/$1/$2/$3/$4/$5/$6 last;
rewrite ^/(.*)$ /index.php?$1 last;
}
}
location /union/ {
rewrite ^/union/(.*)$ /union/index.php?$1 last;
}
location ~ /\.ht {
deny all;
}
}