狮子鱼商城系统 Nginx 配置说明
狮子鱼商城系统 Nginx 配置说明
问题:No input file specified
这是 nginx + PHP-FPM 配置中最常见的错误,通常是因为 fastcgi_param SCRIPT_FILENAME 配置不正确。
快速解决方案
步骤 1:找到你的 nginx 配置文件
Windows 环境:
通常在
C:\nginx\conf\nginx.conf或C:\nginx\conf\vhost\*.conf
Linux 环境:
通常在
/etc/nginx/sites-available/或/etc/nginx/conf.d/
步骤 2:修改 PHP 处理配置
找到 location ~ \.php$ 部分,确保配置如下:
location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; # 根据你的 PHP-FPM 配置调整
fastcgi_index index.php;
# 关键配置:必须使用 $document_root
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}步骤 3:确保 root 路径正确
server { # Windows 路径(使用正斜杠)
root E:/Project/BOOSZOU/zhe.qdneed.com;
# Linux 路径示例
# root /var/www/zhe.qdneed.com;
# ...}步骤 4:检查 PHP-FPM 配置
Windows 环境(php-fpm.conf):
listen = 127.0.0.1:9000
Linux 环境(/etc/php-fpm.d/www.conf):
listen = 127.0.0.1:9000# 或listen = /var/run/php-fpm/php-fpm.sock
重要:nginx 的 fastcgi_pass 必须与 PHP-FPM 的 listen 配置匹配!
步骤 5:测试并重载配置
# 测试配置语法nginx -t# 重载配置nginx -s reload# 或service nginx reload
完整配置示例
项目根目录已提供完整配置文件:nginx-lionfish.conf
使用方法:
复制配置内容到你的 nginx 配置文件
修改以下参数:
server_name:你的域名root:项目实际路径fastcgi_pass:PHP-FPM 监听地址
配置要点:
ThinkPHP 路由重写:
location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=$1 last; break; } }多个入口文件支持:
index.php- 主入口seller.php- 商家端wxapp.php- 小程序notify.php- 通知delivery_notify.php- 配送通知静态文件缓存:已配置 30 天缓存
安全配置:禁止访问 Runtime、ThinkPHP 等敏感目录
常见问题排查
问题 1:仍然报 "No input file specified"
解决方案 A:使用绝对路径
fastcgi_param SCRIPT_FILENAME E:/Project/BOOSZOU/zhe.qdneed.com$fastcgi_script_name;
解决方案 B:检查路径是否正确
# 在 PHP 文件中临时添加调试代码<?phpecho "SCRIPT_FILENAME: " . $_SERVER['SCRIPT_FILENAME'] . "<br>";echo "File exists: " . (file_exists($_SERVER['SCRIPT_FILENAME']) ? 'Yes' : 'No'); ?>
问题 2:PHP-FPM 连接失败
检查 PHP-FPM 是否运行:
# Windowstasklist | findstr php-fpm# Linuxps aux | grep php-fpm
检查端口是否监听:
# Windowsnetstat -an | findstr 9000# Linuxnetstat -tlnp | grep 9000
问题 3:路由不工作(404 错误)
确保 ThinkPHP 路由重写规则已配置:
location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}问题 4:文件权限问题(Linux)
# 确保文件可读chmod 644 *.phpchmod -R 755 /path/to/project# 确保 nginx 用户有权限chown -R www-data:www-data /path/to/project
Windows 环境特殊说明
路径格式:使用正斜杠
/,不要使用反斜杠\root E:/Project/BOOSZOU/zhe.qdneed.com; # ✅ 正确root E:\Project\BOOSZOU\zhe.qdneed.com; # ❌ 错误
PHP-FPM:Windows 通常使用 TCP Socket(127.0.0.1:9000)
服务管理:
# 启动 nginxnginx.exe# 停止 nginxnginx.exe -s stop# 重载配置nginx.exe -s reload
验证配置
访问以下 URL 测试:
首页:
http://zhe.qdneed.com/商家端:
http://zhe.qdneed.com/seller.php小程序接口:
http://zhe.qdneed.com/wxapp.php?controller=Index.index
如果都能正常访问,说明配置成功!
日志查看
查看错误日志:
# Windowstype C:\nginx\logs\error.log# Linuxtail -f /var/log/nginx/error.log
查看访问日志:
# Windowstype C:\nginx\logs\access.log# Linuxtail -f /var/log/nginx/access.log
技术支持
如果问题仍未解决,请提供:
nginx 配置文件内容
PHP-FPM 配置文件内容
nginx 错误日志
PHP-FPM 错误日志
操作系统版本
狮子鱼商城系统 - ThinkPHP 3.x 框架