How to Handle Multiple PHP Versions with Apache Server on Windows

1 263

In this article, we will discuss “How to Handle Multiple PHP Versions with Apache Server on Windows”. As previous, I’m sharing an article where you learn how to set up Apache, PHP, and MySql on windows. So I recommend you to start with our previous article for a better understanding. Because in this article, I’m not adding the basic setup steps which are already discussed in the previous article.

Multiple PHP Versions

We need different PHP versions which we want to set up on our system. You can download it from the official PHP site and choose the Non Thread Safe releases.

Multiple PHP Version

I recommend you to create a new directory with “PHP” name and extract all the downloaded PHP versions in this directory. It’s really simple and easy to maintain for example “F:\localserver\php, and PHP versions such as 7.2.11, 7.3.0”.

After extracting the PHP versions, you need to add the PHP path into the windows environment variable. And inside each PHP version’s directory, you found php.ini-development. Create a copy of this file and saved on the same location with the name of php.ini.

There is one important update which is mandatory as given below:

; extension_dir = "ext"

// Uncomment the above mention statement and change it to

extension_dir = "F:\localserver\php\7.3.0\ext"

You need to update the extension_dir path as per the PHP version.

Update Apache

We already discussed, how to setup apache server in our previous article. So we are not adding here again. To setup of multiple version, we need a “mod_fcgid (FastCGI ASF module)”, you can download it from the Apache Lounge.

Extract the downloaded modules ZIP package. Go into the mod_fcgid-*** (*** is a version and other details) folder. Open the mod_fcgid folder, copy the file into the Apache module directory such as F:\localserver\Apache24\modules.

Update httpd.conf

Open the httpd.conf, located at F:\localserver\Apache24\conf. Search the following modules in this file, if available then uncomment (remove the # symbol from the starting) it otherwise add those modules.

# LoadModule include_module modules/
# LoadModule vhost_alias_module modules/
# LoadModule fcgid_module modules/

Before adding those modules, it’s necessary to all those modules available in the module directory.

Update httpd-default.conf

Open the httpd-default.conf, located at F:\localserver\Apache24\conf\extra. Add the following code snippet at the bottom of the file.

FcgidInitialEnv PATH "F:\localserver\php\7.3.0;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"
FcgidIOTimeout 64
FcgidConnectTimeout 16
FcgidMaxRequestsPerProcess 1000
FcgidMaxProcesses 50
FcgidMaxRequestLen 8131072
# Location of php.ini
FcgidInitialEnv PHPRC "F:\localserver\php\7.3.0"
FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 1000
<Files ~ "\.php$">
  AddHandler fcgid-script .php
  FcgidWrapper "F:/localserver/php/7.3.0/php-cgi.exe" .php
  Options +ExecCGI

In the above code snippet, we are just creating a default configuration of our apache server. Currently, we are setting up the PHP version 7.3 as our default PHP version.

You may change the PHP path as per your requirement such as “F:\localserver\php\7.3.0” or “F:\localserver\php\7.2.13”.

Add httpd-default.conf in the httpd.conf. Open httpd.conf and apply the changes as given below.

# Include conf/extra/httpd-default.conf


Include conf/extra/httpd-default.conf

Test PHP in Browser

Create a new file phpinfo.php at F:\localserver\Apache24\htdocs with the following content.

    echo phpinfo();

Open the browser and visit “http://localhost/phpinfo.php”.sho

phpMyAdmin Issue

I’m facing one strange issue in the phpMyAdmin as per the below mention screenshot.

Multiple PHP Version with Windows

It’s because phpMyAdmin still not support PHP 7.3 completely. You can read more at PHP Bug.

Setup Virtual Host for PHP Version

We already discussed Virtual Host in our previous article. Today, we create the virtual host for our different PHP versions on different Port. You need to change your host file located at C:\Windows\System32\drivers\etc to have Windows map these fake domains to your local server. localhost:90

Update the httpd.conf

Open the file and uncomment (remove the leading hash sign) as given below.

# Include conf/extra/httpd-vhosts.conf


Include conf/extra/httpd-vhosts.conf

Also, add port no to start listening.

Listen 90

Now edit the F:\localserver\Apache24\conf\extra\httpd-vhosts.conf file and add the following content.

<VirtualHost *:90>
    ServerAdmin webmaster@local.web
    DocumentRoot "F:/localserver/Apache24/htdocs"
    ServerName localhost:90
    ErrorLog "logs/"
    CustomLog "logs/" common 
    # Use below statement to load the specific version of php configuration
    FcgidInitialEnv PHPRC "F:/localserver/php/7.2.13/php.ini"

    <Directory "F:/localserver/Apache24/htdocs"> 
        <Files ~ "\.php$"> 
            AddHandler fcgid-script .php 
            FcgidWrapper "F:/localserver/php/7.2.13/php-cgi.exe" .php 
            Options +ExecCGI 

In the above code snippet, We are using “FcgidInitialEnv PHPRC” statement to load the specific PHP config (php.ini) file.

Everything is ready now. We can access both PHP versions with the same apache server, http://localhost for PHP version 7.3.0 and http://localhost:90 for PHP version 7.2.13.


In this article, we are discussing “How to Handle Multiple PHP Versions with Apache Server on Windows”. I’m trying to explain you step by step process to make setup easy. I recommend you to read our previous article for a better understanding. We will discuss more on the Virtual Host, Apache, phpMyAdmin, PHP in our future post.  Please feel free to add the comment if any query or you can submit your feedback 😉

Leave A Reply

Your email address will not be published.

1 Comment
  1. Kelly B. says

    It’s really time saver,
    buddy 😉