当前位置:首页 > Windows程序 > 正文

Windows下nginx+php配置

2021-03-29 Windows程序

1. 首先,将 nginx.conf 中的 PHP 配置注释去掉。

# 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 /scripts$fastcgi_script_name; # include fastcgi_params; #} location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; include fastcgi_params; }

2. 这里使用的 PHP 是以 cgi 的形式,所以要启用 php-cgi,修改 php.ini,把注释去掉:

;cgi.fix_pathinfo=1 cgi.fix_pathinfo=1

3. 启动 php-cgi 和 nginx

php D:/xampp/php/php-cgi.exe -b 127.0.0.1:9000 -c D:/xampp/php/php.ini nginx D:/nginx/start nginx

可以看看进程里,如果 nginx 和 php-cgi 都有,那么差不多要成功了。最后,,可能会出现 "No input file specified" 的问题,那么修改一下 nginx.conf :

location ~ \.php$ { #root html; root D:/nginx/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; #fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; #fastcgi_param SCRIPT_FILENAME D:/nginx/html$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }

注意注释的地方,修改成下面那行,请根据你的具体文件配置路径。

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/69783.html