记一次在wamper64中增加php遇到的问题

在wamper64中手动增加php版本碰到了不少问题,记录总结一下

原因

因为要复现joomla3.4.6的一个RCE,php要求在5.6.13下才行,我的wamper自带的php5只有5.6.40,所以需要我手动安装一个低版本

过程

一开始我找我的小伙伴要了他的phpstudy下的php5.3.29,按照网上的方法配置好后wamper是橘色的,一看果然有个服务没启动,于是我查看后发现是apache没有正常启动,
查看了一下错误日志后发现是php目录下的wampserver.conf文件内容出了问题
最后定位到第9行:

1
2
3
4
5
6
7
8
9
10
11
12
<?php
$phpConf['phpIniDir'] = '.';
$phpConf['phpExeDir'] = '.';
$phpConf['phpConfFile'] = 'php.ini';
//PHP 5.6.x needs Apache 2.4.x and doesn't works with Apache 2.2.x
//$phpConf['apache']['2.2']['LoadModuleName'] = 'php5_module';
//$phpConf['apache']['2.2']['LoadModuleFile'] = 'php5apache2_2.dll';
//$phpConf['apache']['2.2']['AddModule'] = '';
$phpConf['apache']['2.4']['LoadModuleName'] = 'php5_module';
$phpConf['apache']['2.4']['LoadModuleFile'] = 'php5apache2_4.dll';
$phpConf['apache']['2.4']['AddModule'] = '';
?>

  • 显然是php5apache2_2.dll这个dll加载失败了。我想起小伙伴传给我的php文件里是没有这个dll的,这个dll是我从自己的php5.6.40拷贝过来的,我仔细看了一下他传给我的文件叫:php5.3.29nts.rar,我去查了一下nts的含义,果然是php版本的问题,官方的解释是这样的:
    NTS全称:Non Thread Safe,TS是指具有多线程功能的构建。NTS仅指单线程构建。TS二进制文件的用例涉及与多线程SAPI和作为模块加载到Web服务器的PHP的交互。对于NTS二进制文件,广泛的用例是通过FastCGI协议与Web服务器进行交互,而不使用多线程(例如CLI)。
  • 如果你要使用apache,则需要使用TS版本;如果是IIS,则使用NTS等等
    所以我又去下了一个5.3.29TS版本,下载好安装完成,却发现目录下没有php5apache2_4.dll而是php5apache2_2.dll,后来我看到wampserver.conf下第7行:
    1
    //PHP 5.6.x needs Apache 2.4.x and doesn't works with Apache 2.2.x
    而且我的wamper中只有一个apache2.4版本的,所以需要重新下个版本稍高点的

最后

总结一下需要更改的配置文件

  1. 将你的任意版本php下的php.ini复制到新php目录下,并替换其中的版本号
  2. (本例中)将php5版本下的wampserver.conf复制到新php目录下,具体改的地方要看实际情况
  3. 将你的任意版本php下的phpForApache.ini复制到新php目录下,替换其中的版本号
  4. 打开wamper的配置文件{wamper安装路径}/wampmanager.ini,全局搜索[phpversion]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
[phpVersion]
;WAMPPHPVERSIONSTART
Type: item; Caption: "5.6.11"; Action: multi; Actions:switchPhp5.6.11; Glyph: 13
Type: item; Caption: "5.6.40"; Action: multi; Actions:switchPhp5.6.40
Type: item; Caption: "7.0.33"; Action: multi; Actions:switchPhp7.0.33
Type: item; Caption: "7.1.29"; Action: multi; Actions:switchPhp7.1.29
Type: item; Caption: "7.2.18"; Action: multi; Actions:switchPhp7.2.18
Type: item; Caption: "7.3.5"; Action: multi; Actions:switchPhp7.3.5
[switchPhp5.6.11]
Action: service; Service: wampapache64; ServiceAction: stop; Flags: ignoreerrors waituntilterminated
Action: run; FileName: "D:/Wampserver/bin/php/php5.6.40/php-win.exe";Parameters: "switchPhpVersion.php 5.6.11";WorkingDir: "D:/Wampserver/scripts"; Flags: waituntilterminated
Action: run; FileName: "D:/Wampserver/bin/php/php5.6.40/php.exe";Parameters: "switchMysqlPort.php 3306";WorkingDir: "D:/Wampserver/scripts"; Flags: waituntilterminated
Action: run; FileName: "D:/Wampserver/bin/php/php5.6.40/php-win.exe";Parameters: "refresh.php";WorkingDir: "D:/Wampserver/scripts"; Flags: waituntilterminated
Action: run; FileName: "net"; Parameters: "start wampapache64"; ShowCmd: hidden; Flags: waituntilterminated
Action: resetservices
Action: readconfig
[switchPhp5.6.40]
Action: service; Service: wampapache64; ServiceAction: stop; Flags: ignoreerrors waituntilterminated
Action: run; FileName: "D:/Wampserver/bin/php/php5.6.40/php-win.exe";Parameters: "switchPhpVersion.php 5.6.40";WorkingDir: "D:/Wampserver/scripts"; Flags: waituntilterminated
Action: run; FileName: "D:/Wampserver/bin/php/php5.6.40/php.exe";Parameters: "switchMysqlPort.php 3306";WorkingDir: "D:/Wampserver/scripts"; Flags: waituntilterminated
Action: run; FileName: "D:/Wampserver/bin/php/php5.6.40/php-win.exe";Parameters: "refresh.php";WorkingDir: "D:/Wampserver/scripts"; Flags: waituntilterminated
Action: run; FileName: "net"; Parameters: "start wampapache64"; ShowCmd: hidden; Flags: waituntilterminated
Action: resetservices
Action: readconfig
[switchPhp7.0.33]
Action: service; Service: wampapache64; ServiceAction: stop; Flags: ignoreerrors waituntilterminated
Action: run; FileName: "D:/Wampserver/bin/php/php5.6.40/php-win.exe";Parameters: "switchPhpVersion.php 7.0.33";WorkingDir: "D:/Wampserver/scripts"; Flags: waituntilterminated
Action: run; FileName: "D:/Wampserver/bin/php/php5.6.40/php.exe";Parameters: "switchMysqlPort.php 3306";WorkingDir: "D:/Wampserver/scripts"; Flags: waituntilterminated
Action: run; FileName: "D:/Wampserver/bin/php/php5.6.40/php-win.exe";Parameters: "refresh.php";WorkingDir: "D:/Wampserver/scripts"; Flags: waituntilterminated
Action: run; FileName: "net"; Parameters: "start wampapache64"; ShowCmd: hidden; Flags: waituntilterminated
Action: resetservices
Action: readconfig
  • ;WAMPPHPVERSIONSTART下方插入:Type: item; Caption: "{你的版本号}}"; Action: multi; Actions:switchPhp{你的版本号}

  • 接下来在[switchPhpx.x.xx]前插入

1
2
3
4
5
6
7
8
[switchPhp{你的版本号}]
Action: service; Service: wampapache64; ServiceAction: stop; Flags: ignoreerrors waituntilterminated
Action: run; FileName: "{安装路径}/php/php{你的版本号}/php-win.exe";Parameters: "switchPhpVersion.php {你的版本号}";WorkingDir: "{安装路径}scripts"; Flags: waituntilterminated
Action: run; FileName: "{安装路径}/bin/php/php{你的版本号}/php.exe";Parameters: "switchMysqlPort.php 3306";WorkingDir: "{安装路径}/scripts"; Flags: waituntilterminated
Action: run; FileName: "{安装路径}/bin/php/php{你的版本号}/php-win.exe";Parameters: "refresh.php";WorkingDir: "{安装路径}/scripts"; Flags: waituntilterminated
Action: run; FileName: "net"; Parameters: "start wampapache64"; ShowCmd: hidden; Flags: waituntilterminated
Action: resetservices
Action: readconfig
  • 更改完成后退出wamper64,然后重启各项服务就🆗了
Author: Isabellae
Link: http://is4b3lla3.github.io/2020/01/31/%E8%AE%B0%E4%B8%80%E6%AC%A1%E5%9C%A8wamper64%E4%B8%AD%E5%A2%9E%E5%8A%A0php%E7%89%88%E6%9C%AC%E8%B8%A9%E8%BF%87%E7%9A%84%E5%9D%91/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.