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:
- Install IIS:
- Open the “Control Panel”, select “Programs”, and click on “Enable or disable Windows features”.
- Check the box next to “Web Management Tools”, “World Wide Web Services”, and “ISAPI Extensions” under “Internet Information Services”.
- Click on “OK” to proceed with the installation.
- Installing PHP:
- Download the Windows version of PHP, for example, from the official website php.net.
- 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”.
- Rename the “php.ini-development” file to “php.ini” in the PHP directory.
- 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). - Set up IIS.
- Open the “Control Panel”, choose “System and Security”, click on “Administrative Tools”, and open “Internet Information Services (IIS) Manager”.
- In the tree menu on the left, expand the server name, right-click on “Website”, and select “Add Website”.
- 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”).
- In the “Binding” tab, select the IP address and port number (default is 80).
- Click “OK” to finish configuring the website.
- Install MySQL.
- Download the Windows version of MySQL, for example, from the official website mysql.com.
- Run the installation program, follow the instructions to install MySQL, and set the password for the root user.
- Set up MySQL
- Open the “my.ini” file under the MySQL installation directory.
- Locate the section “[mysqld]” and add a line “default-character-set=utf8”.
- Locate the “[client]” section and add a line “default-character-set=utf8”.
- Save and close the “my.ini” file.
- Login to MySQL by entering “mysql -u root -p” in the Windows command prompt.
- Enter the password of the root user to access the MySQL command line interface.
- 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. - Test environment:
- Create a test file in the website directory of IIS, for example “C:\inetpub\wwwroot\test.php”.
- Enter the following content in the “test.php” file to test:
- 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.