106
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
- Open the Control Panel on your Windows server.
- Go to “Programs” or “Programs and Features”.
- Click on “Turn Windows features on or off”.
- Scroll down and locate “Internet Information Services (IIS)” and expand it.
- Check the boxes next to “Web Management Tools” and “World Wide Web Services” to enable IIS.
- Click “OK” to install IIS.
Step 2: Install PHP
- 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).
- Extract the downloaded PHP archive to a folder of your choice, for example, “C:\PHP”.
- Open the extracted PHP folder and locate the “php.ini-production” file. Rename it to “php.ini”.
- 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.
- Save and close the “php.ini” file.
Step 3: Configure IIS to Use PHP
- Open the Internet Information Services (IIS) Manager from the Start menu.
- In the left-hand pane, expand the server name, and then expand “Sites”.
- Select the website where you want to enable PHP.
- In the right-hand pane, double-click on “Handler Mappings”.
- In the Actions pane, click “Add Module Mapping”.
- In the “Request path” field, enter “*.php”.
- In the “Module” field, choose “FastCgiModule” from the drop-down list.
- 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”).
- Click “OK” to save the module mapping.
Step 4: Test PHP
- Create a new PHP file in the web directory of your website (e.g., “C:\inetpub\wwwroot”) and name it “phpinfo.php”.
- Open the “phpinfo.php” file in a text editor and add the following PHP code: “<?php phpinfo(); ?>”.
- Save and close the “phpinfo.php” file.
- Open a web browser and enter the URL of the PHP file in the address bar (e.g., “http://localhost/phpinfo.php“).
- If everything is set up correctly, you should see the PHP information page displaying information about your PHP installation.
Step 5: Install MySQL
- Download the MySQL installer from the official MySQL website (https://dev.mysql.com/downloads/windows/installer/) for Windows.
- Run the MySQL installer and choose the “Custom” installation option.
- Select the MySQL products and features that you want to install, and click “Next”.
- Choose the installation type (e.g., “Server Only”) and click “Next”.
- Configure the MySQL server options according to your needs, and click “Next”.
- Set a root password for the MySQL server and click “Next”.
- Choose the MySQL server authentication method (e.g., “Use Legacy Authentication Method (Retain MySQL 5.x Compatibility)”) and click “Next”.
- Choose the MySQL server port (e.g., “3306”) and click “Next”.