📜 ⬆️ ⬇️

Multiple PHP Versions Under One Apache on Windows

Some time ago I needed to have different versions of PHP on one web server. All the manuals that I managed to find at a glance implied linux distributions, to which I did not want to transfer the apache configuration, which was installed in the throes, installed on the virtual Windows Server 2012 R2 (x64). I present the result of my successful experiment to your judgment.

First of all, you need to decide what bitiness (x86 or x64) we want from our web server. Recently, namely, versions of PHP5.5, the developer began to produce stable builds for x64, whereas earlier similar builds were released by enthusiasts. For the greatest possible variation of PHP versions and for a good example, let’s focus on the x86 build. Next, I will indicate the software versions that have earned in my particular case.

1. Download Apache 2.4.10 Win32 VC11 at www.apachelounge.com/download
ATTENTION! You must have Visual C ++ Redistributable for Visual Studio 2012 installed on your computer
The choice of version is due to the fact that VC11 assemblies do not have (according to reviews) performance problems like VC9, VC10, and can run modules written for them. Older versions of Apache have not been tested.

Installation and basic configuration of the web server is chewed without me, so we omit it.
')
2. We take PHP binaries, windows.php.net/download
We are interested in the x86 Thread Safe version. We take all the stable versions that interest you. Personally, I earned from 5.3 to 5.6. Archived versions also work.
For convenience, we decompose everything in neighboring folders:
image

3. We climb in apache configs.

3.1.1 httpd.conf - Turn off PHP, if it is configured as a module for Apache:
#LoadModule php5_module "D:/php/php5.6/php5apache2_4.dll" #AddType application/x-httpd-php .php #PHPIniDir "D:/php/php5.6/" 


3.1.2 httpd.conf - Enable FastCGI module
 LoadModule fcgid_module modules/mod_fcgid.so 

Enable the use of its configuration:
 Include conf/extra/httpd-fcgid.conf 


3.2 conf / extra / httpd-fcgid.conf - We leave the default settings, except for the first paragraph:
 # Fast CGI module Settings (PHP 5.3, 5.4) # FcgidInitialEnv PHPRC "C:\\php" # FcgidInitialEnv PATH "C:\\php;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;" FcgidInitialEnv SystemRoot "C:\\Windows" FcgidInitialEnv SystemDrive "C:" FcgidInitialEnv TEMP "C:\\WINDOWS\\TEMP" FcgidInitialEnv TMP "C:\\WINDOWS\\TEMP" FcgidInitialEnv windir "C:\\WINDOWS" 


3.3 conf / extra / httpd-vhost.conf - Register settings for each virtual host (highlighted with "||"):
 <VirtualHost *:80> DocumentRoot "D:/http/web.local/" ServerName web.local ErrorLog "logs/web.local-error.log" CustomLog "logs/web.local-access.log" common || FcgidInitialEnv PHPRC "D:\\php\php5.6" || || FcgidInitialEnv PATH "D:\\php\php5.6;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;" || <Directory "D:/http/web.local/"> || AddHandler fcgid-script .php || Options -Indexes +FollowSymLinks || +ExecCGI || || FcgidWrapper "D:/php/php5.6/php-cgi.exe" .php || || Require all granted || </Directory> </VirtualHost> 


If everything is laid out in neighboring folders like mine, then in the virtual host config we change only the last digits in the PHP path.

As a result: we get different versions of PHP on different virtual hosts on the same Apache service.

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


All Articles