IT Nota

  • Home
  • How To
  • .NET
  • WordPress
  • Contact

How to Upgrade to PHP 7.2 on IIS (Windows 10)

This tutorial is a shorter version of the previous post upgrading to PHP 7.1 on Windows 10 and it is intended as a follow-up on how to upgrade your PHP to the latest version (in this case PHP 7.2) if you have already installed the previous version of PHP 7 in your Windows system.

Steps to Upgrade from PHP 7.1 to PHP 7.2

  1. Download PHP for Windows. Since we’re using PHP as FastCGI, we’ll use the 64-bit Non-Thread Safe (NTS) version (i.e., php-7.2.1-nts-Win32-VC15-x64.zip).

  2. PHP 7.2 is also the first version that requires Visual C++ Redistributable for Visual Studio 2017. If you don’t have it installed, you can download it from here (64-bit). If you have a 32-bit OS, please check on the download section below and select the one for x86.

  3. We also need to upgrade our WinCache version for PHP 7.2. Download the WinCache php_wincache-2.0.0.8-7.2-nts-vc15-x64 and extract the file as well.

    WinCache Binary for PHP 7.2

  4. Extract both downloaded zip files (just double-click them and they will be extracted into their sub-folders) as shown below:

    PHP 7.2 and WinCache zip files extracted to sub-folders

  5. If you check the WinCache folder php_wincache-2.0.0.8-7.2-nts-vc15-x64, look for two files with the following names: php_wincache.dll and php_wincache.pdb.

  6. Copy the two files from the WinCache folder to a sub-folder (“ext”) within the PHP folder (i.e., php-7.2.1-nts-Win32-VC15-x64/ext).

    Copy php_wincache files from WinCache folder to ext sub-folder under PHP folder

  7. Now, copy the whole content of php_wincache-2.0.0.8-7.2-nts-vc15-x64 folder into a new folder and name it v7.2.

    Copy all PHP files to a new folder v7.2

  8. Copy the php.ini file from v7.1 to v7.2.

  9. You might want to modify certain parameters in the php.ini as highlighted below:

    [WebPIChanges]
    error_log=C:\WINDOWS\temp\PHP72x64_errors.log
    upload_tmp_dir=C:\WINDOWS\temp
    session.save_path=C:\WINDOWS\temp
    cgi.force_redirect=0
    cgi.fix_pathinfo=1
    fastcgi.impersonate=1
    fastcgi.logging=0
    max_execution_time=300
    date.timezone=Australia/Melbourne
    extension_dir="C:\Program Files\PHP\v7.2\ext\"
    

    And make sure you also have the PHP_WINCACHE set.

    [PHP_WINCACHE]
    extension=php_wincache.dll
    

    The change is pretty simple and we can compare the two php.ini files between v7.1 and v7.2 as below:

    Compare php.ini files between v7.1 and v7.2

  10. Open IIS Manager and click on FastCGI Settings.

    IIS Manager FastCGI Settings

  11. You can create a new entry for PHP 7.2 by following Step 8 from previous post, except for PHPRC where you want to update the value to 7.2 (i.e., C:\Program Files\PHP\v7.2).

    Once completed, just click OK.

    IIS Manager FastCGI Settings Modify PHPRC to version 7.2

  12. Go back to IIS Manager and click on Handler Mappings.

    IIS Manager Handler Mappings

  13. Look for PHP_via_FastCGI and double-click on it. Make sure the path for the Executable is updated accordingly. Click OK when done.

    IIS Manager Handler Mappings PHP_via_FastCGI set to v7.2

Update Windows Environment Variables

Finally, once again we need to update the path of the new PHP in Windows Environment Variables.

  1. Click on the Windows start button and type in “system” and click on System Control panel.

    Windows System Control Panel

  2. In System window, click on Advanced system settings and on System Properties window, make sure you have Advanced tab opened. And you can follow the path shown in the picture to update the path to where your PHP 7.2 is located.

    Control Panel System Environment Variables Update to PHP 7.2

  3. Click on Environment Variables… button.

  4. Under System Variables, click on Path and Edit… button.

  5. Click on where the current PHP is located and double-click it or click on Edit button.

  6. Change the value to the location of the new PHP (i.e., C:\Program Files\PHP\v7.2)

  7. Click OK button on each window to close.

That’s it! Now using the same test.php file with the following code:

<?php phpinfo(); ?>

Run it from your browser (i.e., http://localhost/test.php). If PHP is installed with the correct version, you will see the PHP version will be updated similar to the picture below:

phpinfo 7.2.1 displayed on a page

Further Reading

How to Install PHP on Windows 10 Using Web Platform Installer
FastCGI
Difference between PHP thread safe and non thread safe binaries
Using FastCGI to Host PHP Applications on IIS 7
WinCache Extension for PHP

Download

Download PHP For Windows: Binaries and sources Releases
WinCache 2.0.0.8 PHP Extension Direct Download
Microsoft Visual C++ Redistributable for Visual Studio 2017

January 19, 2018 Filed Under: How To Tagged With: IIS, Internet Information Services, Microsoft, PHP, Windows, Windows 10

How to Upgrade to PHP 7.1 on Windows 10

This setup should only be used as PHP development environment on Windows as it has not been tested on production.

If you followed the steps from the previous post on PHP installation on Windows using Web Platform Installer, you will now have PHP 7.0 to do your web development.

The problem using Web Platform Installer (WPI) is that most likely you won’t be using the latest version of PHP (at the time of this writing, it’s 7.0.15 and 7.1.1 and WPI only gives you version 7.0.9).

Fortunately, if you want to upgrade to the latest version, you can do it manually in a few simple steps described below.

Before we start, please keep in mind that this installation is for a local PHP server on IIS, not Apache web server.

Steps to Upgrade PHP to 7.1

  1. Open Control Panel, click on Programs and Features, and then Turn Windows features on or off. Under Internet Information Services, World Wide Web Services, Application Development Features, make sure that option CGI is checked. This enables both the CGI and FastCGI services, which is recommended for PHP applications.

    Control Panel CGI

  2. Download PHP for Windows. Since we’re using PHP as FastCGI, we’ll use the 64-bit Non-Thread Safe (NTS) version (i.e., php-7.1.1-nts-Win32-VC14-x64.zip).

  3. Extract file php-7.1.1-nts-Win32-VC14-x64.zip to its own folder.

  4. Copy your current PHP7 installation from v7.0 and rename the copy to v7.1.

    Copy original PHP 7.0 to 7.1 folder

  5. Copy all files from the PHP7 zip folder (Step 3) to the new renamed v7.1 folder (Step 4).

  6. Edit the php.ini (C:\Program Files\PHP\v7.1\php.ini) to reflect the new version (7.1) under [WebPIChanges] as shown below (see highlighted changes):

    [WebPIChanges]
    error_log=C:\WINDOWS\temp\PHP71x64_errors.log
    upload_tmp_dir=C:\WINDOWS\temp
    session.save_path=C:\WINDOWS\temp
    cgi.force_redirect=0
    cgi.fix_pathinfo=1
    fastcgi.impersonate=1
    fastcgi.logging=0
    max_execution_time=300
    date.timezone=Australia/Melbourne
    extension_dir="C:\Program Files\PHP\v7.1\ext\"
    
    [ExtensionList]
    ;extension=php_mysql.dll
    extension=php_mysqli.dll
    extension=php_mbstring.dll
    extension=php_gd2.dll
    extension=php_gettext.dll
    extension=php_curl.dll
    extension=php_exif.dll
    extension=php_xmlrpc.dll
    extension=php_openssl.dll
    extension=php_soap.dll
    extension=php_pdo_mysql.dll
    extension=php_pdo_sqlite.dll
    extension=php_imap.dll
    extension=php_tidy.dll
    
    [PHP_WINCACHE]
    extension=php_wincache.dll
    

    php.ini File Update

    Please note the change in line 1857. Although it’s not related to PHP upgrade, you need to double check that the extension=php_mysql.dll is either commented out or deleted.

    MySQL extension was deprecated on PHP version 5.5 and removed on version 7. If it’s not excluded, you’ll see the following error:

    PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\Program Files\PHP\v7.1\ext\php_mysql.dll' - The specified module could not be found.
    
    in Unknown on line 0
    

    Line 1872-1873 are for WinCache setting. Just make sure it’s there or else you will also encounter an error.

  7. Open IIS Manager and click on FastCGI Settings.

    IIS Manager FastCGI Settings

  8. Double-click on the PHP 7.0 settings and copy all the property values including the Environment Variables (PHP_FCGI_MAX_REQUESTS, PHPRC) and Advanced Settings. We’re just going to reuse all the values from the existing installation instead of starting from scratch.

    Click Cancel button after you’re done.

    IIS Manager FastCGI Properties

    EnvironmentVariables PHP_FCGI_MAX_REQUESTS Properties

    EnvironmentVariables PHPRC Properties

  9. Now from FastCGI Settings window, click on Add Application… on the Actions pane on the right.

    IIS Manager FastCGI Settings Add Application

  10. Type in C:\Program Files\PHP\v7.1\php-cgi.exe on the Full Path box.

  11. Enter all values you copied from Step 8, except for PHPRC where you want to update the value to 7.1 (i.e., C:\Program Files\PHP\v7.1).

    Once completed, just click OK.

  12. Go back to IIS Manager and click on Handler Mappings.

    IIS Manager Handler Mappings

  13. Look for PHP_via_FastCGI and double-click on it.

    IIS Manager PHP_via_FastCGI

  14. Locate the new php-cgi.exe and change the value on the Executable (optional): accordingly. Click Yes when there’s a dialog box asking you to create a FastCGI application for this executable.

    Click OK and exit IIS Manager.

    IIS Manager Handler Mappings PHP FastCGI

Update WinCache Extension for PHP

Once PHP is upgraded to version 7.1 you may run into another issue with your WinCache PHP extension with an error message as follow.

PHP Warning:  PHP Startup: wincache: Unable to initialize module
Module compiled with module API=20151012
PHP    compiled with module API=20160303
These options need to match

in Unknown on line 0

This error was caused by an outdated version of WinCache. PHP 7.1 requires a new WinCache binaries. Look for them in the PECL packages or you can download it directly from this link.

WinCache PHP Extension PECL download

Installation should be straightforward. Just extract the zip file and follow the instructions.

Update Windows Environment Variables

Finally, we need to update the path of the new PHP in Windows Environment Variables.

  1. Click on the Windows start button and type in “system” and click on System Control panel.

    Windows System Control Panel

  2. In System window, click on Advanced system settings and on System Properties window, make sure you have Advanced tab opened. And you can follow the path shown in the picture to complete the rest of the steps.

    Control Panel System Environment Variables

  3. Click on Environment Variables… button.

  4. Under System Variables, click on Path and Edit… button.

  5. Click on where the current PHP is located and double-click it or click on Edit button.

  6. Change the value to the location of the new PHP (i.e., C:\Program Files\PHP\v7.1)

  7. Click OK button on each window to close.

That’s all there is. Now you can test your PHP installation by creating a test.php file with this PHP code.

<?php phpinfo(); ?>

Run it from your browser (i.e., http://localhost/test.php). If PHP is installed with the correct version, you will see something similar to this:

phpinfo 7.1.1

Compared with previous version of PHP installation on Windows:

phpinfo 7.0.9 displayed on a page

Further Reading

How to Install PHP on Windows 10 Using Web Platform Installer
How to Upgrade to PHP 7.2 on IIS (Windows 10)
FastCGI
Difference between PHP thread safe and non thread safe binaries
Using FastCGI to Host PHP Applications on IIS 7
WinCache Extension for PHP

Download

Download PHP For Windows: Binaries and sources Releases
WinCache 2.0.0.8 PHP Extension Direct Download
Microsoft Visual C++ 2015 Redistributable Update 3

January 20, 2017 Filed Under: How To Tagged With: IIS, Internet Information Services, Microsoft, PHP, Windows, Windows 10

How to Install PHP on Windows 10 Using Web Platform Installer

If you need to install a PHP on your local Windows machine with Internet Information Services (IIS), Microsoft has already provided a way where you can do it fairly quickly using WPI.

Keep in mind though, this setup has not been tested for production environment. So only use it as a PHP development environment for Windows.

Steps

  1. Open Control Panel -> Programs and Features -> Turn Windows features on or off. Under Internet Information Services -> World Wide Web Services -> Application Development Features, make sure that option CGI is checked. This enables both the CGI and FastCGI services.

    Control Panel CGI

  2. Download Web Platform Installer. For this example for Windows 10 64-bit, it’s the WebPI 5.0 x64.

  3. Double-click on WebPlatformInstaller_amd64_en-US.msi to install it.

  4. Once installed, you should see a file with the name wpilauncher.exe. Double-click it.

  5. When you see the Window, click on the Products link and search for “php” and press ENTER.

    Web Platform Installer 5.0 Product Search for PHP

  6. Add PHP 7.0.9 (x64) (or later version if available) as an item to install. Selecting this will automatically add Windows Cache Extension and PHP Manager for IIS.

    Web Platform Installer 5.0 PHP Installation

  7. (Optional) If you need to connect to SQL Server using PHP, you need to install Microsoft Drivers 4.0 (x64) for PHP v7.0 for SQL Server in IIS.

  8. Click on Install button.

    Web Platform Installer 5.0 Prerequisites Agreement

The downside of this installation is probably WPI may have a mind on its own and install other components that you didn’t choose as shown below:

Web Platform Installer 5.0 Installation Summary

If you see a failed installation for PHP Manager for IIS like above, don’t worry about it. That component is only used to provide a GUI for managing PHP from IIS. You can still use the command line and text editor to make configuration changes.

As always you can always test your PHP installation by creating a test.php file with this PHP code.

<?php phpinfo(); ?>

And run it from your browser (i.e., http://localhost/test.php). If PHP is installed correctly, you will see something similar to this:

phpinfo 7.0.9 displayed on a page

You may notice that the version of PHP installed using WPI is usually several versions behind the release version. Fortunately, you can always download PHP for Windows yourself and upgrade your PHP installation on Windows to a newer version with just a few additional steps explained on this post.

Further Reading

How to Upgrade to PHP 7.1 on Windows 10
How to Upgrade from PHP 7.1 to PHP 7.2 on IIS (Windows 10)
How to Activate Built-in Web Server
FastCGI
Using FastCGI to Host PHP Applications on IIS 7

Download

Web Platform Installer Direct Downloads

December 30, 2016 Filed Under: How To Tagged With: IIS, Internet Information Services, Microsoft, PHP, Windows, Windows 10

How to Fix PHP7 Compatibility Issue with W3 Total Cache

With the advent of PHP 7, a few webhosts such as SiteGround have made it available on all their shared hosting services and you can find a way to enable it here.

Before you jump the bandwagon though, be aware of the warning they posted on their website:

Please have in mind that even if you’re using an app that supports PHP 7 some of its components like plugins, themes, modules, etc. may have old code that will not work on the latest version. This is why we advise that you always test on a staging environment before you enable it on your live site.

You’ll run into a compatibility issue right away if you use one of the WordPress plugins, W3 Total Cache (W3TC). Right after upgrading to PHP 7, I saw this message on the bottom of every page of my WordPress blog:

Warning: Parameter 1 to W3_Plugin_TotalCache::ob_callback() expected to be a reference, value given in WP_PATH/wp-includes/functions.php on line 3297

Actually this error message is misleading, because the real issue is not in functions.php file on line 3297. Instead, you need to go to W3 Total Cache directory within your WordPress installation under wp-content folder and look for a file called TotalCache.php.

The whole path would be:
WP_PATH\wp-content\plugins\w3-total-cache\lib\W3\Plugin\TotalCache.php

Look for line 512 (highlighted):

    /**
     * Output buffering callback
     *
     * @param string $buffer
     * @return string
     */
    function ob_callback(&$buffer) {
        global $wpdb;

Remove the ampersand “&” from the code as the following:

    function ob_callback($buffer) {
        global $wpdb;

Here’s the before and after comparison:
W3 TotalCache.php modification for PHP7 compatibility

Once you’re done changing the code, just clear all the caching and reload your page. This time the error message should disappear.

Update for PHP 7.0.9

With the release of PHP 7.0.9, some people have already encountered more issues with this W3 Total Cache plugin after upgrading.

Typical error messages:

Warning: Parameter 1 to W3_Plugin_Minify::ob_callback() expected to be a reference, value given in /wp-content/plugins/w3-total-cache/inc/functions/plugin.php on line 23
Warning: Parameter 1 to W3_Plugin_Cdn::ob_callback() expected to be a reference, value given in /wp-content/plugins/w3-total-cache/inc/functions/plugin.php on line 23
Warning: Parameter 1 to W3_PgCache::ob_callback() expected to be a reference, value given in /wp-content/plugins/w3-total-cache/inc/functions/plugin.php on line 23
Warning: Parameter 1 to W3_Plugin_Minify::ob_callback() expected to be a reference, value given in /wp-content/plugins/w3-total-cache/inc/functions/plugin.php on line 23
Warning: Parameter 1 to W3_Plugin_Cdn::ob_callback() expected to be a reference, value given in /wp-content/plugins/w3-total-cache/inc/functions/plugin.php on line 23
Warning: Parameter 1 to W3_PgCache::ob_callback() expected to be a reference, value given in /wp-content/plugins/w3-total-cache/inc/functions/plugin.php on line 23
Warning: Parameter 1 to W3_Plugin_Minify::ob_callback() expected to be a reference, value given in /wp-content/plugins/w3-total-cache/inc/functions/plugin.php on line 23
Warning: Parameter 1 to W3_Plugin_Cdn::ob_callback() expected to be a reference, value given in /wp-content/plugins/w3-total-cache/inc/functions/plugin.php on line 23
Warning: Parameter 1 to W3_PgCache::ob_callback() expected to be a reference, value given in /wp-content/plugins/w3-total-cache/inc/functions/plugin.php on line 23

Fortunately someone from WordPress forum has already posted a good solution. I personally have not tested this, but at least others have had success implementing the fix.

Just to sum up, you basically need to change make the same code modification as above, but to more files.

If you use Git, you can easily find all these files by running this command:

$ git grep -e 'ob_callback(&$buffer)' -n

W3 Total Cache ob_callback

And it should list all the filenames you need to update.

WP_PATH\wp-content\plugins\w3-total-cache\lib\W3\PgCache.php
WP_PATH\wp-content\plugins\w3-total-cache\lib\W3\Plugin\BrowserCache.php
WP_PATH\wp-content\plugins\w3-total-cache\lib\W3\Plugin\Cdn.php
WP_PATH\wp-content\plugins\w3-total-cache\lib\W3\Plugin\Minify.php
WP_PATH\wp-content\plugins\w3-total-cache\lib\W3\Plugin\NewRelic.php
WP_PATH\wp-content\plugins\w3-total-cache\lib\W3\Plugin\TotalCache.php // *

* You will only see the last file if you haven’t fixed it from the earlier instruction above.

Update each file so that all occurrences of ob_callback(&$buffer) are replaced with ob_callback($buffer).

Finally, it’s worth repeating, backup before you do anything.

If you rather not deal with all these operations yourself, you may want to use some of the fixes and customization like this one (use at your own risk).

References

Modern PHP: New Features and Good Practices
Learning PHP 7: A Pain-Free Introduction to Building Interactive Web Sites
PHP for the Web: Visual QuickStart Guide (5th Edition)
Fixing Warning on HHVM
W3 Total Cache and PHP 7.0.9
Fix and customize W3 Total Cache

December 22, 2015 Filed Under: WordPress Tagged With: PHP

How to Change WordPress Upload Folder

If you do a fresh install using WordPress 3.5 or later, you may have noticed that one useful feature that’s sorely missing is the ability to change the default upload directory from the Administration page.

WordPress Old Media Settings (Administration Dashboard)

Not sure why it was taken out in the first place, fortunately there’s still a way to do it without too much trouble.

You just need to add the following code in the wp-config.php file:

// Change default upload directory to '/myimages'
define( 'UPLOADS', 'myimages' );

The example above is based on the assumption that you want your upload directory in a sub-folder called ‘/myimages’ at the root of your WordPress installation. If you prefer to do it within your wp-content folder, make sure you include the path in the prefix:

// Change default upload directory to '/wp-content/myimages'
define( 'UPLOADS', 'wp-content/myimages' );

Note: The above code needs to be added before the last section of wp-config.php that says:

/** Sets up WordPress vars and included files. */
require_once( ABSPATH . 'wp-settings.php' );

Further Reading

Editing wp-config.php: Moving Upload Folders

February 17, 2014 Filed Under: WordPress Tagged With: PHP

Next Page »
Buy me a coffee Support this site
Buy Me a Coffee?

Categories

  • .NET
  • Coding
  • Cybersecurity
  • Database
  • How To
  • Internet
  • Multimedia
  • Photography
  • Programming
  • Resources
  • Review
  • Tips and Tricks
  • Uncategorized
  • Use Case
  • WordPress
  • Writing

Recent Posts

  • How to View Stored Procedure Code in SQL Server
  • How to Find a String in SQL Server Stored Procedures
  • How to Remove Cached Credentials without Rebooting Windows
  • ESP Work Automation: Empowering Enterprises with Streamlined Workflows and Operational Efficiency
  • How to Search for a String in All Tables in a Database

Recent Posts

  • How to View Stored Procedure Code in SQL Server
  • How to Find a String in SQL Server Stored Procedures
  • How to Remove Cached Credentials without Rebooting Windows
  • ESP Work Automation: Empowering Enterprises with Streamlined Workflows and Operational Efficiency
  • How to Search for a String in All Tables in a Database

Tags

.NET .NET Core AdSense ASP.NET Cdonts Dll Classic ASP Code Editor ETL FSharp Genesis Framework Git Google HP Asset Manager HTML5 Hugo IIS Information Security Internet Internet Information Services iOS JAMStack Linux macOS Microsoft Microsoft SQL Server MVC PHP PowerShell Python Simple Mail Transfer Protocol Smtp Server SQL SQL Server SSIS SSMS SSRS Sublime Text Visual Studio Visual Studio Code VPN Windows Windows 8 Windows 10 Windows 2012 Windows Server

Copyright © 2011-2025 IT Nota. All rights reserved. Terms of Use | Privacy Policy | Disclosure