Running different versions of PHP under Windows

Jorge Castro
Cook php
Published in
2 min readJan 5, 2019

It is possible to run multiple copies of Apache (if they use different ports) and each copy of Apache pointing at a different version of PHP. I work that way because It uses less resources and memory (versus Vagrant or Docker). In fact, we don’t need docker at all.

  1. DOWNLOAD Apache from Apache Lounge https://www.apachelounge.com/download/ and uncompress it in some folder. If we need more than one copy of php, then we must uncompress in a different folder.

Example: (I want to install php 5.6 and php 7.2)

📁 c:\apachephp5 // uncompress it here
📁 c:\apachephp5\bin
📁 c:\apachephp5\config
📁 c:\apachephp5\etc.
📁 c:\apachephp7 // and uncompress it here
📁 c:\apachephp5\bin
📁 c:\apachephp5\config
📁 c:\apachephp5\etc.

2. DOWNLOAD PHP from PHP For Windows https://windows.php.net/download/ and uncompress it in some folder. It must be the version THREAD SAFE (TS).

Example php 5 and php 7.

📁 c:\php5\
📁 c:\php7\

3. Go to the Apache’s **config** folder and edit the file **httpd.conf**

📃 c:\apachephp5\config\httpd.conf
📃 c:\apachephp7\config\httpd.conf

Uncomment the line that says

#Listen …

and change it for

Listen 8010 (or the desirable port)

After the last #loadmodule, add the next line. It is for PHP 5

PHPIniDir c:/php5
LoadModule php5_module “c:/php5/php5apache2_4.dll”

Or for PHP 7:

PHPIniDir c:/php7
LoadModule php7_module “c:/php7/php7apache2_4.dll”

Find the last line that says #AddType and add the next line

AddType application/x-httpd-php .php

And maybe you want to change the document root

📁 c:\myfolderproject (it is where is your php project)

DocumentRoot “c:/myfolderproject”
<Directory “c:/myfolderproject”>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

4. Rinse and repeat for each instance of Apache/PHP that you want to run

5. Let’s say that some module requires a special library (curl for example). You could copy those libraries right into the apache’s bin folder. Example: libeay32.dll, libssh2.dll and ssleay32.dll

📁 c:\php5\ // copy the files
📁 c:\php7\ // copy the files

📁 c:\apachephp5\bin //(and paste it here)
📁 c:\apachephp7\bin //(and paste it here)

6. Run apache manually by going to the Apache’s bin folder and running (as a shell command) the program **httpd.exe**

📁 c:\apachephp5\bin\httpd.exe

Note, it is ok if Apache shows this message:

AH00558: httpd: Could not reliably determine the server’s fully qualified domain name, using ******. Set the ‘ServerName’ directive globally to suppress this message

7. With a bit of practice, it is quite easy

--

--