SoFunction
Updated on 2025-04-09

Text tutorial on installing PHP running environment on Windows system

1. Download related software

Software Download Address
httpd-2.2.15-win32-x86-no_ssl.msi /
mysql-5.1. /downloads/
php-5.2. /
phpMyAdmin-3.3. /home_page/
ZendOptimizer-3.3. /en/downloads/
Create a folder called lamp on the C drive of Windows system, as the installation location of the web environment, and install all the software required by the environment into this folder.

2. Install Apache

1 The "Set System Information" dialog box requires input of several basic configuration parameters. These three pieces of information can be filled in at will, and it is also possible if it is invalid.
Enter the domain name "" in the first input box.
In the second input box, add the server name.
The third one to add is the contact email address, which will be provided to visitors when a system fails.
It is the email address of this web server administrator, enter lampteacher@ here.
Finally, you need to select the port of the web server, use the default port 80, and automatically start as a system service (first item).
2 A dialog box for selecting installation type pops up, "Typical" is the default installation, and "Custom" is the user-defined installation. We select the "Typical" type here.
3 The Select Installation Location dialog box pops up, and set the location of Apache installation to "d:\lamp\apache2".
4 A confirmation installation dialog box pops up. If you need to check again, you can click the "<Back" button to go back to the check step by step. To ensure that the options are correct, click "Install" to start installing according to the installation options set earlier.
5 The installation interface is popped up, and the installation wizard is successfully completed. At this time, the green small icon management tool of Apache should appear in the status bar in the lower right corner, indicating that the Apache service has started running.
6 After Apache is installed according to the above steps, its installation directory is specified under "C:\lamp\apache2".
The configuration file of Apache is "C:\lamp\apache2\conf\" file.
The place where Apache stores web pages is the "C:\lamp\apache2\htdocs" folder.
7 There are many ways to start and stop Apache in Windows system, and the following examples can be done.
Click Start Menu -> All Programs -> Apache HTTP Server 2.2 -> Control Stop, Start, or Restart Restart under Apache Server.
Click My Computer -> Administration -> Services and Applications -> Services -> Apache2.2 option and click Stop, Turn on or Restart.
Use the small green icon management tool in Apache on the status bar in the lower right corner of the Windows system to enable, stop or restart the Apache server.
8 If Apache is successfully launched, it can pass the browser test. Open the browser and enter the URL of http://localhost/ in the address bar.
You can see It works! This means that Apache is installed successfully and is ready to use.

3. Install MySQL
Installing the MySQL database server can be divided into two parts:
Part is the installation of the program; the other part is the creation of MySQL configuration files, some detailed configuration choices, and setting a password for the MySQL server.
The MySQL configuration assistant is automatically run after the first part is installed, and can also be manually started after the MySQL installation is completed.
1 Install the file "mysql-5.1."
2 The installation type selection dialog box pops up, with three options, namely, typical installation (Typical), complete installation (Complete) and user-defined (Custom).
Select "Custom" here to get more options to facilitate us to specify the installation location. Click the "Next>" button to go to the next step of installation.
3. The user custom settings page pops up, and click the left button on the "Developer Components" option.
Then select the second item "This feature, and all subfeatures, will be installed on local hard drive."
That is, "this part, and the sub-part contents are all installed on the local hard disk."
4 Specify the installation location. Click the "Change..." button to change the installation location and specify it to the "C:\lamp\mysql5" folder.
Not only does this option need to change the installation location, the first few options include MySQL Server option (MySQL Server),
MySQL client program options (Client Programs) and file options (Documentation) all need to change the installation location, and the operations are the same.
Click the "Change..." button to manually change the installation location. You can point the installation location of these options to the "C:\lamp\mysql5" folder.
It is recommended that the "MySQL Server Datafiles" option do not specify the server data file under the same partition as the operating system. This prevents the data from being cleared during system backup and restore.
Here you specify it to the D:\datafiles\ folder. After the settings are completed, click the "Next>" button to go to the next step of installation.
5 The installation location confirmation dialog box pops up, and you need to wait for a few seconds to install. At this point, the MySQL database software is installed and the interface appears.
Check "Configure the MySQL Server now", click the "Finish" button to end the software installation and start the MySQL Configuration Wizard.
6 Then automatically run the MySQL configuration assistant and arrive at the second part of the installation MySQL configuration stage.
7 The configuration type selection dialog box pops up, with two options "Detailed Configuration" and "Standard Configuration". Select the first item "Detailed Configuration".
The next few steps of configuration are some things that the MySQL configuration assistant needs to set when selecting this item. After selecting the type, click the "Next>" button to continue with the next configuration.
8 The Server Type selection dialog box pops up, which determines how much main memory the MySQL server will try to retain. The larger the main memory, the faster the server will be, but the greater the impact on other programs.
Here are three options:
The Developer Machine option is a development test class, and MySQL consumes very little resources;
Server Machine options are server type, and MySQL occupies more resources;
The Dedicated MySQL Server Machine option is a dedicated database server, and MySQL takes up all available resources.
Choose different types, for web developers, the first Developer option is the best choice, and the other two are best for large databases. After selecting the type, click the "Next>" button to continue with the next configuration.
9 The Database Usage dialog box pops up. They determine which data table types MySQL server will support.
There are three options here:
The "Multifunctional Database" option is a universal multifunctional type, a better type, and the default selected type;
The "Transactional Database Only" option is the server type, focusing on transaction processing;
The "Non-Transactional Database Only" option is non-transactional and relatively simple, mainly for monitoring and counting.
Users can change according to the actual purpose of the database. We use the default selection here and click the "Next>" button to continue with the next configuration.
10 The InnoDB Tablespace Setting dialog box pops up, and you should specify a storage location for the InnoDB database file here. The default storage location is the MySQL installation directory.
Here, use the default storage location, click the "Next>" button to continue with the next configuration.
11 The Concurrent Connections selection dialog box pops up. The options here determine the number of database connections that are opened simultaneously.
There are three options in total:
The first "Decision Support (DSS)/OLAP" option can have 20 connections;
The second "Online Transaction Processing (OLTP)" option can have 500 connections;
The third "Manual Setting" option manually sets a connection number.
For MySQL server running on a computer for software development, there is no need for too many connections. At this time, you should be fine to choose the first "Decision Support (DSS)/OLAP".
However, for MySQL servers working at full speed on some popular websites, the number of concurrent connections may be very large. At this time, you should choose the second "Online Transaction Processing (OLTP)" option.
Use the default first option here, click the "Next>" button to continue with the next configuration.
12 A dialog box to activate the TCP/IP networking function (Enable TCP/IP Networking) pops up. In the Windows system environment, there are two ways for MySQL server to communicate with applications:
First, through named pipe;
The second is to pass the network protocol TCP/IP.
The recommended configuration given by the MySQL Configuration Assistant is to activate TCP/IP and use port 3306. Select the multi-check box (adding a firewall does not block this port) and use the default recommended configuration. Click the "Next>" button to continue with the next configuration.
13 The Default Character Set dialog box pops up. When saving text data to the database, MySQL supports various existing character sets.
Here we select the third item. In order to better handle the Chinese character set, select or fill in "utf8" in the Character Set, and click the "Next>" button to continue with the next configuration.
14 The Install as Windows Service dialog box pops up. Here you can choose whether to install MySQL service as a Windows system service.
This way, the MySQL server can be managed through Windows system service management. You can also specify the Service Name (service ID name).
Another option is to choose whether to add the MySQL bin directory to Windows PATH (after adding, you can directly use the files in the bin directory without specifying the directory name). (Please select)
Here we accept the default settings recommended by the MySQL configuration assistant, click the "Next>" button to continue with the next configuration.
15 The Security Options dialog box pops up. This is the most important configuration, and it takes a decision to allow who can connect to the MySQL server and whether a password must be entered to establish the connection.
Set as the safest setting, because root is the only user and the MySQL system administrator user, so the root user should be allowed to enter the password correctly to connect to the database, and only allow him to log in locally.
Don't check the second option. No anonymous account is created here. The so-called anonymous account refers to an account that can be connected to the database without a password. Click the "Next>" button to continue with the next configuration.
16 A confirmation execution dialog box pops up. Confirm that the configuration settings are correct. If there is any error, click the "<Back" button to return to the check. If you confirm that it is correct, click "Execute" to make the settings take effect, and click the "Finish" button to end the installation and configuration of MySQL.
17 After MySQL installation environment, after the installation and configuration are completed according to the above steps, the installation directory of MySQl is below "C:\lamp\mysql5\";
The MySQL configuration file is the "C:\lamp\mysql5\" file; the MySQL data file is stored in the "D:\datafiles\data" folder.
18 Start and stop MySQL in Windows system, right-click the My Computer->Management->Services and Applications->Services->MySQL options, and click Stop, Turn on or Restart.
19 To test whether the MySQL database installation is successful, you can open a MySQL client to log in to the MySQL server for testing.
Use the Start Menu -> All Programs -> MySQL -> MySQL Server 5.1 -> MySQL Command Line Client to start the command line interpreter program for MySQL.
Then enter the password you entered when configuring MySQL. If everything goes well, you should see the MySQL input prompt in the input window. Next, execute the status command, and the result indicates that the MySQL server is successfully installed.

Solution:
Problems and solutions that arise when installing MYSQL: When installing MySQL, the system prompts: Cannot create windows service for :0
The reason is that there is an old mysql service in the system. The solution is as follows:
To permanently delete the old mysql service, the user needs to execute the following command on the command line with administrative permissions:
C:\>sc delete mysql
[SC] DeleteService SUCCESS
When installing the service, if similar situations occur, check whether there are legacy service programs in the service. Solution: After deleting the old service, install the new service.

3. Install PHP
When installing a PHP server, there are two tasks that must be completed.
PHP is a module of the Apache server and needs to be plugged into Apache to assist it in processing PHP files. Therefore, the first task is to load the PHP module in Apache.
During development, you also need to use PHP programs to connect to the database and operate on the database, so the second task is to configure PHP's MySQL extension interface.
(1) Install PHP as an extension module of the Apache server.
Step 1: File of "php-5.2." Just unzip the content of this ZIP document into a selected subdirectory, and we will decompress it to the "C:\lamp\php5" directory here.
Step 2: Load PHP into Apache in module form.
The loading method is to write three lines of content in the Apache configuration file: the first line loads the PHP module;
The second line tells the Apache server that the file with the suffix name is .php or other suffix name is used to parse it with PHP; the third line specifies the location of the PHP configuration file.
Here we just insert the following three lines into a certain location in the Apache configuration file C:\lamp\apache2\conf\.

LoadModule php5_module "C:/lamp/php5/php5apache2_2.dll" #LoadPHP module
AddType application/x-httpd-php .php .phtml # Which suffix file is parsed by PHP module?
PHPIniDir "C:/lamp/php5" #Specify the location of the PHP configuration file
Notice:
The first line refers to loading PHP 5 in module mode, inserting this line into the line "#LoadModule vhost_alias_module modules/mod_vhost_alias.so" in the Apache configuration file. Where C:/lamp/php5/php5apache2_2.dll is the file under the corresponding path to install PHP. Be careful not to confuse php5apache2_2.dll, it is only applicable to versions before Apache 2.0. The PHP 5 compression package only applies to versions of apache2.0.*. If it is version 2.2.* or above, you must use php5apache2_2.dll. Otherwise, some loading errors may occur.
The second line is to add PHP support. Tell Apache to parse suffixes as PHP. For example, let Apache parse files with .php or .phtml suffixes to PHP. Find the "AddType application/x-gzip .gz .tgz" item in the Apache configuration file, and add the "Addtype application/x-httpd-php .php .phtml" line below it. You can parse any suffix file into PHP, just add it to the added statement and separate it with spaces. Here is an example of adding one more .phtml.
The third line is to specify the location of the PHP configuration file. Just add it under the second line "Addtype application/x-httpd-php .php .phtml", where "C:/lamp/php5" specifies the previously selected PHP decompressed directory.

Step 3: Create PHP configuration file. Just change the -recommended file in the PHP decompressed directory C:/lamp/php5 to the name.
You can also rename the file -dist in the C:/lamp/php5 directory, but the configuration file automatically adds "//" to all added contents, which increases security and also increases troubles; if -recommended is renamed, the configuration file does not add "//" to the added contents, which reduces security, but is more convenient. Here, rename the -recommended file to a file.
Step 4: Restart the Apache server. As long as the Apache configuration file or PHP configuration file is changed, the Apache server should be restarted. The Apache server loads the configuration file at startup to make the content of the configuration file change take effect.
As a working module of the Apache server, PHP also loads configuration files when Apache starts to make the modified content take effect.
Step 5: Test whether the PHP installation is successful. The above steps have installed PHP as an extension module of Apache and started with the Apache server.
If you want to check whether PHP is installed successfully, you can use a text editor to create a file named C:\lamp\apache2\htdocs in the Apache server's web page folder C:\lamp\apache2\htdocs

<?php //PHP script start tag
phpinfo();//PHP internal function, used to print PHP status information
?> //PHP script end tag

Then use a web browser to open the http://localhost/ page. A PHP test page appears to indicate that the PHP installation is successful.
(2) Configure the MySQL extension interface of PHP
Step 1: After the above configuration, PHP5 has been installed successfully. However, PHP cannot access the MySQL database server yet, so PHP must find two MySQL-related DLL files installed with PHP.
Before this, first copy the files under PHP installation directory C:\lamp\php5\ to the Windows installation directory.
This directory is usually C:\Windows, and some Windows server versions are C:\Winnt directory. You can also set the environment variables of the Windows system and add the PHP decompression directory C:\lamp\php5\ to the PATH environment variable.
Here we copy the C:\lamp\php5\ file to C:\Windows.
Step 2: Turn on the MySQL function in the PHP configuration file. Use a text editor to open PHP's configuration file C:\lamp\php5\.
Insert the following three items to enable the mysql and mysqli extension interfaces. You can also find the following three lines in the PHP configuration file and remove the previous semicolon for comments.

extension_dir="c:/lamp/php5/ext" #Specify the extension interface directory of PHP, the directory separator is "/"
extension=php_mysql.dll #Enable MySQL extension interface
extension=php_mysqli.dll #Enable MySQLi extension interface

Step 3: Restart the Apache server and the modifications made using the PHP configuration file take effect.
Step 4: Check the contents in the PHP test page and check whether there is any description information about the mysql and mysqli interface parameters. If you see the information shown in Figure 2-46, it means that the PHP's mysql and mysqli extension interfaces are loaded successfully, open the web browser and visit the http://localhost/ page for testing.
After the above configuration, we have completed the configuration of PHP's MySQL and MySQLi extension interfaces. The same method is also the same if we need to configure other extension interfaces.

4. Install Zend accelerator
Step 1: File of "ZendOptimizer-3.3." This is directly an installation file, and you can start the installation program by double-clicking.
Step 2: Through the installation of the previous step, the following interface appears, confirm that you agree to the software installation and use license regulations, select "I accept the terms in the license agreement", and click the "Next>" button to continue.
Step 3: A dialog box for selecting installation location pops up. Here you can select the location you like. Here we set the location of Zend Optimizer installation to "C:\lamp\ZendOptimizer\" and click the "Next>" button to continue the installation.
Step 4: The following screen to select the type of web server pops up and select options. Click the "Next>" button to continue the installation.
Step 5: The Select PHP Profile Location dialog box pops up. When installing PHP, we will specify the PHP installation directory C:\lamp\php5\, so the location selected here is also the C:\lamp\php5 folder.
Step 6: The following dialog box for selecting the root directory of the website pops up, and selecting the root directory path of the website content. When installing Apache, we specify the root directory of the website to the installation directory of Apache C:\lamp\apache2\ below.
So the location selected here is also the C:\lamp\apache2\ folder, click the "Next>" button to continue the installation.
Step 7: A confirmation installation dialog box pops up. If you need to check again, you can click the "<Back" button to go back to the check step by step to ensure that the options are correct, and click the "Install" button to start the installation option set before to start the installation.
Step 8: If the following prompt pops up, first close the web server, and then click the "OK" button to continue the installation.
Step 9: If all installation is smooth, the end installation dialog box below will pop up. Click the "Finish" button to end the installation. The installation is complete.
Step 10: Check the installation results. Start the Apache server, open the web browser to visit the http://localhost/ page, and test it through the phpinfo() function. If the following content appears, the installation is successful.
This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
with Zend Extension Manager v1.2.0, Copyright (c) 2003-2007, by Zend Technologies
with Zend Optimizer v3.3.3, Copyright (c) 1998-2007, by Zend Technologies

Installation
Step 1: Unzip phpMyAdmin-3.3. to /apache2/htdocs/, and create a folder called phpmyadmin, put the compressed file in and install it.
Step 2: Configure the top-level directory of phpMyAdmin. There is no file by default. We need to create one manually, or copy the template to get the minimum configuration file.
The following example is to provide only the part that must be modified. According to the actual situation, some other options may be needed to modify it.
Through the requirements of the authentication mode, there can be two configuration solutions, one is the HTTP and cookie authentication mode.
In both modes, users must first enter the valid username and password of the MySQL database in a login window before using the phpMyAdmin program.
This approach has two obvious benefits: First, because the password of the MySQL database does not appear in the file, the authentication process is more secure;
Secondly, you allow logging in as different users to manage your own database. These two authentication modes are especially suitable for multiple user accounts in the database.
The second solution is config authentication mode. In this mode, the password is saved in the file in plain text. Just write the MySQL username and password directly to the file.
In this way, when logging in to phpMyAdmin, you will not prompt for username and password, but will only log in directly with the user written in the file.
This pattern can be used if you are just using phpMyAdmin on a local test system.
(1) HTTP authentication mode
If you want phpMyAdmin to use HTTP authentication mode, you need to make the following modifications in the bold part of the file. The specific content is as follows:
$cfg['Servers'][$i]['auth_type'] = 'http' ; //Only modify this line to HTTP authentication mode
After completing the settings, when we start phpMyAdmin, a web browser dialog box will pop up on the screen. You need to enter the MySQL username and password in this dialog box to enter the phpMyAdmin operation interface. In the Windows client, use IE browser to access the files in the phpMyAdmin directory of the web server, that is, phpMyAdmin is started.
(2) Cookie authentication mode
Cookie authentication mode is a complement to HTTP authentication mode. It can be used in cases where HTTP authentication mode cannot be used. Cookie authentication mode requires that users must allow cookies from phpMyAdmin to enter their computer. That is, the user needs to enable the client's cookie function in the browser.
If you want phpMyAdmin to use cookie authentication mode, in addition to modifying the auth_type statement in the file, you must also provide a string to the blowfish_secret parameter. This string can be arbitrary, and the purpose is to encrypt the user and password used when logging in before storing them on the cookies on the client computer. The modified contents are as follows:
$cfg['blowfish_secret'] = ''xxxxxx''; //Arbitrary string is needed here
$cfg['Servers'][$i]['auth_type'] = 'cookie'; // This is modified to cookie authentication mode
Just like the way to start phpMyAdmin above, we use IE browser on the Windows client to access the files in the phpMyAdmin directory on the web server, and we need to provide the MySQL username and password to log in.
(3) config authentication mode
If you want phpMyAdmin to use config authentication mode, you need to make the following modifications in the file. Write the user name and password of the MySQL database in plain text, and the specific modifications are as follows:
$cfg['Servers'][$i]['auth_type'] = 'config' ; // This is modified to config authentication mode
$cfg['Servers'][$i]['user'] = 'root'; //Use your MySQL database username
$cfg['Servers'][$i]['password'] = '111111'; //Use your MySQL database password
Just like the way to start phpMyAdmin above, we use IE browser on the Windows client to access the files in the phpMyAdmin directory on the web server. However, you can log in without providing the MySQL username and password. It is logged in in plain text.

Note: phpmyadmin needs lowercase