Multiple versions of PHP under one Apache on Windows

Some time ago I needed to have different versions of PHP on the same web server. All the manuals that I managed to find with a cursory glance meant linux distributions, to which I did not want to transfer the apache configuration made in agony, installed on the virtual Windows Server 2012 R2 (x64). I present the result of my successful experiment to your court.

First of all, you need to decide what bit depth (x86 or x64) we want from our web server. Recently, namely, version PHP5.5, the developer began to release stable builds for x64, whereas previously such builds were issued by enthusiasts. For the greatest possible spread of PHP versions and for an illustrative example, let us dwell on the x86 assembly. Next, I will indicate the software versions that have worked in my particular case.

1. Download Apache 2.4.10 Win32 VC11 at
ATTENTION! It is necessary to 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 (according to reviews) have performance problems like those of VC9, VC10, and can run modules written for them. Older versions of Apache have not been tested.

The installation and basic configuration of the web server is chewed without me, so we omit it.

2. We take PHP binaries,
We are interested in x86 Thread Safe versions. We take all the stable versions that interest you. Personally, I have earned from 5.3 to 5.6. Archived versions also work.
For convenience, we decompose everything into neighboring folders:

3. We climb into apache configs.

3.1.1 httpd.conf - Turn off PHP if it is configured as a module to 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 - Turn on the FastCGI module
LoadModule fcgid_module modules/

Turn on 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 - We write the settings for each virtual host (highlighted with "||"):

    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;" ||

|| AddHandler fcgid-script .php ||
    Options -Indexes +FollowSymLinks || +ExecCGI ||
|| FcgidWrapper "D:/php/php5.6/php-cgi.exe" .php ||
|| Require all granted ||

If everything is sorted into 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.

Also popular now: