Update PHP Version in IIS

Step 1: Check the Current PHP Version

  1. Open a Command Prompt and run:

php -v

  1. Alternatively, create a phpinfo.php file in the web root (C:\inetpub\wwwroot\):

<?php phpinfo(); ?>

Access it via http://localhost/phpinfo.php in your browser.

Step 2: Download the Latest PHP Version

  1. Go to the official PHP for Windows site: 🔗 https://windows.php.net/download

  1. Download the latest Non-Thread Safe (NTS) x64 ZIP file (for IIS).

Step 3: Backup the Existing PHP Installation

  1. Navigate to your current PHP installation directory (e.g., C:\PHP or C:\Program Files\PHP).

  2. Create a backup by copying the folder to a safe location.

Step 4: Extract and Configure PHP

  1. Extract the downloaded ZIP file to a new directory, e.g., C:\PHP8.

  2. Copy the php.ini-development file and rename it to php.ini.

  3. Open php.ini and configure necessary settings like extension_dir:

extension_dir = "C:\PHP8\ext"

  1. Update any required extensions by uncommenting lines (remove ;):

extension=curl
extension=gd
extension=mbstring
extension=mysqli

Step 5: Update IIS to Use the New PHP Version

Option 1: Update in IIS Manager

  1. Open IIS Manager (inetmgr).

  2. Go to Handler Mappings.

  3. Find *.php, and double-click it.

  4. Change the Executable Path to the new PHP location (C:\PHP8\php-cgi.exe).

  5. Click OK, then restart IIS.

Option 2: Update FastCGI in fcgi Settings

  1. Open Command Prompt as Administrator.

  2. Run the following command to update FastCGI settings:

C:\Windows\System32\inetsrv\appcmd set config /section:system.webServer/fastCgi /+[fullPath='C:\PHP8\php-cgi.exe']

Step 6: Update System PATH Variable

  1. Open System PropertiesAdvancedEnvironment Variables.

  2. In System Variables, find Path and edit it.

  3. Replace the old PHP path with the new one (C:\PHP8).

  4. Click OK and restart the server.

Step 7: Restart IIS and Verify

  1. Restart IIS:

iisreset
  1. Run:

php -v

Or refresh http://localhost/phpinfo.php to confirm the new version.


REFERENCES

Last updated

Was this helpful?