How to get WordPress and PHP to work with IIS

IIS

 

How to Get WordPress and PHP to Work with IIS

Running WordPress on Internet Information Services (IIS) can offer high performance and scalability for Windows-based servers. While Apache is the traditional choice for WordPress, IIS can provide an excellent alternative for hosting WordPress with PHP. This guide will show you how to set up WordPress and PHP on IIS step-by-step, complete with detailed instructions and examples.

Prerequisites

  • A Windows Server with IIS installed.
  • Administrative access to the server.
  • Basic knowledge of IIS and server configuration.

Step 1: Install IIS

If IIS is not already installed, follow these steps to set it up:

  1. Open the Server Manager and click on Manage > Add Roles and Features.
  2. Choose Role-based or feature-based installation and click Next.
  3. Select your server and click Next.
  4. Under Server Roles, select Web Server (IIS) and click Next.
  5. Under Features, select additional features if needed and click Next.
  6. Click Install to complete the installation.

Step 2: Install PHP

PHP is required for WordPress. Follow these steps to install PHP on IIS:

  1. Download the latest non-thread-safe version of PHP from the PHP for Windows website.
  2. Extract the PHP files to a directory, e.g., C:\PHP.
  3. Open the IIS Manager and select your server in the left-hand Connections pane.
  4. Double-click on Handler Mappings, then click Add Module Mapping.
  5. Configure the module mapping:
    • Request Path: *.php
    • Module: FastCgiModule
    • Executable: Path to php-cgi.exe (e.g., C:\PHP\php-cgi.exe).
    • Name: PHP via FastCGI
  6. Click OK and confirm adding the mapping.

Step 3: Configure FastCGI for PHP

FastCGI improves PHP performance on IIS. Configure it as follows:

  1. In IIS Manager, double-click FastCGI Settings.
  2. Select the entry for php-cgi.exe and click Edit.
  3. Set the Activity Timeout and Request Timeout to appropriate values, e.g., 300 seconds.
  4. Click Environment Variables and add:
    • Name: PHP_FCGI_MAX_REQUESTS
    • Value: 10000
  5. Click OK to save the changes.

Step 4: Download and Configure WordPress

Install WordPress by following these steps:

  1. Download the latest version of WordPress from the official WordPress website.
  2. Extract the WordPress files to the root directory of your website, e.g., C:\inetpub\wwwroot\wordpress.
  3. Set the necessary file permissions to allow IIS to read and write files.

Step 5: Configure MySQL Database

WordPress requires a MySQL database:

  1. Install MySQL Server if not already installed.
  2. Create a new database and user for WordPress. Use the following SQL commands:
    
    CREATE DATABASE wordpress;
    CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'securepassword';
    GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';
    FLUSH PRIVILEGES;
                    

Step 6: Update wp-config.php

Configure the database settings in the wp-config.php file:


define('DB_NAME', 'wordpress');
define('DB_USER', 'wordpressuser');
define('DB_PASSWORD', 'securepassword');
define('DB_HOST', 'localhost');
        

Step 7: Set Up Pretty Permalinks

Enable pretty permalinks by adding URL Rewrite rules:

  1. In IIS Manager, double-click URL Rewrite.
  2. Click Add Rules and select Blank Rule.
  3. Create rules to mimic .htaccess functionality. Example:
    <code class="language-xml">
    <rule name="WordPress Permalinks">
    <match url="^(.*)$" />
    <conditions>
    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    </conditions>
    <action type="Rewrite" url="/index.php" />
    </rule>
    </code>

Step 8: Test Your WordPress Site

Open a browser and navigate to your site (e.g., http://yoursite). Complete the WordPress installation process by providing site details and database credentials.


By following these steps, you can successfully configure WordPress and PHP to work with IIS. This setup ensures a robust and scalable platform for hosting your WordPress site on Windows servers. Remember to monitor and maintain your IIS server regularly for optimal performance.


©2025 ServerTools.site
Please disable your adblocker or whitelist this site!