win7下ngnix mysql php的安装_Windows7下nginx +mysql+多版本PHP共存安装方法

配置Nginx同时支持PHP5.2+php5.3 + PHP5.6

这里我们采用php的fastcgi模式来配置nginx对php的支持

1)、首先打开nginx的配置文件目录 D:\Server\nginx\conf 找到nginx.conf 打开它, 我们需要先对他进行改造,以方便我们使用。

我们将server部分的默认配置全部注释掉,然后将server部分的配置全部转移至D:\Server\nginx\conf\vhost 目录[添加配置语句

include vhost/*.conf;

见图.

2)、在D:\Server\nginx\conf目录分别新建php52.conf php53.conf和php56.conf 配置文件 见图,对应的文件和内容如下:

D:\Server\nginx\conf\php52.conf

index  default.html index.html index.htm default.php index.php;

location ~ .*\.(php|php5)?$  {

fastcgi_pass 127.0.0.1:9052;

fastcgi_index index.php;

include fastcgi.conf;

}

D:\Server\nginx\conf\php53.conf

index  default.html index.html index.htm default.php index.php;

location ~ .*\.(php|php5)?$  {

fastcgi_pass 127.0.0.1:9053;

fastcgi_index index.php;

include fastcgi.conf;

}

D:\Server\nginx\conf\php56.conf

index  default.html index.html index.htm default.php index.php;

location ~ .*\.(php|php5)?$  {

fastcgi_pass 127.0.0.1:9056;

fastcgi_index index.php;

include fastcgi.conf;

}

说明: 这里的 127.0.0.1:90xx 是php所对应版本的监听地址和端口,此处设置的xx为本人最近定义的对应PHP版本的端口号,如9052表示的是PHP5.2版本[本人原创,不喜欢这个端口可设置任意你能记住的端口,当然这个端口必须是其他程序没有使用的]

3)、转到php目录配置PHP.ini

将对应的PHP版本的目录里面的php.ini-development改名为 php.ini 然后根据自己的实际使用需要配置就可以了,具体可百度搜索 “ PHP配置文件详解php.ini  ”查看

4)、在D:\Server\nginx目录创建PHP的启动和关闭脚本

先创建ReStartNginx.bat 文件, 然后添加如下内容:

@ECHO OFF

echo Stopping nginx...

taskkill /F /IM nginx.exe > nul

echo Stopping PHP FastCGI...

taskkill /F /IM php-cgi.exe > nul

echo ReStarting nginx...

ECHO Starting PHP FastCGI...

RunHiddenConsole D:/Server/php-5.2.13-nts-Win32/php-cgi.exe -b 127.0.0.1:9052 -c D:/Server/php-5.2.13-nts-Win32/php.ini

RunHiddenConsole D:/Server/php-5.3.29-nts-Win32-VC9-x86/php-cgi.exe -b 127.0.0.1:9053 -c D:/Server/php-5.3.29-nts-Win32-VC9-x86/php.ini

RunHiddenConsole D:/Server/php-5.6.4-nts-Win32-VC11-x86/php-cgi.exe -b 127.0.0.1:9056 -c D:/Server/php-5.6.4-nts-Win32-VC11-x86/php.ini

echo Starting nginx...

D:/Server/nginx/nginx.exe

exit

创建 stop.bat【关闭nginx和PHP服务的】文件,添加如下内容

@echo off

echo Stopping nginx...

taskkill /F /IM nginx.exe > nul

echo Stopping PHP FastCGI...

taskkill /F /IM php-cgi.exe > nul

exit

完成以上步骤后,直接打开ReStartNginx.bat 大公告成! 可以开始你的NGINX+php多版本共存之旅了...............

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值