Setting up an environment with Windows, IIS, PHP, and MySQL.

To set up an IIS+PHP+MySQL environment on Windows, you can follow these steps:

  1. Install IIS:
  2. Open the “Control Panel”, select “Programs”, and click on “Enable or disable Windows features”.
  3. Check the box next to “Web Management Tools”, “World Wide Web Services”, and “ISAPI Extensions” under “Internet Information Services”.
  4. Click on “OK” to proceed with the installation.
  5. Installing PHP:
  6. Download the Windows version of PHP, for example, from the official website php.net.
  7. Extract the downloaded PHP compressed file and move the extracted folder to the directory of IIS, for example move it to “C:\inetpub\wwwroot\php”.
  8. Rename the “php.ini-development” file to “php.ini” in the PHP directory.
  9. Edit the “php.ini” file and modify the following configurations:

    Change “;extension_dir = “ext”” to “extension_dir = “C:\inetpub\wwwroot\php\ext””.
    Change “;cgi.force_redirect = 1” to “cgi.force_redirect = 0”.
    Change “;cgi.fix_pathinfo=1” to “cgi.fix_pathinfo=0”.
    Change “;date.timezone = ” to “date.timezone = Asia/Shanghai” (or modify according to your time zone).

  10. Set up IIS.
  11. Open the “Control Panel”, choose “System and Security”, click on “Administrative Tools”, and open “Internet Information Services (IIS) Manager”.
  12. In the tree menu on the left, expand the server name, right-click on “Website”, and select “Add Website”.
  13. In the “Add Website” dialogue box, enter the website name and set the physical path to the folder where PHP is located (such as “C:\inetpub\wwwroot\php”).
  14. In the “Binding” tab, select the IP address and port number (default is 80).
  15. Click “OK” to finish configuring the website.
  16. Install MySQL.
  17. Download the Windows version of MySQL, for example, from the official website mysql.com.
  18. Run the installation program, follow the instructions to install MySQL, and set the password for the root user.
  19. Set up MySQL
  20. Open the “my.ini” file under the MySQL installation directory.
  21. Locate the section “[mysqld]” and add a line “default-character-set=utf8”.
  22. Locate the “[client]” section and add a line “default-character-set=utf8”.
  23. Save and close the “my.ini” file.
  24. Login to MySQL by entering “mysql -u root -p” in the Windows command prompt.
  25. Enter the password of the root user to access the MySQL command line interface.
  26. To create a new database, run the following command: CREATE DATABASE example;
    Grant all privileges on the ‘example’ database to ‘username’@’localhost’ with the password ‘password’;
    Flush privileges.
  27. Test environment:
  28. Create a test file in the website directory of IIS, for example “C:\inetpub\wwwroot\test.php”.
  29. Enter the following content in the “test.php” file to test:

  30. Access the test file by typing “http://localhost/test.php” into the web browser to ensure that both PHP and MySQL are functioning correctly.

In this way, the configuration of setting up IIS+PHP+MySQL environment on Windows is completed.

bannerAds