This article is about how to update your PHP version on Windows, specifically when using EasyPHP dev server. For the average developer, this can be a daunting process, but it’s really not that hard.
My reason for posting this article is that EasyPHP server has stuck any upgrade components behind a paywall, or ‘warehouse’ as they call it, which costs $10/year, which seems crazy when it’s so easy to do yourself.
This guide should work for other servers running on windows as well, you’ll just need to modify certain steps depending on how your specific set up is configured.
Before we start, there are a few things worth mentioning. During this process, I will be upgrading from PHP 5.5.8 to 5.6.16 which are both VC11 builds, so I could be sure I had the Visual C++ Redistributable for Visual Studio 2012 x86 or x64 installed, so there wouldn’t be any problems there. If you’re upgrading from an older version that uses VC9 it might be easier to reinstall EasyPHP.
This is what the admin screen looks like with the old (5.5.8) version installed:
and this is the output of phpinfo();
with 5.5.8:
Step 1: Download and extract PHP
The first thing you’ll need to do is download the latest PHP zip package from the official PHP website, specifically I’ll be downloading the thread safe x86 version, as noted on their website “With Apache you have to use the Thread Safe (TS) versions of PHP”:
Once that is downloaded, you should unzip it to the place where you PHP binaries are located, but in a new folder, named ‘php_5.6.16
‘ or ‘php_new
‘. On my set up, this as under C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\binaries\php
where there is a single folder called php_runningversion
:
Step 2: Shut down EasyPHP, Apache and MySQL
This is as simple as right clicking in on the EasyPHP icon in the taskbar and clicking ‘Stop’.
However, if you’ve installed Apache and MySQL as windows services, this may not work for you, permissions depending. If this is the case, go ahead and hit windows+r
, type services.msc
and the windows services dialogue should pop up:
On this big list, you’ll see Apache and MySQL. Go ahead and right click on each, and hit stop.
Step 3: Change configuration settings
Now you’ll want to take your old php.ini
file and incorporate any settings in there into a new php.ini
file with any new configuration settings needed by your new version of PHP.
This is needed, because new versions of PHP might have new configuration settings, or new recommended settings, so you should take any configurations from your old settings and apply them to the new php.ini
file instead of just using the old one in place.
This is made much easier by using a DIFF tool, which are available for download, or just as easy, you can use an online version, such as https://www.diffchecker.com/.
For EasyPHP, you’ll notice these lines at the top of the php.ini file located in php_runningversion
:
;------------------------ IMPORTANT ! ---------------------- ; This file is GENERATED by EasyPHP when needed so edit the ; file C:\PROGRA~2\EASYPH~1.1VC\binaries\conf_files\php.ini if you want to do ; modifications in this file ;-----------------------------------------------------------
Aha, so we need to instead find the file located at C:\PROGRA~2\EASYPH~1.1VC\binaries\conf_files\php.ini
and edit that instead.
The new php.ini
file that comes with PHP can be found in the php_new
directory we set up earlier, usually named php.ini-development
or something similar.
Once you have copied over all the specific needed configuration settings from your old php.ini file, go ahead and rename the old file in C:\PROGRA~2\EASYPH~1.1VC\binaries\conf_files\php.ini
to php.ini-old
and save your new file there as php.ini.
Step 4: Drop the new PHP in old PHP’s place
This step is fairly simple – you can now rename php_runningversion
to php_old
or php_5.5.8
and the rename the new php folder to php_runningversion
.
You should also go ahead and copy any extension files/folders and certificates from the old folder to the new folder. In my example, I had a few extensions in the ext folder I needed to copy over, as well as a certificate in the root folder (the .crt and .pem files) and some files relating to xdebug.
Of course, you can always just disable these, if you no longer need them, or don’t want them, by editing your php.ini
file.
Once you’ve done this, you should have a folder set up like this:
Step 5: Restart EasyPHP, Apache, MySQL
Once you’ve done all this, follow the reverse of Step 2 to restart EasyPHP, Apache and MySQL – you can right click on the taskbar icon at the bottom and click start, or again go into services.msc and start the services manually.
Once you’ve done this, the new PHP version should appear in your phpinfo();
and EasyPHP administration screens:
and our new phpinfo output:
Et voilá!
You should also verify that PHP is looking for the right version on the command line by typing php -v
on the command line (you have added it to your PATH, right?)