Windows Apache build PHP development Environment _php Instance

Source: Internet
Author: User
Tags mysql version php session php development environment php file upload utc greenwich vc9 mysql login phpmyadmin

This paper describes in detail the use of apache2.2.21/php5.3.5/mysql5.5.19/phpmyadmin3.4.9 to build a PHP development environment under WINDOWS2003.

First step: Download the installed files

1. Apache version Httpd-2.2.21-win32-x86-no_ssl.msi

2. MySQL version Mysql-5.5.19-win32.msi

3. PHP version Php-5.3.5-win32-vc6-x86.zip

4. phpMyAdmin version Phpmyadmin-3.4.9-all-languages.zip

Tips:

1. It is recommended that the Apache version without SSL be selected to complete development, so we use Apache 2.2.21-win32-x86-no Ssl.msi here.

2. Install MySQL under Windows to select the. msi installation package format, we chose the Mysql-5.5.19-win32.msi, double-click according to the wizard installation can be simple and convenient.

3. PHP we choose to use the. zip version of Windows, Php-5.3.5-win32-vc6-x86.zip. In terms of both security and performance, the zip version is good, and the general server is installed with this version.

Do not download the NTS version or the VC9 version, because VC9 is specifically customized for IIS, and VC6 is provided for Apache or other Web service software.

4. phpMyAdmin is a PHP based online MySQL management tool, in the phpMyAdmin3 installation needs of the PHP environment for at least PHP5.2,MYSQL5 version, we are here to meet the requirements.

Step Two: Install files

1. Build a folder on the disk you want to install. For easy management, we create a Wamp folder in the root directory of D disk. D:\WAMP (WAMP is the abbreviation of windows+apache+mysql+php).

2. Create a WWW folder under the Wamp folder to store your PHP Web program. D:\WAMP\WWW.

3. Install the Apache server and install the Apache server into the D:\WAMP\Apache folder. The specific Apache installation process can refer to the documentation Apache installation diagram.

4. Extract the downloaded php-5.3.5-win32-vc6-x86 to the D:\WAMP\PHP folder.

5. Install MySQL database, install MySQL to D:\WAMP\MySQL folder. Specific MySQL installation process can refer to the documentation MySQL installation diagram.

6. Extract Phpmyadmin-3.4.9-all-languages.zip, then rename it to phpMyAdmin and copy it to the PHP Web site program directory. The result is D:\WAMP\WWW\phpMyAdmin.

Step Three: Configure Apache

First use the text Editing tool (recommended EditPlus) to open the D:\WAMP\Apache\conf\httpd.conf file, which is Apache configuration file, the following steps are to modify the contents of this file.

Note that the new settings will not take effect until you have modified the httpd.conf file to restart the Apache service.

1. Set the listening port

After opening the httpd.conf file, locate Listen (probably on line 46th) and change the number following it to 8080, as follows:

Listen 8080

This parameter is used to set the listener port for the Apache server, typically by default of 80. Modify to 8080 to avoid conflicts with the IIS port number of Windows 2003 systems, or you can use the default 80 port number if you do not have IIS enabled.

2. Let Apache load PHP module

Find the #LoadModule vhost_alias_module modules/mod_vhost_alias.so (probably on line 128th), and add the following after this line:

LoadModule php5_module "D:/wamp/php/php5apache2_2.dll"
 addtype application/x-httpd-php. PHP phpinidir
 "D:/ wamp/php "
LoadModule php5_module" D:/wamp/php/php5apache2_2.dll "

This means loading the PHP5 module in modular mode.

AddType application/x-httpd-php. php


This means that the file of the. php extension is executed as a PHP script. You can use any other extensions you like, such as. html,. php5, or even. txt to execute PHP.

Phpinidir "d:/wamp/php"

This is used to specify the directory where PHP's configuration file php.ini resides.

If Apache 2 is running PHP5 in module mode, the phpinidir instruction can be used.

3. Modify the Site Storage directory

We know that the Apache default site directory is the Htdocs folder under the Apache installation directory. When you change the site directory, you must modify the corresponding Apache configuration.

Look for DocumentRoot (approximately 182 lines) in the profile httpd.conf to modify it to the correct folder for the site directory. Here we change it to

DocumentRoot "D:/wamp/www"

Also, find this should is changed to whatever your set DocumentRoot to (approximately 207 lines), under which there are rows <directoy default DocumentRoot, and modify it to your own The DocumentRoot path that has already been configured. We modify this to:

 <directory "D:/wamp/www" >

4. Modify Directory First file

Look for DirectoryIndex index.html (approximately 244 lines) in the profile httpd.conf to modify it to:

DirectoryIndex index.html index.htm index.php

DirectoryIndex refers to a file that is executed by Apache by default when the client browser accesses a path that is a directory.

As we modified the example: when the client browser access to a directory, Apache will find the directory under the index.html, if not to find index.htm, no longer find index.php. is not found, the list of files in the directory is displayed by default. Reference documentation: If you prevent Apache from displaying a list of files

Fourth Step: Configure PHP

Open the PHP installation directory, that is D:\WAMP\PHP, we can see that the directory has two such files Php.ini-development and Php.ini-production, the first is to develop the use of the configuration file, the second is the configuration of the production environment, because we are doing the development of the local, so choose the former. Copy the php.ini-development to the same directory and rename it to PHP.ini. This php.ini is the configuration file currently in use, and the following steps are modifying the contents of this php.ini file. Note that the new settings will not take effect until you modify the php.ini file to restart the Apache service.

1. Specify the storage directory for the PHP extension library

PHP extensions in Windows are usually stored as DLLs in PHP's ext directory.
Use the Text tool to open the php.ini file and find Extension_dir = "ext" (approximately 809 lines), which is the line under on Windows. Put it in front of the semicolon ";" removed, instead as follows:

 Extension_dir = "D:/wamp/php/ext"

Extension_dir represents the specific directory of the PHP extension library to invoke the corresponding DLL file.

2. Open the appropriate extension library

By default, many PHP extensions are turned off, such as default PHP does not support the MySQL database connection, you need to open the appropriate extension library.
Here we turn on some common extensions.

Find Windows Extensions (approximately 941 lines), below it is a list of extension.

Find the following extensions:

, Extension=php_curl.dll,
 Extension=php_gd2.dll,
 extension=php_mbstring.dll,
 Extension=php_exif.dll ,
 Extension=php_mysql.dll, Extension=php_mysqli.dll, Extension=php_pdo_mysql.dll,
 extension= Php_pdo_odbc.dll;
 extension=php_sockets.dll;
 extension=php_xmlrpc.dll;
 Extension=php_xsl.dll

Remove the semicolon ";" before extension above. If you want to load other extension modules, the method is the same, just remove the preceding semicolon.

Tip 1: Restart Apache Prompt "Unable to load dynamic Library......php_curl.dll", load Php_curl.dll error. The solution is to copy the Libeay32.dll and Ssleay32.dll from the PHP directory to the Windows directory or Windows/system32 directory, as long as the path contained in the system PATH environment variable is available. If you don't want to copy, you can also put the PHP path directly into the system PATH environment variable. Right-click My Computer => Properties => Advanced => environment variable => system variable has a path, double click to open, add a semicolon to your PHP path "; The front (;D: \wamp\php), add in just OK. Restart Apache to no longer prompt for this error.

Tip 2: EXIF extensions are used to display EXIF information for a picture, because the extension requires Mbstring.dll support, so the Extension=php_exif.dll line must be written to Extension=php_ Behind the Mbstring.dll.

Tip 3: If PHP's own extension library doesn't meet your needs, you can go to pecl.php.net to find and download the library you need. Windows users can go to pecl4win.php.net or http://downloads.php.net/pierre/download a compiled DLL file, or go to http://museum.php.net/php5/ Load PECL Collection Compression package.

Tip 4: Many people are looking for php_zip.dll, in fact, from the beginning of the php5.3 has been integrated with the zip extension, direct use on the line. You can use the <?php phpinfo ()?> to find a description of the zip extension.

3. Allow PHP to support short tags

In the php.ini configuration file look for Short_open_tag = off (approximately 266 lines) to modify it to: Short_open_tag = on Let IT support the short label.
PHP code is generally included in the <?php ...? > tags, set short_open_tag = On, can be written in a more concise form: .... ? >.

4. Configure the PHP session function

When using the session function, we have to configure the Save directory on the server for the sessions file. We need to create a read-write directory for the session, preferably separate from the site directory.

Here the directory is built in the D:\WAMP\sessiontmp, and then found in the php.ini configuration file, Session.save_path = "/tmp" (approximately 1467 lines), remove the preceding semicolon ";" and change to read as follows:

 Session.save_path = "D:/wamp/sessiontmp"

5. Configure PHP File Upload function

Like the session, when using PHP file Upload function, we have to specify a temporary folder to complete the file upload function, otherwise the file upload function will fail.
We create a read-write directory folder D:\WAMP\fileuploadtmp and then find it in the php.ini configuration file, Upload_tmp_dir = (about 875 lines), modified to:

 Upload_tmp_dir = "D:/wamp/fileuploadtmp"

PHP default upload file size of not more than 2M, to upload more than 2M files, please refer to the document configuration PHP.ini implementation file upload function.

6. Set time zone

In the php.ini configuration file look for;d Ate.timezone = (approximately 993 lines), remove the preceding semicolon ";" to read as follows:

 Date.timezone = PRC

Date.timezone is the PHP5.1 start of the newly added configuration parameter, which is used to set the time zone. The default Date.timezone is commented out, or the default time zone is UTC Greenwich Mean time.

We change here to Date.timezone = PRC (Prc,people's Republic of China, the People's Republic of China), which is the date of use in the Chinese time zone. This will solve the problem of eight hours difference in time.

Fifth Step: Configure phpMyAdmin

Open the phpMyAdmin directory, that is, D:\WAMP\WWW\phpMyAdmin, we can see that the directory has a config.sample.inc.php file, copy this file to the same directory, and renamed to Config.inc.php. This config.inc.php is the phpMyAdmin configuration file, the following steps are to modify the contents of this config.inc.php file.

1. Set phpMyAdmin login mode

Open the config.inc.php file and look for $cfg [' Servers '] [$i] [' Auth_type '], set as follows:

 $cfg [' Servers '] [$i] [' auth_type '] = ' cookie ';

The value of this parameter is set to a cookie, and the username password is required for each login phpMyAdmin. This is also the default setting for phpMyAdmin.

Then find $cfg [' Blowfish_secret '], set as follows:

 $cfg [' blowfish_secret '] = ' admin10000.com ';

This parameter is used for the encryption of cookies, which is set to admin10000.com and you can change to your own password.

Here are four ways to login phpMyAdmin:

Cookie: This is the default login method for phpMyAdmin configuration. You need to enter the MySQL admin account and password in the login interface.
When you select the cookie login method, you also need to set the phrase password $cfg [' Blowfish_secret '], which is used for the encryption of cookies.
For example: $cfg [' blowfish_secret '] = ' admin10000.com ';
If not set, the login phpMyAdmin prompts the "profile now requires a phrase password" error.

Config: Enter the phpMyAdmin login address directly in the address bar of the browser to login and anyone can access it. The username and password are set in advance in the configuration file.
This logon method must add the following 2 line parameters to the configuration file:
$cfg [' Servers '] [$i] [' user '] = ' your MySQL login account ';
$cfg [' Servers '] [$i] [' password '] = ' your MySQL login password;
If only in the development of this machine, you can set the config login mode, eliminating the trouble of entering the password every time.

http: pop up a dialog box and enter the username and password.
Signon: Similar to the page jump login mode, at the same time need to set $cfg[' Servers ' [$i] [' Signonurl '], when you enter the phpMyAdmin login address will automatically jump to the Signonurl set URL.

2. Open phpMyAdmin Advanced function

After you log in phpMyAdmin, you will be prompted at the bottom of the first page: "phpMyAdmin advanced features are not fully set, some features are not available."
Now we're going to solve this problem. Using the phpMyAdmin Import feature, import the Phpmyadmin/scripts/create_tables.sql file to create the necessary data tables.

Next you will need to create a new MySQL user and give it access to the data tables established by the previous operation, which is called the control user and supports the phpMyAdmin advanced features.

We use PMA here as a control user and as a pmapass to control the user's password. You can change it yourself.

In the phpMyAdmin SQL query function box, enter the following SQL code:

 GRANT USAGE on mysql.* to ' PMA ' @ ' localhost ' identified by ' pmapass ';
 GRANT SELECT (
 Host, User, Select_priv, Insert_priv, Update_priv, Delete_priv,
 Create_priv, Drop_priv, Reload_ Priv, Shutdown_priv, Process_priv,
 File_priv, Grant_priv, References_priv, Index_priv, Alter_priv,
 Show_db_ Priv, Super_priv, Create_tmp_table_priv, Lock_tables_priv, Execute_priv, Repl_slave_priv, Repl_client_priv
 ) on Mysql.user to ' PMA ' @ ' localhost ';
 GRANT SELECT on mysql.db to ' PMA ' @ ' localhost ';
 GRANT SELECT on Mysql.host to ' PMA ' @ ' localhost ';
 GRANT SELECT (Host, DB, User, TABLE_NAME, TABLE_PRIV, COLUMN_PRIV)
 

We then found the User used to manipulate with storage in config.inc.php. Remove the 2-line parameter annotation (double slash "//") below it.

The results are:

 $cfg [' Servers '] [$i] [' controluser '] = ' PMA ';
 $cfg [' Servers '] [$i] [' controlpass '] = ' pmapass ';

These two lines are control user and control user password respectively. Which is the user we created above.

Then find the Storage database and tables, and remove the comments for the following parameters. The results are:

 $cfg [' Servers '] [$i] [' pmadb '] = ' phpmyadmin ';
 $cfg [' Servers '] [$i] [' bookmarktable '] = ' pma_bookmark ';
 $cfg [' Servers '] [$i] [' relation '] = ' pma_relation ';
 $cfg [' Servers '] [$i] [' table_info '] = ' pma_table_info ';
 $cfg [' Servers '] [$i] [' table_coords '] = ' pma_table_coords ';
 $cfg [' Servers '] [$i] [' pdf_pages '] = ' pma_pdf_pages ';
 $cfg [' Servers '] [$i] [' column_info '] = ' pma_column_info ';
 $cfg [' Servers '] [$i] [' history '] = ' pma_history ';
 $cfg [' Servers '] [$i] [' tracking '] = ' pma_tracking ';
 $cfg [' Servers '] [$i] [' designer_coords '] = ' pma_designer_coords ';
 $cfg [' Servers '] [$i] [' userconfig '] = ' pma_userconfig ';

Step Sixth: Test

Save the following code as a index.php file and place it under the D:\WAMP\WWW directory.

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
 
 

Then enter "http://localhost:8080/index.php" in the browser address bar. The results are shown in the following illustration:

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.