Install PHP running environment text tutorial on Windows

Source: Internet
Author: User
Tags http authentication php server php template mysql command line windows server versions

1. Download related software

Software
Httpd-2.2.15-win32-x86-no_ssl.msi http://httpd.apache.org/download.cgi
Mysql-5.1.46-win32.msi http://dev.mysql.com/downloads/
Php-5.2.13-Win32.zip http://www.php.net/downloads.php
PhpMyAdmin-3.3.3-all-languages.zip http://www.phpmyadmin.net/home_page/downloads.php
ZendOptimizer-3.3.3-Windows-i386.exe http://www.zend.com/en/downloads/
Create a folder named lamp on drive C of Windows system as the Web environment installation location and install all the software required by the environment under this folder.

Ii. install Apache

1. In the "set system information" dialog box, enter several basic configuration parameters. All three information can be entered at will, and invalid information can also be entered.
Enter the "lampbrother.net" domain name in the first input box.
Add www.lampbrother.net server name to the second input box.
The third thing to add is the contact email address, which will be provided to visitors when the system fails,
Is the email address of this Web server administrator, enter the lampteacher@gmail.com here.
Finally, select the Web server port, use the default port 80, and use it as the system service to automatically start (item 1 ).
2. The Select installation type dialog box is displayed. "Typical" is the default installation, and "Custom" is the Custom installation. Here we select "Typical.
3. In the Select installation location dialog box, set the Apache installation location to "d: \ lamp \ apache2.
4. The confirm installation dialog box is displayed. If you need to check again, you can click the "<Back" button to return to the check step by step. Make sure that the options are correct. Click "Install" to start installation according to the preceding setup options.
5. The installation page is displayed. The installation wizard is successful. The green icon management tool of Apache appears 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 preceding steps, its installation directory is specified under "C: \ lamp \ apache2.
The Apache configuration file is the "C: \ lamp \ apache2 \ conf \ httpd. conf" file,
Apache stores the webpage in the "C: \ lamp \ apache2 \ htdocs" folder.
7. There are multiple ways to start and stop Apache in Windows, which can be done in the following example.
Choose Start> All Programs> Apache HTTP Server 2.2> Control Stop, Start, or Restart under Apache Server.
Choose my computer> Manage> services and applications> services> Apache2.2, and click STOP, enable, or restart.
Enable, stop, or restart the Apache server by using the green icon management tool on the status bar in the lower-right corner of Windows.
8. If Apache is successfully started, you can test it in a browser. Open the browser and enter the http: // localhost/URL in the address bar,
You can see It works! This indicates that Apache is successfully installed and can be used.

Iii. Install MySQL
Installing the MySQL database server can be divided into two parts:
One part is the installation of the program; the other part is the use of the MySQL configuration assistant to create the MySQL configuration file, some detailed configuration options, and set a password for the MySQL server.
The MySQL configuration assistant runs automatically after the first part is installed. It can also be started manually after the MySQL installation is complete.
1 install the mysql-5.1.46-win32.msi file.
2. The installation type selection dialog box is displayed. There are three options: Typical installation (Typical), Complete installation (Complete), and Custom (Custom.
Select "m" here to get more options so that we can specify the installation location. Click "Next>" to go to the Next step.
3. The custom settings page is displayed. On the "Developer Components" option, click the left button,
Then select the second item "This feature, and all subfeatures, will be installed on local hard drive .",
That is, "This part and its sub-parts are all installed on the local hard disk ".
4. Specify the installation location. Click Change ..." Click to change the installation location and specify to the "C: \ lamp \ mysql5" folder.
Not only does this option need to change the installation location, but the preceding options include the MySQL Server option (MySQL Server ),
The installation location of Client Programs and Documentation must be changed, and the operations are the same.
Click 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 of the Server data file not be specified in the same partition as the operating system. This prevents data from being cleared during system backup and restoration.
Specify it to the D: \ datafiles \ folder. After the settings are complete, click "Next>" to go to the Next step for installation.
5. The installation confirmation dialog box is displayed. It takes several seconds to install it. Here, the MySQL database software is installed. The interface is displayed,
Select "Configure the MySQL Server now" and click "Finish" to complete software installation and start the MySQL Configuration Wizard.
6. Then, the MySQL configuration assistant is automatically run, and the second part of MySQL configuration is installed.
7. The Configuration type selection dialog box is displayed. There are two options: "Detailed Configuration" and "Standard Configuration )". Select the first item "Detailed Configuration ".
When this option is selected in the subsequent steps, the MySQL configuration assistant needs to set some content. After selecting the type, click "Next>" to continue the configuration.
8. The Server Type selection dialog box is displayed, which determines how much primary memory the MySQL Server will try to retain. The larger the main memory, the faster the server, but the greater the impact on other programs.
There are three options:
The Developer Machine option is a development test class. MySQL occupies a small amount of resources;
The Server Machine option is a Server type, and MySQL occupies a large amount of resources;
The Dedicated MySQL Server Machine option is a Dedicated database Server. MySQL occupies all available resources.
Select different types. For Web developers, the first Developer option is the best choice, and the other two are the most suitable for big databases. After selecting the type, click "Next>" to continue the configuration.
9. The Database Usage dialog box is displayed. They determine which data table types the MySQL server will support.
There are also three options:
The "Multifunctional Database" option is a general multi-function type. It is a good type and is the default type;
The "Transactional Database Only" option is of the server type and focuses on transaction processing;
The "Non-Transactional Database Only" option is Non-transaction processing type, which is simple and mainly used for monitoring and recording.
You can change the database based on the actual usage. Here we use the default option and click "Next>" to continue the configuration.
10 The InnoDB Tablespace Setting dialog box is displayed, where you should specify a storage location for the InnoDB database file. The default storage location is the MySQL installation directory,
Use the default storage location and click "Next>" to continue the configuration.
11 The Concurrent Connections selection dialog box is displayed. The options here determine the number of database Connections that can be opened at the same time.
There are three options:
The first "demo-support (DSS)/OLAP" option can have 20 connections;
The second "Online Transaction Processing (OLTP)" option can have 500 connections;
The third "Manual Setting" option sets the number of connections manually.
For MySQL servers running on a computer used for software development, there is no need for too many connections. In this case, it is no problem to select the first "demo-support (DSS)/OLAP.
However, for MySQL servers working at full speed on some popular websites, the number of concurrent connections may be very large. In this case, select the second "Online Transaction Processing (OLTP)" option.
Use the default first option here and click "Next>" to continue the configuration.
12 The Enable TCP/IP Networking dialog box is displayed. In Windows, there are two ways to communicate between the MySQL server and the application:
One is through the named pipeline (named pipe );
The second is through the network protocol TCP/IP.
MySQL configuration assistant recommends activating TCP/IP and using port 3306. Select the multi-select box (adding a firewall does not block this port) and use the default Recommended configuration. Click "Next>" to continue the configuration.
13. The Default Character Set dialog box is displayed. MySQL supports various Character sets when saving text data to the database.
Here we select the third item. To better process the Chinese Character Set, select or enter "utf8" in Character Set and click "Next>" to continue the Next configuration.
14. The Install as Windows Service dialog box is displayed. You can choose whether to install MySQL as a Windows system service,
In this way, you can manage the MySQL server through Windows system service management. You can also specify the Service Name (Service ID Name ),
Another option is to select whether to add the bin directory of MySQL to the Windows PATH (after adding the directory, you can directly use the file in the bin directory without specifying the directory name ). (Please select)
Here, we accept the default settings recommended by the MySQL configuration assistant, and click "Next>" to continue the Next configuration.
15. The Security Options dialog box is displayed. This is the most important configuration. You need to determine who is allowed to connect to the MySQL server and whether a password must be entered to establish a connection.
It is set to the most secure setting. Because root is the only user and the MySQL system administrator user, it is recommended that the root user enter the correct password to connect to the database and only allow him to log on locally.
Do not select the second option. Here, no anonymous account is created. The so-called anonymous account refers to an account that can connect to the database without a password. Click "Next>" to continue the configuration.
16. The confirm execution dialog box is displayed. Check whether the configuration settings are correct. If any error occurs, click <Back "to return to the check page. If the settings are correct, click Execute to make the settings take effect, and click Finish to complete MySQL installation and configuration.
17. After installing the MySQL environment, follow the preceding steps to install and configure MySQl. The installation directory of MySQL is "C: \ lamp \ mysql5;
The MySQL configuration file is the "C: \ lamp \ mysql5 \ my. ini" file, and the MySQL data file is stored in the "D: \ datafiles \ data" folder.
18 In Windows, start and stop MySQL, right-click my computer, choose manage> services and applications> services> MySQL, and click STOP, enable, or restart.
19. to test whether the MySQL database is successfully installed, you can enable a MySQL client to log on to the MySQL server for testing.
Choose Start> All Programs> MySQL Server 5.1> MySQL Command Line clientto start MySQL Command Line interpreter mysql.exe,
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, run the status command. The result indicates that the MySQL server is successfully installed.

Solution:
Problem and Solution: when installing MYSQL, the system prompts "Cannot create windows service for MySQL. error: 0 ".
The reason is that the old mysql service exists in the system. The solution is as follows:
To permanently delete the old mysql service, you must run the following command on the command line with the administrative permission:
C: \> SC delete mysql
[SC] DeleteService SUCCESS
When installing the service, if a similar situation occurs, check whether the service is a legacy service program, solution, delete the old service, and install the new service.

3. install PHP
When installing the PHP server, you must complete two tasks.
PHP is a module of the Apache server. It must be plug-in to Apache to help it process PHP files. Therefore, the first task is to load the PHP module in Apache.
During development, you also need to use a PHP program to connect to the database and operate on the database. Therefore, the second task is to configure the MySQL extension interface of PHP.
(1) install PHP as an extension module of the Apache server.
Step 1: Export php-5.2.13-win32.zip. Extract the content of this ZIP file to a selected sub-directory. Here we extract it to the "C: \ lamp \ php5" directory.
Step 2: Load PHP to Apache as a module.
The loading method is to write three lines in the Apache configuration file httpd. conf: the first line loads the PHP module;
The second line tells the Apache server that the suffix is. php or files with other suffixes are parsed using PHP. The third line specifies the location of the PHP configuration file.
We can insert the following three lines to a location in the Apache configuration file C: \ lamp \ apache2 \ conf \ httpd. conf.

LoadModule php5_module "C:/lamp/php5/php5apache2_2.dll" # load the PHP Module
AddType application/x-httpd-php. php. phtml # What suffix file does the PHP module parse?
PHPIniDir "C:/lamp/php5" # specify the location of the PHP configuration file
Note:
The first line is to load PHP 5 as a module and insert this line to the "# LoadModule vhost_alias_module modules/mod_vhost_alias.so" line in the httpd. conf configuration file of Apache. C:/lamp/php5/php5apache2_2.dll is the file in the corresponding path for installing PHP. Do not set php5apache2_2.dll and php5apache2. dll and php5apache. dll obfuscation, php5apache. dll is only applicable to versions earlier than Apache 2.0 and php5apache2 in the PHP 5 package. dll is only applicable to apache2.0. *, if it is 2. 2. * For the above version, php5apache2_2.dll must be used. Otherwise, some loading errors may occur.
The second line is to add PHP support. Tell Apache which suffixes will be parsed as PHP. For example, ask Apache to resolve. php or. phtml files to PHP. In the Apache configuration file, find "AddType application/x-gzip. gz. add "Addtype application/x-httpd-php. php. phtml line. You can resolve any suffix file to PHP, as long as you add a separate space in the added statement, Here add one more. phtml for example.
The third line is to specify the PHP configuration file php. ini location, in the second line "Addtype application/x-httpd-php. php. "C:/lamp/php5" specifies the previously selected PHP decompressed directory.

Step 3: Create a PHP configuration file. Directly change the PHP. ini-recommended file under the C:/lamp/php5 directory to php. ini.
You can also set the file php under the C:/lamp/php5 directory. ini-dist is renamed as php. ini, but the configuration file automatically adds "//" to all added content, which increases security and also increases the trouble. ini-recommended is renamed to php. ini, this configuration file does not add "//" to the added content, which reduces security, but is more convenient. Change the php. ini-recommended file to the php. ini file.
Step 4: restart the Apache server. You only need to modify the Apache configuration file httpd. conf or PHP configuration file php. ini, and restart the Apache server. The Apache server loads the configuration file httpd. conf at startup to make the configuration file changes take effect.
As a working module of the Apache server, PHP also loads the configuration file php. ini at Apache startup to make the modification take effect.
Step 5: test whether PHP installation is successful. The above steps have already installed PHP as an extension module of Apache and started with the Apache server.
If you want to check whether PHP is successfully installed, you can create a file named test. php In the C: \ lamp \ apache2 \ htdocs folder on the Apache server.

<? Php // PHP script start flag
Phpinfo (); // PHP internal function, used to print the status information of PHP
?> // PHP script end mark

Then open the http: // localhost/test. php page in the Web browser. A PHP test page is displayed, indicating that PHP is successfully installed.
(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, so PHP must find two MySQL-related DLL files installed with PHP.
Before that, copy the libmysql. dll file under the 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. You can also set the Windows environment variable to add the PHP decompression directory C: \ lamp \ php5 \ to the path environment variable.
Copy the C: \ lamp \ php5 \ libmysql. dll file to C: \ Windows.
Step 2: Enable MySQL in the PHP configuration file. Use a text editor to open the PHP configuration file C: \ lamp \ php5 \ php. ini.
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 semicolon used for comment.

Extension_dir = "c:/lamp/php5/ext" # specify the directory of the PHP extension interface. The directory delimiter is "/"
Extension = php_mysql.dll # enable MySQL extension Interface
Extension = php_mysqli.dll # enable the MySQLi extension Interface

Step 3: restart the Apache server and use the PHP configuration file to make the changes take effect.
Step 4: view the content on the PHP test page and check for descriptions of mysql and mysqli interface parameters. If the information displayed in 2-46 indicates that the mysql and mysqli extension interfaces of PHP are successfully loaded, open the Web browser to access the http: // localhost/test. php page for testing.
After the above configuration, we have completed the configuration of MySQL and MySQLi extension interfaces in PHP. If you need to configure other extension interfaces, the same method is used.

4. Install Zend accelerator
Step 1: Export zendoptimizer-3.3.3-windows-i386.exe. This is an installation file. You can double-click it to start the installation program.
Step 2: confirm to agree to the software installation and use license regulations through the following interface in the previous step, select "I accept the terms in the license agreement", and click "Next>" to continue.
Step 3: The Select installation location dialog box is displayed. You can select the location you like. Here, we will set the Zend Optimizer installation location to "C: \ lamp \ ZendOptimizer, click "Next>" to continue the installation.
Step 4: select the Web server type and select Apache2.x. Click "Next>" to continue the installation.
Step 5: The select PHP configuration file php. ini location dialog box is displayed. When installing PHP, we specify php. ini under the PHP installation directory C: \ lamp \ php5 \. Therefore, the path selected here is the C: \ lamp \ php5 folder.
Step 6: The following dialog box is displayed: select the root directory of the website content. When installing Apache, we specified the website root directory to the Apache installation directory C: \ lamp \ apache2,
Therefore, the path selected here is the C: \ lamp \ apache2 \ Folder. Click "Next>" to continue the installation.
Step 7: The confirm installation dialog box is displayed. If you need to check again, you can click the "<Back" button to return to the check step by step to ensure that the options are correct, click the "Install" button to start installation according to the previously set installation options.
Step 8: if the following prompt is displayed, shut down the Web server and click "OK" to continue the installation.
Step 9: If the installation is successful, the following installation end dialog box is displayed. Click "Finish" to complete the installation.
Step 10: Check the installation result. Start the Apache server, open the Web browser to access the http: // localhost/test. php page, and use the phpinfo () function for testing. 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

5. phpMyAdmin Installation
Step 1: extract phpmyadmin-3.3.3-all-languages.zip to/apache2/htdocs/, create a phpmyadmin folder, and put the compressed file in it to complete installation.
Step 2: configure the config in the top-level directory of phpMyAdmin. inc. php. config does not exist by default. inc. PHP file, we need to manually create one, you can also copy config. sample. inc. the php template obtains the minimum configuration file.
The following example shows the configuration of the config. inc. php file, which only provides the part that must be modified. Based on the actual situation, other options may need to be modified.
There are two configuration schemes for us to pass the Authentication mode. One is HTTP and cookie Authentication mode.
In both modes, you must enter the valid username and password of the MySQL database in a login window before using the phpMyAdmin program.
This method has two obvious advantages: first, because the MySQL database password does not appear in the config. inc. php file, the authentication process is safer;
You can log on to the database as a different user to manage your database. These two authentication modes are especially suitable for multiple user accounts in the database.
The second solution is the config Authentication mode. In this mode, the password is stored in the config. inc. php file in plaintext. You only need to write the MySQL user name and password directly to the config. inc. php file.
In this way, you will not be prompted to enter the user name and password when logging on to phpMyAdmin. Instead, you can log on directly using the user written in the config. inc. php file.
If you only use phpMyAdmin on a local test system, you can use this mode.
(1) HTTP Authentication Mode
To enable phpMyAdmin to use the HTTP Authentication mode, you must first make the following changes in the blacklist section in the config. inc. php file. The details are as follows:
$ Cfg ['servers'] [$ I] ['auth _ type'] = 'http'; // you only need to change this line to the http Authentication mode.
After the settings are complete, when phpMyAdmin is started, a Web browser dialog box will pop up. You need to enter the MySQL user name and password in this dialog box to enter the phpMyAdmin operation interface. On the Windows client, access the index. php file under the phpMyAdmin directory of the Web server using the IE browser, and then start phpMyAdmin.
(2) cookie Authentication Mode
The cookie Authentication mode is complementary to the HTTP Authentication mode. It can be used when the HTTP Authentication mode is not used. Cookie Authentication mode requires that you allow cookies from phpMyAdmin to enter your computer. That is, you need to enable the cookie function of the client in the browser.
To enable phpMyAdmin to use the cookie Authentication mode, in addition to modifying the auth_type statement in the config. inc. php file, you must also provide a string to the blowfish_secret parameter. This string can be arbitrary. The system uses this string to encrypt the user and password used for Logon before storing the cookie on the client computer. The modified content in config. inc. php is as follows:
$ Cfg ['blowfish _ secret'] = ''xxxxxxxx'''; // you need an arbitrary string here.
$ Cfg ['servers'] [$ I] ['auth _ type'] = 'cookies'; // you can change this parameter to the cookie Authentication mode.
Similar to the above phpMyAdmin startup method, we use the IE browser on the Windows client to access the index. php file under the phpMyAdmin Directory on the Web server. we need to provide the MySQL user name and password to log on.
(3) config Authentication Mode
If you want phpMyAdmin to use the config Authentication mode, you must first make the following changes in the config. inc. php file. Write the username and password of the MySQL database in plaintext. The specific modification content is as follows:
$ Cfg ['servers'] [$ I] ['auth _ type'] = 'config'; // change this parameter to the config Authentication mode.
$ Cfg ['servers'] [$ I] ['user'] = 'root'; // use the username of your MySQL database
$ Cfg ['servers'] [$ I] ['Password'] = '000000'; // use the password of your MySQL database
As with phpMyAdmin, we use the IE browser on the Windows client to access the index. php file under the phpMyAdmin Directory on the Web server. However, you can log on without providing the MySQL user name and password. It uses the username and password written in plaintext in config. inc. php.

Note: phpmyadmin must be in lower case.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.