Home ยป How to set up PHP and MySQL on Internet Information Services (IIS) in a Windows environment

How to set up PHP and MySQL on Internet Information Services (IIS) in a Windows environment

0 comment 106 views

Here’s a step-by-step guide on how to set up PHP and MySQL on Internet Information Services (IIS) in a Windows environment:

Step 1: Install IIS

  1. Open the Control Panel on your Windows server.
  2. Go to “Programs” or “Programs and Features”.
  3. Click on “Turn Windows features on or off”.
  4. Scroll down and locate “Internet Information Services (IIS)” and expand it.
  5. Check the boxes next to “Web Management Tools” and “World Wide Web Services” to enable IIS.
  6. Click “OK” to install IIS.

Step 2: Install PHP

  1. Download the latest stable version of PHP from the official PHP website (https://www.php.net/downloads.php) for Windows, and choose the version that matches your server’s architecture (x86 or x64).
  2. Extract the downloaded PHP archive to a folder of your choice, for example, “C:\PHP”.
  3. Open the extracted PHP folder and locate the “php.ini-production” file. Rename it to “php.ini”.
  4. Open the “php.ini” file in a text editor and configure it according to your needs. For example, you may need to set the “extension_dir” parameter to the directory where you extracted the PHP extensions.
  5. Save and close the “php.ini” file.

Step 3: Configure IIS to Use PHP

  1. Open the Internet Information Services (IIS) Manager from the Start menu.
  2. In the left-hand pane, expand the server name, and then expand “Sites”.
  3. Select the website where you want to enable PHP.
  4. In the right-hand pane, double-click on “Handler Mappings”.
  5. In the Actions pane, click “Add Module Mapping”.
  6. In the “Request path” field, enter “*.php”.
  7. In the “Module” field, choose “FastCgiModule” from the drop-down list.
  8. In the “Executable” field, click on the “…” button and browse to the “php-cgi.exe” file in the PHP installation folder (e.g., “C:\PHP\php-cgi.exe”).
  9. Click “OK” to save the module mapping.

Step 4: Test PHP

  1. Create a new PHP file in the web directory of your website (e.g., “C:\inetpub\wwwroot”) and name it “phpinfo.php”.
  2. Open the “phpinfo.php” file in a text editor and add the following PHP code: “<?php phpinfo(); ?>”.
  3. Save and close the “phpinfo.php” file.
  4. Open a web browser and enter the URL of the PHP file in the address bar (e.g., “http://localhost/phpinfo.php“).
  5. If everything is set up correctly, you should see the PHP information page displaying information about your PHP installation.

Step 5: Install MySQL

  1. Download the MySQL installer from the official MySQL website (https://dev.mysql.com/downloads/windows/installer/) for Windows.
  2. Run the MySQL installer and choose the “Custom” installation option.
  3. Select the MySQL products and features that you want to install, and click “Next”.
  4. Choose the installation type (e.g., “Server Only”) and click “Next”.
  5. Configure the MySQL server options according to your needs, and click “Next”.
  6. Set a root password for the MySQL server and click “Next”.
  7. Choose the MySQL server authentication method (e.g., “Use Legacy Authentication Method (Retain MySQL 5.x Compatibility)”) and click “Next”.
  8. Choose the MySQL server port (e.g., “3306”) and click “Next”.

Leave a Comment