系统环境:
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
复制代码代码示例:
@echo off
REM set PHP_FCGI_CHILDREN=5
2)、stop_nginx.bat
复制代码代码示例:
@echo off
echo Stopping nginx... taskkill /F /IM nginx.exe > nul echo Stopping PHP FastCGI... taskkill /F /IM php-cgi.exe > nul exit
可以查看进程中是否有nginx 和 php-cgi。
复制代码代码示例:
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; } 注意,要将注释的地方,修改成下面那行,请根据具体文件配置路径。
创建测试文件test.php,内容如下:
复制代码代码示例:
<?php
phpinfo(); ?> 访问 http://localhost:81/test.php,测试正常。 (责任编辑:IT) |