[php]windows上启动两个apache,两个版本php

原理:安装两个apache服务,对应不同的配置文件(http.conf),加载不同的php模块,启用两个不同端口。

apache版本:apache2.4.10
php版本:php5.5.18/php7.1.5

两个httpd.conf配置文件差异部分

httpd.conf

Listen 80
PHPIniDir “F:/SERVER/php5.5.18”
LoadFile “F:/SERVER/php5.5.18/libpq.dll”
LoadFile “F:/SERVER/php5.5.18/libpq.dll”
LoadFile “F:/SERVER/php5.5.18/libeay32.dll”
LoadFile “F:/SERVER/php5.5.18/ssleay32.dll”
LoadModule php5_module “F:/SERVER/php5.5.18/php5apache2_4.dll”

httpd-php7.conf

Listen 81
PHPIniDir “F:/SERVER/php7.1.5”
LoadFile “F:/SERVER/php7.1.5/libpq.dll”
LoadFile “F:/SERVER/php7.1.5/libpq.dll”
LoadFile “F:/SERVER/php7.1.5/libeay32.dll”
LoadFile “F:/SERVER/php7.1.5/ssleay32.dll”
LoadModule php7_module “F:/SERVER/php7.1.5/php7apache2_4.dll”

两个php.ini配置文件差异部分
php5.5.18中php.ini文件
extension_dir = “F:\SERVER\php5.5.18\ext\”

php7.1.5中php.ini文件
extension_dir = “F:\SERVER\php7.1.5\ext”

将需要的扩展打开
extension=php_gd2.dll
extension=php_openssl.dll
extension=php_pdo_mysql.dll
extension=php_pdo_pgsql.dll
extension=php_pgsql.dll
extension=php_soap.dll
服务安装
F:\SERVER\apache2.4.10\bin\httpd.exe -k install -n Apache2.4 -f “F:\SERVER\apache2.4.10\conf\httpd.conf”
F:\SERVER\apache2.4.10\bin\httpd.exe -k install -n Apache2.4-Php7 -f “F:\SERVER\apache2.4.10\conf\httpd-php7.conf”

启动服务即可
net start Apache2.4
net start Apache2.4-Php7

访问
http://localhost
查看server
Server:Apache/2.4.10 (Win64) OpenSSL/1.0.2k PHP/5.5.18
http://localhost:80
查看server
Server:Apache/2.4.10 (Win64) OpenSSL/1.0.2k PHP/7.1.5

发表评论

邮箱地址不会被公开。 必填项已用*标注