Windows下配置Nginx使之支持PHP(转)
2013-08-02 17:21
399 查看
平台描述:Windows下,使用PHP套件xampp,因为是测试玩,所以没在服务器Linux环境中配置。
1.首先,将nginx.conf中的PHP配置注释去掉。
2.这里使用的PHP是以cgi的形式,所以要启用php-cgi,修改php.ini,把注释去掉:
3.启动php-cgi和nginx,下面介绍两个脚本:
start_nginx.bat
stop_nginx.bat
相关下载:RunHiddenConsole.zip
可以看看进程里,如果nginx和php-cgi都有,那么差不多要成功了。最后,可能会出现"Noinputfilespecified"的问题,那么修改一下nginx.conf:
注意注释的地方,修改成下面那行,请根据你的具体文件配置路径。
编辑test.php:
运行http://localhost:81/test.php,OK。
1.首先,将nginx.conf中的
01 | #passthePHPscriptstoFastCGIserverlisteningon127.0.0.1:9000 |
02 | # |
03 | #location~\.php${ |
04 | #roothtml; |
05 | #fastcgi_pass127.0.0.1:9000; |
06 | #fastcgi_indexindex.php; |
07 | #fastcgi_paramSCRIPT_FILENAME/scripts$fastcgi_script_name; |
08 | #includefastcgi_params; |
09 | #} |
10 |
11 | location~\.php${ |
12 | roothtml; |
13 | fastcgi_pass127.0.0.1:9000; |
14 | fastcgi_indexindex.php; |
15 | fastcgi_paramSCRIPT_FILENAME/scripts$fastcgi_script_name; |
16 | includefastcgi_params; |
17 | } |
1 | ;cgi.fix_pathinfo=1 |
2 | cgi.fix_pathinfo=1 |
start_nginx.bat
01 | @echooff |
02 |
03 | REMsetPHP_FCGI_CHILDREN=5 |
04 | setPHP_FCGI_MAX_REQUESTS=1000 |
05 |
06 | echoStartingPHPFastCGI... |
07 | RunHiddenConsoleD:/xampp/php/php-cgi.exe-b127.0.0.1:9000-cD:/xampp/php/php.ini |
08 |
09 | echoStartingnginx... |
10 | RunHiddenConsoleD:/nginx/nginx.exe-pD:/nginx/ |
1 | @echooff |
2 | echoStoppingnginx... |
3 | taskkill/F/IMnginx.exe>nul |
4 | echoStoppingPHPFastCGI... |
5 | taskkill/F/IMphp-cgi.exe>nul |
6 | exit |
可以看看进程里,如果nginx和php-cgi都有,那么差不多要成功了。最后,可能会出现"Noinputfilespecified"的问题,那么修改一下nginx.conf:
01 | location~\.php${ |
02 | #roothtml; |
03 | rootD:/nginx/html; |
04 | fastcgi_pass127.0.0.1:9000; |
05 | fastcgi_indexindex.php; |
06 | #fastcgi_paramSCRIPT_FILENAME/scripts$fastcgi_script_name; |
07 | #fastcgi_paramSCRIPT_FILENAMED:/nginx/html$fastcgi_script_name; |
08 | fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name; |
09 | includefastcgi_params; |
10 | } |
编辑test.php:
1 | <?php |
2 | phpinfo(); |
3 | ?> |
相关文章推荐
- windows下nginx支持php的配置
- Windows下配置Nginx使之支持PHP
- wnmp(windows+nginx+mysql+php)的环境搭建和配置
- Windows 2008系统下配置IIS 7支持PHP全攻略
- centos6.5直接yum安装nginx,并且支持php访问的配置
- Windows下配置Nginx+php+mysql
- 配置nginx,支持php的pathinfo路径模式
- windows nginx php配置
- 四、配置nginx支持php
- Windows 下配置 Nginx PHP
- 搭建windows+Nginx+PHP配置指南 以及 之后的问题解决
- wnmp(windows+nginx+mysql+php)环境搭建和配置
- windows下nginx1.10.1配置laravel5.2路由支持
- Linux下Nginx+PHP+Mysql安装,Nginx配置文件支持PHP
- Windows下配置Apache服务器并支持php
- Nginx支持php配置
- Windows下配置Nginx+php+mysql
- 在nginx中配置支持php_info的参数
- nginx配置支持PHP解析
- nginx环境下配置支持php5.6(nginx+PHP)