How to use multiple PHP versions with Apache on Windows
In this tutorial where are going to explain how to use multiple php versions with our localhost in a pervious tutorial I've explained how to create your own localhost for windows
before starting make sure you've the following installed:
Apache Lounge
Must installed it and tested it is running correctly.
Download:
http://www.apachelounge.com/download/
I'm going to use v2.4.29 the lastest version for that tutorial date.
Any PHP version (Thread Safe)
Download:
http://windows.php.net/downloads
Create a directory such as C:php
Unzip a version of php (example php5.6 the zipped binary version, not the one with the installer), into a subdirectory of c:php)
Prepare any code editor
I'm going to use Notepad++ but you can use any other code editor. It should be fine.
Notepad++
Download:
https://notepad-plus-plus.org/
If the Apache service is running, stop it. In properties set it startup type to ‘Manual’.
First uninstall any pervious Apache service by using command prompt:
httpd.exe -k uninstall
Move any pervious version at C:\php
to a sub folder for example if you've php7 version move it to C:\php\php7 after creating a new sub folder.
In this tutorial I'm going to use php7 as well as php5
So I've created 2 sub folders.
Unzip the other version of php (eg. 5.6) into a subdirectory.
Install PHP 7
Go to php7 folder rename php.ini-development
to php.ini
Go to C:\Apache24\conf
Edit httpd.conf
Add this for php after all modules:
and add the following at the end:
AddType application/x-httpd-php .php
# Choice between php versions
<ifdefine php7>
LoadModule php7_module C:/php/php7/php7/php7apache2_4.dll
DirectoryIndex index.html index.php
AddHandler application/x-httpd-php .php
# configure the path to php.ini
PHPIniDir "C:/php/php7"
</ifdefine>
Then open command prompt install and install the service:
httpd.exe -k install -n Apache_php7 -D php7
Refresh the services list, then there will be one named ‘Apache_php7′.
Test it by using:
<?php phpinfo() ?>
in info.php file.
Browse to your localhost url:
localhost/info.php
Install PHP 5
Go to php5 folder rename php.ini-development
to php.ini
Add this for php5 after php7 module:
<ifdefine php5>
LoadModule php5_module "C:/php/php5/php5apache2_4.dll"
DirectoryIndex index.html index.php
# configure the path to php.ini
PHPIniDir "C:/php/php5"
</ifdefine>
Then open command prompt install and install the service:
httpd.exe -k install -n Apache_php5 -D php5
Refresh the services list, then there will be one named ‘Apache_php5′.
Test it by using:
<?php phpinfo() ?>
in info.php file.
Browse to your localhost url:
localhost/info.php
You can find the two services at C:\Apache24\bin
Then open ApacheMonitor.exe.
That is it, you will have 2 versions of PHP installed that you can switch between. Just stop 1 service and start the other.
Pervious tutorials:
Setup your own Apache MariaDB PHP phpMyAdmin on Windows!
Posted on Utopian.io - Rewarding Open Source Contributors
Hey @jinzo I am @utopian-io. I have just upvoted you!
Achievements
Suggestions
Get Noticed!
Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!
Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x
Thanks for tutorial.
That was a great contribution
Thank you for the contribution. It has been approved.
You can contact us on Discord.
[utopian-moderator]
@OriginalWorks
The @OriginalWorks bot has determined this post by @jinzo to be original material and upvoted it!
To call @OriginalWorks, simply reply to any post with @originalworks or !originalworks in your message!
This post has received a 10.16 % upvote from @kittybot thanks to: @jinzo.
This post has received a 5.67% upvote from @lovejuice thanks to @jinzo. They love you, so does Aggroed. Please be sure to vote for Witnesses at https://steemit.com/~witnesses.
This post has received a 1.56 % upvote from @drotto thanks to: @jinzo.
This post has received a 1.46 % upvote, thanks to: @jinzo.
Your Post Has Been Featured on @Resteemable!
Feature any Steemit post using resteemit.com!
How It Works:
1. Take Any Steemit URL
2. Erase
https://
3. Type
re
Get Featured Instantly – Featured Posts are voted every 2.4hrs
Join the Curation Team Here
You got a 0.48% upvote from @upme requested by: @jinzo.
Send at least 1.5 SBD to @upme with a post link in the memo field to receive upvote next round.
To support our activity, please vote for my master @suggeelson, as a STEEM Witness