📜 ⬆️ ⬇️

Multiple PHP versions under one Apache on Windows (v2)

This tutorial did not suit us, because the company has a document regulating the directory structure on LAN, and we have all the websites (about 250) in one directory. I understand and do not get tired of repeating that this document is complete nonsense, but the authorities will not be persuaded. Therefore, it became necessary to quickly switch between versions of PHP without moving anything anywhere, without “these your Denvers and polynservers and other things, everything must be from the box , I’ll come to the right, otherwise I’ll be fired! ".

And so, the directory structure:

C: \ Server \ Apache24
C: \ Server \ PHP55
C: \ Server \ PHP56
C: \ Server \ PHP57
C: \ Server \ home here directories with sites

In C: \ Server \ Apache24 \ conf \ copy / paste 3 copies of httpd.conf and rename them to httpd55.conf, httpd56.conf and httpd7.conf, each configuration file for its version of PHP, respectively. I first configured one Apache config, then after its copy-paste for 3 files I connected it in each file:

your PHP versions
# httpd55.conf LoadModule php5_module "C:/Server/PHP55/php5apache2_4.dll" <IfModule php5_module> AddHandler application/x-httpd-php .php PHPIniDir "C:/Server/PHP55" </IfModule> # httpd56.conf LoadModule php5_module "C:/Server/PHP56/php5apache2_4.dll" <IfModule php5_module> AddHandler application/x-httpd-php .php PHPIniDir "C:/Server/PHP56" </IfModule> # httpd7.conf LoadModule php7_module "C:/Server/PHP7/php7apache2_4.dll" <IfModule php7_module> AddHandler application/x-httpd-php .php PHPIniDir "C:/Server/PHP7" </IfModule> 

Next, through the console, we create 3 Windows services for each version of PHP, indicating which config Apache will use:
')
 C:\Server\Apache24\bin\httpd.exe -k install -n "Apache PHP5.5" -f "C:\Server\Apache24\conf\httpd55.conf" C:\Server\Apache24\bin\httpd.exe -k install -n "Apache PHP5.6" -f "C:\Server\Apache24\conf\httpd56.conf" C:\Server\Apache24\bin\httpd.exe -k install -n "Apache PHP7" -f "C:\Server\Apache24\conf\httpd7.conf" 

Do not forget to leave autorun in only one Apache service. I only have PHP5.6, for PHP5.5 and PHP7 I switch by necessity.

Result:


PS For this crutch, I was even given a prize :)

Source: https://habr.com/ru/post/312202/


All Articles