Installing the PHP running environment on Windows system Text Tutorial _php Basics

Source: Internet
Author: User
Tags anonymous install php mysql client mysql in php server mysql command line zend windows server versions
I. Download related software

Software Download Address
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 the C disk of the Windows system as the installation location for the Web environment and install all software required by the environment under this folder.

Two. Install Apache

1 The Set System Information dialog box requires you to enter a few basic configuration parameters. These three information can be arbitrarily filled out, invalid also line.
Enter the "lampbrother.net" domain name in the first input box.
Add the Www.lampbrother.net server name to the second input box.
The third one to add is the contact e-mail address, which will be provided to visitors when the system fails,
is the email address of this Web server administrator, enter lampteacher@gmail.com here.
Finally, select the port of the Web server, use the default 80 port, and start automatically as a system service (the first).
2 Pop-up Select the Installation Type dialog box, "Typical" for the default installation, "Custom" for the user to customize the installation, we choose the "typical" type.
3 Pop-up Select Install Location dialog box, set the location of Apache installation to "D:\lamp\apache2".
4 Pop-up Confirmation Setup dialog box. If you need to check again, you can click the "<back" button to return to the check step by step. Make sure the options are correct, and click Install to start installing with the installation options set earlier.
5 pop-up is installing the interface, the installation Wizard successfully completed, when the bottom right corner of the status bar should appear Apache green Small Icon management tool, indicating that the Apache service has begun to run
6 Apache after the installation is completed, its installation directory is specified under "C:\lamp\apache2".
The Apache configuration file is a "C:\lamp\apache2\conf\httpd.conf" file,
The place where Apache holds Web pages is the "C:\lamp\apache2\htdocs" folder.
7 to start and stop Apache in a Windows system, there are several ways in which the following examples can be done.
Click Start Menu-> All Programs->apache HTTP server 2.2->control The Stop stop, start open, or restart restart under Apache server.
Click My Computer-> Management-> Service and Application-> service->apache2.2 option, click Stop, Open, or reboot.
Turn on, stop, or restart the Apache server by using the Green Small Icon management tool in Apache on the status bar in the lower right corner of the Windows system.
8 Apache can be tested by browser if it starts successfully. Open the browser and enter the http://localhost/URL in the address bar.
You can see IT works! This indicates that the Apache installation was successful and can be used.

Three. Install MySQL
Installing a MySQL database server can be divided into two parts:
Part is the installation of the program, and the other part is to use the MySQL configuration Assistant to create the MySQL configuration file, some detailed configuration options, and a password for the MySQL server.
The MySQL configuration Assistant is automatically run after the first part of the installation, or it can be started manually after the MySQL installation is complete.
1 Install "Mysql-5.1.46-win32.msi" files.
The 2 pop-up Installation Type selection dialog box has three options, namely typical installation (typical), full installation (Complete), and user-defined (custom) three types.
Choose "Custom" here, get more options, convenient for us to specify the installation location. Click the "next>" button to install the next step.
3 Pop-up user custom settings page, click the left button on the "Developer components" option,
And then select the second item "This feature, and all subfeatures, will is installed on the local hard drive.",
This is "This section, and subordinate parts, all installed on the local hard drive."
4 Specify the installation location. Click the change ... button to alter the installation location and specify it under the C:\lamp\mysql5 folder.
Not only does this option change the installation location, the previous options include the MySQL server option (MySQL servers),
MySQL client program options (client Programs), file options (documentation), all change the installation location, the operation is the same.
Click the Change ... button to manually alter the installation location to point to the "C:\LAMP\MYSQL5" folder where these options are installed.
It is recommended that the server data file "MySQL server datafiles" option not specify the same partition as the operating system. This prevents data from being emptied when the system backup is restored.
This is assigned to the D:\datafiles\ folder. When the settings are complete, click the "next>" button to install the next step.
5 Pop-up Installation Location Confirmation dialog box, you need to wait a few seconds to install. Here the MySQL database software is installed, the interface appears,
Check "Configure the MySQL Server now", click "Finish" button to end the software installation and start the MySQL Configuration Wizard.
6 then automatically runs the MySQL configuration assistant, to the second part of the installation MySQL configuration phase.
7 Pop-up Configuration Type selection dialog box, two options "Detailed Configuration (Detailed configuration)" and "Standard Configuration (Standard configuration)". Select the first item "Detailed Configuration".
The next few steps are configured with some content 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 Pop-up Server Type selection dialog box, which determines how much primary memory the MySQL server will attempt 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:
Developer machine option is to develop test classes, MySQL takes up very little resources;
The server machine option is the servers type, MySQL consumes more resources;
The dedicated MySQL server machine option is a dedicated database server, and MySQL consumes all available resources.
Choose a different type, 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 Pop-up database use (DB Usage) dialog box. They determine which kinds of data table types the MySQL server will support.
There are also three options here:
The "Multifunctional Database" option is a versatile, better type, the default type;
The "Transactional Database only" option is a server type, focusing on transaction processing;
"Non-transactional Database only" option is not a transaction processing type, relatively simple, mainly to do some monitoring, counting.
The user can change according to the actual database use, we use the default choice here, click the "next>" button to continue the next configuration.
10 Pop-up InnoDB table space settings (InnoDB tablespace Setting) dialog box, 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 here, and click the "Next>" button to continue with the next configuration.
11 Pop-up concurrent Connection (Concurrent Connections) Selection dialog box, where the options determine the number of simultaneous open database connections.
A total of three options:
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 sets the number of connections manually.
For a MySQL server running on a computer for software development, you don't need too many connections, so choosing the first "Decision Support (DSS)/olap" should be fine.
But the number of concurrent connections can be very large for MySQL servers that are working at full speed on some popular sites, and the second Online Transaction processing (OLTP) option should be selected.
Here, using the default first option, click the "next>" button to continue with the next configuration.
12 Eject the Activate TCP/IP networking feature (Enable TCP/IP Networking) dialog box. In a Windows system environment, the MySQL server communicates with the application in two ways:
One is through the named pipe (named pipe);
The second is TCP/IP via network protocol.
The recommended configuration given by the MySQL configuration Assistant is to activate TCP/IP and use port No. 3306. Select the Multiple selection box (join firewall does not block this port), use the default recommended configuration. Click the Next> button to continue with the next configuration.
13 pop-up default Character Set Settings dialog box, MySQL supports existing character sets when you save text data to a database in Character.
Here we select the third item, in order to better handle the Chinese character set, select or fill in "UTF8" in character set, click the "next>" button to continue the next configuration.
14 Eject the Install as Windows Services (Install as Windows Service) dialog box. Here you can choose whether to install the MySQL service as a Windows system service.
This allows you to manage the MySQL server through Windows System service management. You can also specify the service name (the Services identity name),
Another option is to choose whether to add MySQL's Bin directory to Windows path (when added, you can use the files in the bin directory directly without having to indicate the directory name). (Please select)
Accept the default settings recommended by the MySQL configuration assistant and click the "Next>" button to continue with the next configuration.
15 Pop-up Security Options dialog box. This is the most important configuration, and you need to decide who is allowed to connect to the MySQL server and whether you must enter a password to establish a 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 on locally.
Do not tick the second option, this does not create any anonymous account, the so-called anonymous account refers to the password can not be connected to the database account. Click the Next> button to continue with the next configuration.
16 Popup Confirmation Execution dialog box. Verify that the configuration settings are correct, and if so, click the "<back" button to return to the check. If you are sure, click Execute to make the settings effective, and click Finish to end the installation and configuration of MySQL.
MySQL installed after the environment, in accordance with the above steps to install and configure the completion of the MySQL installation directory is "C:\lamp\mysql5\" below;
MySQL's configuration file is a "C:\lamp\mysql5\my.ini" file, where the MySQL data file is stored in the "D:\datafiles\data" folder.
Start and stop MySQL in Windows system, right-click My Computer-> manage-> service and application-> service->mysql option, click Stop, Open, or reboot.
19 Test MySQL Database installation is successful, you can open a MySQL client to log on to the MySQL server for testing.
Use the Start menu-> All Programs->mysql->mysql Server 5.1->mysql command line client to start MySQL's command-line interpreter program Mysql.exe,
Then enter the password you entered when you configured MySQL. If all goes well, you should see the MySQL input prompt in the input window. Next executes the status command, which indicates that the MySQL server was successfully installed.

Solution:
Problems and solutions when installing MySQL: When installing MySQL, the system prompts: cannot create Windows service for mysql.error:0
The reason is that there is an old MySQL service in the system, and the solution is as follows:
To permanently delete the old MySQL service, you need the user to administer the following commands on the command line:
C:\&GT;SC Delete MySQL
[SC] DeleteService SUCCESS
When installing services, if a similar situation occurs, look at the service is not a legacy of service procedures, solutions, delete old services, install new services.

Three. Install PHP
When you install a PHP server, you have two tasks to complete.
PHP is a module of the Apache server, to plug into Apache to assist it to deal with PHP files, so the first task is to add the PHP module in Apache.
In the development of the use of PHP program to connect the database and the database operations, so the second task is to configure the PHP MySQL extension interface.
(1) Install PHP as an extension module of the Apache server.
Step one: "Php-5.2.13-win32.zip" file. Unzip the contents of the Zip document to a selected subdirectory, and we'll extract it into the "C:\LAMP\PHP5" directory.
Step Two: PHP is loaded into Apache in a modular way.
The way to load 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 suffix name is. php or a file that specifies a different suffix name using PHP parsing; the third line specifies the location of the PHP configuration file.
Here we 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" #加载PHP模块
AddType application/x-httpd-php. php. phtml #PHP模块解析哪种后缀文件
Phpinidir "C:/LAMP/PHP5" #指定PHP配置文件的位置
Attention:
The first line, which refers to loading PHP 5 as a module, inserts this line into the Apache configuration file httpd.conf "#LoadModule vhost_alias_module modules/mod_vhost_alias.so" Line below. Where C:/lamp/php5/php5apache2_2.dll is the appropriate path to install PHP files. Be careful not to confuse Php5apache2_2.dll, Php5apache2.dll, and Php5apache.dll, Php5apache.dll only for previous versions of Apache 2.0, PHP The Php5apache2.dll in the 5 compression package only applies to the apache2.0.* version, if it is 2.2.* above version, must use Php5apache2_2.dll. Otherwise, there may be some load errors.
The second line is the support for adding PHP. Tell Apache which suffixes are parsed as PHP. For example, ask Apache to parse a file of. php or. phtml suffixes into PHP. Locate 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 resolve any suffix file to PHP, as long as you add a statement and separate it with a space, add one more. phtml to the example.
The third line, which specifies the location of the PHP configuration file php.ini, is added under the second line "AddType application/x-httpd-php. PHP phtml", where "C:/LAMP/PHP5" Specifies the previously selected PHP uncompressed directory.

Step three: Create a PHP configuration file. Directly to the PHP extract directory c:/lamp/php5 below the php.ini-recommended file renamed to PHP.ini can be.
You can also rename the file Php.ini-dist in the C:/LAMP/PHP5 directory to php.ini, but the profile automatically adds "//" to all additions, adding security, as well as adding to the hassle If the php.ini-recommended is renamed PHP.ini, the profile does not add "//" to the added content, which reduces security but is more convenient. Here the php.ini-recommended file is renamed php.ini file.
Step four: Restart the Apache server. You should restart the Apache server as long as you make changes to the Apache profile httpd.conf or the PHP configuration file php.ini. The Apache server loads the configuration file httpd.conf at startup, making the contents of the configuration file changes effective.
PHP, as a working module of the Apache server, also loads the configuration file at the time of Apache startup to php.ini the modified content.
Step five: Test whether the PHP installation was successful. The steps above have installed PHP as an extended module of Apache and started with the Apache server.
If you want to check if PHP is installed successfully, you can use a text editor to create a file named test.php under the C:\lamp\apache2\htdocs folder where the Apache server holds the Web page.

<?php//php Script start tag
Phpinfo ();//php internal function for printing the state information of PHP
?>//php Script end tag

Then use the Web browser to open the http://localhost/test.php page. A PHP test page appears stating that the PHP installation was successful.
(2) Configure PHP's MySQL extension interface
Step one: After the above configuration, PHP5 has been successfully installed. But PHP is not yet able to access the MySQL database server, so PHP must find the two MySQL-related DLL files installed with PHP.
Before that, you should first copy the Libmysql.dll files under the PHP installation directory C:\lamp\php5\ to the Windows installation directory.
The directory is usually C:\Windows, and some Windows server versions are C:\WINNT directories. You can also set the environment variables for your Windows system and add PHP's uncompressed directory C:\lamp\php5\ to the PATH environment variable.
Here we copy the C:\lamp\php5\libmysql.dll file to the C:\Windows below.
Step two: Open the MySQL feature 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 open the MySQL and mysqli extension interface. You can also find the following three lines in the PHP configuration file and remove the semicolon used for the comment.

Extension_dir= "C:/lamp/php5/ext" #指定PHP的扩展接口目录, directory separator is "/"
Extension=php_mysql.dll #开启MySQL扩展接口
Extension=php_mysqli.dll #开启MySQLi扩展接口

Step three: Restart the Apache server and use the modifications made by the PHP configuration file to take effect.
Step four: Check the contents of the PHP test page to see if there is any description of the MySQL and mysqli interface parameters. If you see the information shown in Figure 2-46 indicating that PHP's MySQL and mysqli extensions are loaded successfully, also open a Web browser to access the http://localhost/test.php page for testing.
Through the above configuration, we have completed the PHP mysql and mysqli extension interface configuration, if need to configure other extension interface is the same method.

4. Install Zend Accelerator
Step one: "Zendoptimizer-3.3.3-windows-i386.exe" file. This is directly an installation file, double-click to start the installer.
Step two: Through the previous installation of the following interface, confirm the consent to the Software Installation use license regulations, select "I accept the terms in the License Agreement", click the "next>" button to continue.
Step Three: Pop-up Select the Installation Location dialog box, where you can choose your favorite location, we will Zend Optimizer installation location set to "C:\lamp\ZendOptimizer\", click the "next>" button to continue the installation.
Step Four: Pop-up below select the Web server kind of screen, select the apache2.x option. Click the Next> button to continue the installation.
Step Five: Eject the Select PHP Profile php.ini Location dialog box. When installing PHP, we assign php.ini to the PHP installation directory C:\lamp\php5\, so the location chosen here is also the C:\LAMP\PHP5 folder.
Step Six: Pop-up below select the root directory of the Web Site dialog box, select the site content root path. When we install Apache we assign the site root directory to the Apache installation directory 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 Seven: Eject the Confirm Installation dialog box. 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, and click the "Install" button to begin installing with the installation options set earlier.
Step eight: If you eject the following prompts, close the Web server first, and then click OK to continue the installation.
Step nine: If all installed smoothly will pop up the following end of the installation dialog box, click the Finish button to finish the installation, when the installation is complete.
Step Ten: Check the installation results. Start the Apache server, open a Web browser to access the Http://localhost/test.php page, and test it through the phpinfo () function. If the following description appears, the installation is successful.
This program makes 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 of 5.phpMyAdmin
Step One: Extract the Phpmyadmin-3.3.3-all-languages.zip to the/apache2/htdocs/, and create a call phpMyAdmin folder, the compressed file into the finished installation.
Step Two: Configure the config.inc.php in the phpMyAdmin top-level directory, the default does not exist config.inc.php files, we need to create one manually, you can also copy the config.sample.inc.php template to get the minimum configuration file.
The following example is a configuration of the config.inc.php file with only the parts that must be modified, and some other options may be required to make the changes.
We can use the authentication mode requirements, there are two kinds of configuration scenarios, one is the HTTP and cookie authentication mode.
In both modes, users must first enter a valid username and password for the MySQL database in a login window before they can use the phpMyAdmin program.
There are two obvious benefits to this approach: first, because the MySQL database password does not appear in the config.inc.php file, the authentication process is more secure;
Second, it allows you to manage your own database by logging on as a different user. These two authentication modes are especially appropriate for multiple user accounts in the database.
The second scenario is the Config authentication mode. In this mode, the password is stored in the config.inc.php file in clear text form. Only the MySQL username and password must be written directly to the config.inc.php file.
In this way, you will not be prompted for a username and password when you log in to phpMyAdmin, and only log in with the user written in the config.inc.php file.
This pattern can be used if you are only using phpMyAdmin on a local test system.
(1) HTTP Authentication Mode
If you want phpMyAdmin to use the HTTP authentication mode, you first need to make the changes shown below in the bold section of the config.inc.php file. The specific contents are as follows:
$cfg [' Servers '] [$i] [' auth_type '] = ' http '; Only modify this line to HTTP authentication mode
When we start phpMyAdmin, we will have a Web browser dialog box on the screen that requires you to enter the MySQL username and password in the dialog box to enter the phpMyAdmin operator interface. The Windows client uses IE browser to access the index.php file in the phpMyAdmin directory of the Web server, which starts the phpMyAdmin.
(2) Cookie authentication mode
Cookie authentication mode is supplemental to the HTTP authentication mode and can be used on occasions where HTTP authentication mode cannot be used. Cookie authentication mode requires the user to allow cookies from phpMyAdmin to enter their computer. That is, the user needs to open the client's cookie function in the browser.
If you want phpMyAdmin to use the cookie authentication mode, you must also supply a string to the Blowfish_secret parameter in addition to modifying the Auth_type statement in the config.inc.php file. This string can be arbitrary so that the user and password used at logon are stored in the cookie on the client computer before the system encrypts them using this string. The content modified in config.inc.php is as follows:
$cfg [' blowfish_secret '] = ' xxxxxxx '; We need an arbitrary string here.
$cfg [' Servers '] [$i] [' auth_type '] = ' cookie '; This is modified to cookie authentication mode
As with the phpMyAdmin, we use IE browser on the Windows client to access the index.php files on the phpMyAdmin directory on the Web server, and we need to provide a MySQL username and password to log in.
(3) Config authentication mode
If you want phpMyAdmin to use the Config authentication mode, you first need to make the modifications shown below in the config.inc.php file. The MySQL database username and password written in plaintext, the specific changes are as follows:
$cfg [' Servers '] [$i] [' auth_type '] = ' config '; This changes to config authentication mode
$cfg [' Servers '] [$i] [' user '] = ' root '; Use your MySQL database username
$cfg [' Servers '] [$i] [' password '] = ' 111111 '; Use the password for your MySQL database
Like the way it starts phpmyadmin, we use IE in the Windows client to access the index.php files on the phpMyAdmin directory on the Web server. However, you can log on without providing a user name and password for MySQL, which is logged in using the username and password written in plaintext in config.inc.php.

Note: phpMyAdmin to lowercase
Related Article

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.