xmpcw 发表于 2018-12-1 14:43:39

IIS7 IIS8 中多个版本php共存的方法

<table cellspacing="0" cellpadding="0" style="margin-right: auto; margin-left: auto; width: 1296px; line-height: 21px; color: rgb(85, 85, 85); font-family: &quot;verdana,宋体&quot;; background-color: rgb(236, 217, 170);"><tbody style="line-height: 21px;"><tr style="line-height: 21px;"><td style="line-height: 21px;"><div id="textstyle_1" style="font-family: Arial, Helvetica, sans-serif; list-style: none; margin-right: auto; margin-left: auto; line-height: 18px; word-break: break-all; overflow: hidden; font-size: 9pt; text-indent: 24px;"><font face="Verdana" style="line-height: 18px;">原文地址: https://blog.cozof.com/pieces/54.shtml 最近又重回.net,用回IIS。<br style="line-height: 18px;">然后用到某个php开源项目,需要低版本的php,之前装的一个php5.5不能用,所以决定降一下版本,后面发现其实可以多个版本共用。于是打算分享下。<br style="line-height: 18px;">分享之前网上先搜了下,有发现有人实现了,但方法不同,所以还是分享下: 我的电脑是win7 64位 php<br style="line-height: 18px;">可以在官网下载http://windows.php.net/download/,php 5.4之前的版本似乎没有了,旧版本我是其它地方找的。<br style="line-height: 18px;">&nbsp;我们将使用fastcgi模块,直接下载非线程安全(Non Thread Safe)的版本,效率比较高.x86是32位的,x64是64位的别下错了,然后点zip下载。<br style="line-height: 18px;">&nbsp;下载解压放到某个目录,比如: E:\php7.0.3\ E:\php5.5.30\ E:\php5.2.6\ php.ini的配置这里就不说了,原来该怎么设置怎么设置。 步骤 1.打开IIS 7。<br style="line-height: 18px;">&nbsp;IIS最上层&gt;处理程序映射 2.右边 添加模块映射 3.在弹出的窗口中 路径写*.php 模块选FastCgiModule,可执行文件是php目录下的php-cgi.exe 名称随便填,为了好记可以填php版本名称,然后确定。 再添加几次 把多个版本的php都添加进去 4.由于是点IIS最上层添加,而不是点某个网站添加,<br style="line-height: 18px;">所以每个网站目录不会自动生成一个web.config文件。我们可以自己添加一个utf-8编码的web.config文件放到网站目录下,用于调用不同版本的php,不管有没有多个版本的php,都需要这么一个web.config文件,内容如下: 1 2 3 4 5 6 7 8 9 10 11 主要就是scriptProcessor(脚本处理器)路径不同,决定了调用了不同版本的php。 也很重要,先把所有版本的php都移除一遍(这里的"name=" 就是之前填的名称)。再add name=,确保调到的是需要的版本。 注意:如果这边remove只有3个,而实际上你加了5个版本的php的话,为了确保调用到正确的版本,应该把另两个加进去。 然后就可以了。有新站的话就把这个web.config拷到站点的目录里,再修改下scriptProcessor的路径就可以了。 我这几个php共用的是一个MySql,版本是5.6.24,能正常使用。 由于php不同版本间是不怎么向后兼容的,比如php5.6以后不支持mysql_*函数连接mysql数据库,只支持mysqli_*和pdo_*等,所以多版本共存还是比较有意义的。<br style="line-height: 18px;"></font></div><div><font face="Verdana" style="line-height: 18px;"><br></font></div></td></tr></tbody></table><p></p>
页: [1]
查看完整版本: IIS7 IIS8 中多个版本php共存的方法