Current Location: Home> Latest Articles> IIS Server PHP Environment Configuration Complete Guide

IIS Server PHP Environment Configuration Complete Guide

gitbox 2025-06-24

Introduction to IIS

IIS (Internet Information Services) is a powerful web server developed by Microsoft, providing a stable and reliable environment to host websites and various applications. With proper configuration, IIS can seamlessly integrate with scripting languages such as PHP, expanding development flexibility and capabilities.

PHP Installation

Before configuring IIS to support PHP, you need to properly install PHP. Here is the detailed installation process:

Step 1: Download PHP

Visit the official PHP website and download the PHP package suitable for your server version.

Step 2: Extract and Configure Environment Variables

Extract the downloaded PHP archive to a directory such as C:\PHP, and add this directory to your system environment variables so the system can recognize PHP commands.

setx PATH "%PATH%;C:\PHP"

Configure PHP in IIS

After PHP is installed, configure IIS accordingly to enable PHP support.

Step 1: Enable CGI Feature

Open IIS Manager, select your target site, go to “Handler Mappings,” and make sure the CGI feature is enabled. This step is critical for the server to process PHP requests.

Step 2: Add PHP Handler Mapping

Click “Add Module Mapping” in “Handler Mappings” and fill in the following:

  • Module: FastCgiModule
  • Executable: C:\PHP\php-cgi.exe
  • Name: PHP_via_FastCGI

Step 3: Configure PHP Parameters

Use the site’s “Configuration Editor” to adjust PHP-related settings such as maximum upload file size and default timezone. Here are some common php.ini configuration examples:

upload_max_filesize = 10M
post_max_size = 10M
date.timezone = "Asia/Shanghai"

Test PHP Configuration

Once configured, create a test PHP file to verify if the environment works properly. Create info.php in your website root directory with the following content:

<?php
phpinfo();
?>

Visit this file (e.g., http://yourdomain.com/info.php). If you see the PHP info page, the IIS and PHP configuration was successful.

Summary

By following these steps, you can set up a fully functional PHP environment on an IIS server. Regular maintenance and updates of the configuration will help ensure your website’s security and stability. Hopefully, this article helps you complete the IIS and PHP integration smoothly.