In this tutorial I will be going over how to upgrade the PHP build on a local Windows 10 machine running IIS 10. If you’re looking for how to setup a local PHP environment on a Window machine, you may be interested in this post. After the environment is setup, unless it already comes with PHP 7.1, you can come back to this post to learn how to upgrade PHP.
My current setup at the time of this tutorial is as follows:
- Windows 10
- IIS Version 10.0.1.14393.0
- PHP Version 7.0.9
The goal is to upgrade PHP from 7.0 to 7.1. First place you’ll want to go is, http://windows.php.net/download#php-7.1 . This is where you can download PHP that will work on Microsoft Windows. Because I need to use SQLSRV drivers since the database I interact with is a Microsoft SQL database, I need to install the x86 Non-Thread Safe version of PHP. There’s a good chance you may be in a similar situation, else 64-bit thread-safe is the way to go.
Once you downloaded the appropriate PHP build, you’ll want to locate where your computer stores PHP executables. There may already be previous versions already installed. You can find this by looking at “PHP executable” within your PHP Manager. Mine is located under C:\Program Files (x86)\PHP.
Create a new folder and dump the build in there. You’ll want to copy the “ext” folder from the previous version into the new folder. The “ext” folder contains all your .dll files. Once this is created, you’ll want to register the new PHP build within PHP Manager.
With this new build, migrate manually your custom changes in the php.ini file from the previous PHP build you were using to the new one. Migrate only your custom settings. Don’t blanket copy and paste everything open. For example:
- short_open_tag = On
Notice the SQLSRV drivers. You’ll need to upgrade those so that they work with PHP 7.1. You can download the drivers at Microsoft’s msphpsql Github. At the time of this post, SQLSRV 4.3.0 is the latest stable version and comes in PHP 7.0 and PHP 7.1 compatible flavors. Obviously, you’ll want the PHP 7.1 version and drop them into the “ext” folder where you have PHP 7.1 stored.
What is odd is that you may receive an error such as “PHP Startup: Unable to load dynamic library ‘C:\Program Files (x86)\PHP\v7.1\ext\php_mysql.dll’ – The specified module could not be found This is because PHP 7.1 doesn’t come with the mysql .dll file but somehow the makers of PHP didn’t exclude it in the default PHP 7.1 php.ini file? For me, since I’m using MS SQL through the SQLSRV drivers, I just comment out the following line in php.ini.
If you have WinCacheGrind, you’ll need to update that to a build that is compatible with PHP 7.1. Grab the NTS x86 version of WinCache for PHP 7.1.
Extract and throw it in the “ext” folder of the current PHP build. If you’re lazy, just rename the .dll file to what is registered in your php.ini.