Install PHP running environment text tutorial on Windows

Source: Internet
Author: User
Tags configuration settings http authentication 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 Program -> 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. When saving the text data to the database, MySQL supports the existing character sets.
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 the 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> 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 must use a PHP program to connect to the database and perform operations 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 load method is in the Apache configuration file httpd. write three lines in conf: the first line loads the PHP module;
the second line tells the Apache server that the suffix is. PHP or files with other extension names are parsed using PHP; the third line specifies the location of the PHP configuration file.
here we can insert the following three lines into 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 # Which suffix file is parsed by the PHP module
phpinidir "C:/lamp/PhP5" # specify the location of the PHP configuration file
Note:
the first line, load PHP 5 as a module and insert this line to the Apache configuration file httpd. under the "# loadmodule vhost_alias_module modules/mod_vhost_alias.so" line in Conf, you can. 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.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.