To install PHP on Windows Server 2022, follow these steps:

Step 1: Download PHP

  1. Go to the PHP for Windows website.
  2. Download the latest version of PHP. Choose the “Non-thread safe” version for IIS.

Step 2: Extract PHP

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

Step 3: Configure PHP

  1. Rename php.ini-development to php.ini.
  2. Open php.ini in a text editor and configure the necessary settings:
    • Set the extension_dir directive to point to the ext directory within your PHP installation, e.g., extension_dir = "C:\php\ext".
    • Enable required extensions by uncommenting lines (remove the ; at the start of the line) for extensions you need, such as:
      ini

      Copy
      extension=mysqli
      extension=gd
      extension=mbstring

Step 4: Add PHP to System Path

  1. Right-click on “This PC” and select “Properties.”
  2. Click on “Advanced system settings.”
  3. Click on the “Environment Variables” button.
  4. Under “System variables,” find and select the Path variable, then click “Edit.”
  5. Add the path to your PHP installation (e.g., C:\php) and click “OK.”

Step 5: Install IIS (if not already installed)

  1. Open Server Manager.
  2. Click on “Add roles and features.”
  3. Follow the wizard to install the Web Server (IIS) role.

Step 6: Configure IIS to Use PHP

  1. Open IIS Manager.
  2. Select your server in the left panel.
  3. In the middle panel, double-click on “Handler Mappings.”
  4. Click on “Add Module Mapping” in the right panel.
    • Request path: *.php
    • Module: FastCgiModule
    • Executable: C:\php\php-cgi.exe
    • Name: PHP_via_FastCGI
  5. Click “OK” and confirm any prompts.

Step 7: Test PHP Installation

  1. Create a new file named info.php in your web server’s root directory (e.g., C:\inetpub\wwwroot\info.php).
  2. Add the following code to info.php:
    php

    Copy
    <?php phpinfo(); ?>
  3. Open a web browser and navigate to http://localhost/info.php. You should see the PHP information page.

Step 8: Restart IIS

  1. Open Command Prompt as Administrator.
  2. Run the command:
    bash

    Copy
    iisreset

Conclusion

You have successfully installed PHP on Windows Server 2022. You can now start developing and hosting PHP applications. In the next article I will show an easier way to install PHP.

Hope you find this helpful. Comment are welcome.

Installing PHP on Windows Server 2022 – Manual Way

You May Also Like