How to Upgrade PHP 8.1.30 to PHP 8.4.27 NTS on Windows IIS: A Production Guide

How to Upgrade PHP 8.1.30 to PHP 8.4.27 NTS on Windows IIS: A Production Guide

 Introduction

Keeping PHP updated is an important part of application maintenance, security, and performance optimization. Organizations running PHP applications on Windows Server with Internet Information Services (IIS) must plan upgrades carefully to avoid application downtime, configuration issues, and compatibility failures.

This article explains how to upgrade from PHP 8.1.30 to PHP 8.4.27 Non-Thread-Safe (NTS), using a 32-bit (x86) build on Windows IIS. It covers installation, configuration, FastCGI integration, verification, production testing, and rollback strategies.

Important: Before deployment, verify the requested PHP patch against the official PHP for Windows archive and confirm that it remains an appropriate security-supported version. Also validate application and extension compatibility.

1. Understanding PHP NTS on IIS

PHP for Windows is available in Thread-Safe (TS) and Non-Thread-Safe (NTS) builds.

  • NTS: Commonly used with IIS FastCGI.
  • TS: Intended for configurations that require thread-safe PHP, including certain Apache module deployments.
  • x86: A 32-bit PHP build that requires compatible extensions and runtime components.
  • x64: A 64-bit build that requires compatible 64-bit extensions and components.

The PHP architecture must be compatible with the Windows environment, IIS worker-process configuration, and native dependencies.

For an IIS application using 32-bit PHP, the application pool may need Enable 32-Bit Applications set to True on a 64-bit Windows Server.

2. Download PHP 8.4.27 NTS x86

Download PHP only from the official PHP for Windows website:

https://windows.php.net/download/

Select the correct release package:

  • Version: PHP 8.4.27
  • Build: Non-Thread-Safe (NTS)
  • Architecture: x86 (32-bit)
  • Package: ZIP

Keep the existing PHP 8.1.30 installation intact during the upgrade. Installing the new version in a separate directory allows administrators to test the new configuration and roll back quickly if required.

Example directory structure:

C:\PHP\
    8.1.30\
        php.exe
        php-cgi.exe
        php.ini
    8.4.27\
        php.exe
        php-cgi.exe
        php.ini

Install the appropriate Microsoft Visual C++ Redistributable x86 runtime if it is not already installed.

3. Back Up the Existing Environment

Before making any production changes, back up the IIS configuration and current PHP configuration.

Run PowerShell as Administrator:

# Back up IIS configuration
& "$env:windir\System32\inetsrv\appcmd.exe" add backup "Before-PHP-8.4.27"
# Back up the existing PHP configuration
Copy-Item "C:\PHP\8.1.30\php.ini" `
  "C:\PHP\8.1.30\php.ini.pre-8.4-backup"

Adjust the paths to match the server's existing installation.

Also record the current FastCGI executable path, PHP handler mappings, environment variables, application-pool settings, and enabled PHP extensions. A configuration backup is useful only if the administrator understands how to restore the relevant settings.

4. Install and Configure PHP 8.4.27

Extract the downloaded ZIP file to:

C:\PHP\8.4.27

Copy php.ini-production to php.ini, then configure the new installation.

Example configuration:

extension_dir = "C:\PHP\8.4.27\ext"

date.timezone = "Asia/Kolkata"

log_errors = On
display_errors = Off

error_log = "C:\PHP\8.4.27\php-errors.log"

upload_max_filesize = 20M
post_max_size = 25M
memory_limit = 256M

These settings are examples. Retain the existing application's required settings after reviewing their compatibility with PHP 8.4.

Enable only the required extensions, such as mysqli, pdo_mysql, curl, mbstring, openssl, fileinfo, gd, intl, or zip, as appropriate for the application. Confirm that each extension matches the PHP version, x86 architecture, NTS build, and compiler runtime.

Avoid copying the old php.ini over the new configuration without reviewing obsolete directives, changed defaults, and extension compatibility.

5. Verify the PHP Installation

Before modifying IIS, validate the new PHP installation from PowerShell:

$php = "C:\PHP\8.4.27\php.exe"

& $php -v
& $php --ini
& $php -m

Check the version, loaded configuration file, and installed extensions.

For PHP script syntax validation:

& $php -l "C:\inetpub\wwwroot\your-site\index.php"

Replace the example path with the actual application entry point.

Resolve missing DLLs, configuration errors, and extension-loading warnings before moving to the IIS configuration stage.

6. Configure IIS FastCGI

IIS commonly executes PHP through FastCGI using php-cgi.exe.

Open IIS Manager (inetmgr) and select the server node.

Add the new FastCGI application

  1. Open FastCGI Settings.
  2. Add a new application.
  3. Set the executable to: C:\PHP\8.4.27\php-cgi.exe
  4. Configure the PHPRC environment variable as: C:\PHP\8.4.27
  5. Save the configuration.

If FastCGI Settings is unavailable, check whether the IIS CGI role service is installed.

Update the PHP handler mapping

At the appropriate website or server configuration level, add or update the PHP handler mapping.

Review inherited handler mappings carefully to avoid conflicts. Retain the old PHP 8.1 handler information until the new version has been tested successfully.

7. Check Application Pool and File Permissions

Verify the IIS application pool configuration.

For a 32-bit PHP build running on 64-bit Windows, confirm that Enable 32-Bit Applications is enabled for the relevant application pool.

Check permissions for the application-pool identity:

  • Read and execute access to PHP binaries and required DLLs.
  • Read access to the PHP configuration file.
  • Write access only to necessary upload, cache, session, or log directories.
  • Restricted access to configuration files and sensitive application data.

Do not grant broad write permissions to the entire PHP installation or website directory.

8. Test the Application After the Upgrade

After updating the FastCGI configuration and recycling the relevant application pool, verify the application through its normal HTTPS address.

A temporary diagnostic script can confirm which PHP runtime is serving requests:

<?php
header('Content-Type: text/plain');

echo 'PHP_VERSION=' . PHP_VERSION . PHP_EOL;
echo 'PHP_INT_SIZE=' . PHP_INT_SIZE . PHP_EOL;
echo 'PHP_SAPI=' . PHP_SAPI . PHP_EOL;
echo 'PHP_INI=' . php_ini_loaded_file() . PHP_EOL;

For the requested deployment, expected output includes:

PHP_VERSION=8.4.27
PHP_INT_SIZE=4
PHP_SAPI=cgi-fcgi
PHP_INI=C:\PHP\8.4.27\php.ini

The PHP_INT_SIZE value of 4 indicates a 32-bit PHP integer environment. The SAPI and configuration path help confirm that IIS is using the intended installation.

Remove the diagnostic file immediately after testing. Never leave diagnostic scripts or unrestricted phpinfo() output publicly accessible in production.

9. Perform Functional and Regression Testing

A successful PHP version check does not prove that the application is fully compatible.

Validate the application's critical workflows, including:

  • User login, authentication, and session management.
  • Database connections, queries, and transactions.
  • File uploads, downloads, and document processing.
  • Email delivery and scheduled tasks.
  • REST API integrations and outbound HTTPS requests.
  • Payment workflows, where applicable.
  • Error handling, logging, and background processes.

Review PHP error logs, IIS logs, and Windows Event Viewer for startup errors, HTTP 500 responses, missing extensions, deprecated functionality, and unexpected behavior.

Run load or smoke tests appropriate to the application before completing production acceptance.

10. Rollback Strategy

A production upgrade must include a tested rollback procedure.

If PHP 8.4 causes application errors:

  1. Restore the previous PHP 8.1 FastCGI executable path.
  2. Restore the original PHP handler mapping.
  3. Restore the previous PHPRC setting and relevant environment variables.
  4. Recycle the affected application pool.
  5. Verify the application's critical workflows.
  6. Review logs to identify the reason for the failed upgrade.

Keep the previous PHP installation and configuration unchanged until the new version has passed the agreed observation period.

An IIS configuration backup can be restored with:

& "$env:windir\System32\inetsrv\appcmd.exe" `
  restore backup "Before-PHP-8.4.27"

Use a full IIS restore only when necessary because it can revert unrelated IIS configuration changes made after the backup. Restoring only the affected PHP settings is generally safer.

11. Production Deployment Checklist

Before closing the change request, confirm that:

  • The PHP package and architecture have been verified.
  • The current PHP and IIS configurations have been backed up.
  • PHP 8.4 configuration and required extensions have been validated.
  • FastCGI and handler mappings point to the intended executable.
  • Application-pool architecture and permissions are correct.
  • Critical application workflows pass regression tests.
  • Logs contain no unresolved critical errors.
  • Temporary diagnostic files have been removed.
  • The rollback procedure has been documented and tested.
  • The selected PHP patch is appropriate for the organization's security requirements.

Conclusion

Upgrading PHP on Windows IIS is more than replacing a PHP executable. A reliable production upgrade requires compatible binaries, correct FastCGI configuration, validated extensions, functional testing, monitoring, and a clear rollback strategy.

By installing PHP 8.4.27 NTS x86 alongside PHP 8.1.30 and switching IIS only after validation, administrators can reduce deployment risk and maintain service continuity.

The same principles apply to other runtime upgrades: preserve the existing environment, validate compatibility, deploy incrementally, monitor the application, and retain a practical recovery path.

Official resources

  • PHP for Windows downloads: https://windows.php.net/download/
  • PHP manual: https://www.php.net/manual/en/
  • IIS FastCGI configuration: https://learn.microsoft.com/en-us/iis/configuration/system.webserver/fastcgi/
  • Microsoft Visual C++ Redistributable: https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist

Post a Comment

0 Comments