This article describes in detail the use of apache2.4.12-x64-vc11/php-5.6.7-win32-vc11-x64/mysql5.6.24/phpmyadmin4.4.2 to build a PHP development environment under Windows8.1 (X64).
First step: Download the installed files
1. It is recommended to select the Apache version without SSL to complete the development.
2. Install MySQL under Windows Select the. msi installation package format, double-click the wizard to install, simple and convenient.
3. PHP we choose to use the. zip version of Windows. From the security and performance of the zip version is good, the general server is also installed this version.
Do not download the NTS version or the VC9 version, because VC9 is specifically customized for IIS, and VC6 is for Apache or other Web services software.
4. phpMyAdmin is a PHP-based online MySQL management tool, the PHP environment required for phpMyAdmin3 installation is at least php5.2,mysql5 or more, we meet the requirements here.
Step Two: Install files
1. Build a folder on the disk that you want to install. For administrative convenience we create a Wamp folder in the root directory of the D drive. D:\WAMP (WAMP is the abbreviation for windows+apache+mysql+php).
2. Create a WWW folder under the Wamp folder to store your PHP website program. D:\WAMP\WWW.
3. Install the Apache server and install the Apache server to 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 and install MySQL to the D:\WAMP\MySQL folder. The specific MySQL installation process can refer to the documentation for the MySQL installation diagram.
6. Unzip the phpmyadmin-3.4.9-all-languages.zip, then rename it to phpMyAdmin, and copy it to the PHP website 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, this file is the Apache configuration file, the following steps are to modify the contents of this file.
Note that the httpd.conf file needs to be restarted to restart the Apache service and the new settings will not take effect.
1. Setting the Listening port
After opening the httpd.conf file, locate Listen (probably on line 46th) and change the number after it to 8080, as follows:
Listen 8080
This parameter is used to set the Apache server's listening port, which typically defaults to 80. The change to 8080 is to avoid conflicts with IIS port numbers for Windows 2003 systems, and you can use the default 80 port number if you do not have IIS enabled.
2. Let Apache load the PHP module
Locate the #LoadModule vhost_alias_module modules/mod_vhost_alias.so (probably on line 128th) and add the following after this line:
Define phproot "d:/programs/wapm/php" "${phproot}" #LoadModule Vhost_alias_module Modules/mod_vhost_alias. "${phproot}/php5apache2_4.dll"AddType application/x-httpd-php. php
LoadModule php5_module "D:/wamp/php/php5apache2_4.dll"
This means loading the PHP5 module in modules mode.
AddType application/x-httpd-php. php
This means that the. php extension file is executed as a PHP script. You can use any other extension you like, such as. html,. php5, or even. txt to execute PHP.
Phpinidir "d:/wamp/php"
This is used to specify the directory where the PHP configuration file php.ini resides.
If Apache 2 is running PHP5 in module mode, you can use the Phpinidir command.
3. Modify the Site Storage directory
We know that the Apache Default Web hosting directory is the Htdocs folder under the Apache installation directory. When you change the Web hosting directory, you must modify the appropriate Apache configuration.
Look for DocumentRoot (approximately 182 lines) in profile httpd.conf and modify it to the correct folder for the site directory. We'll change here.
DocumentRoot "D:/wamp/www" <directory "d:/wamp/www" >
Also, look for this should is changed to whatever you set DocumentRoot to (about 207 lines), under which there is a line <directoy the default documentroot, and modify it to your own The DocumentRoot path that you have configured. We have modified here to:
4. Modify the Directory home page file
Look for DirectoryIndex index.html (approximately 244 lines) in the configuration file httpd.conf to modify it to:
DirectoryIndex index.html index.htm index.php
DirectoryIndex refers to the file that Apache performs by default when the path that the client browser accesses is a directory.
For example: When the client browser accesses a directory, Apache will go to find the index.html in that directory, and if you don't find index.htm again, you haven't found index.php. is not found, the list of files in this directory is displayed by default. Reference Document: 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 there are two such files in the directory Php.ini-development and Php.ini-production, the first one is the configuration file used for development, the second is the configuration of the production environment, because we are doing the development in this machine, so choose the former. Copy the php.ini-development to the same directory and rename it to PHP.ini. This php.ini is the currently used configuration file, the following steps are to modify the contents of this php.ini file. Note that the Apache service needs to be restarted after modifying the php.ini file, and the new settings will not take effect.
1. Specify a storage directory for the PHP extension library
PHP's extension libraries under windows are usually stored as DLLs in the PHP ext directory.
Use the Text tool to open the php.ini file and look for extension_dir = "ext" (approximately 809 lines), which is the line below on Windows. Put it in front of the semicolon ";" Removed and changed to read as follows:
Extension_dir = "D:/wamp/php/ext"
Extension_dir represents the specific directory of the PHP extension library in order to invoke the appropriate DLL file.
2. Open the appropriate extension library
By default, many PHP extension libraries are closed, such as the default PHP does not support the connection to the MySQL database, you need to open the appropriate extension library.
Here we open some of the commonly used extension libraries.
Find Windows Extensions (about 941 lines), below it is the 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
Get rid of the semicolon ";" in front of the above extension. If you want to load other extensions, the method is the same, just remove the preceding semicolon.
Tip 1: Restart the Apache hint "Unable to load dynamic Library......php_curl.dll", loading the Php_curl.dll error. The workaround is to copy the Libeay32.dll and Ssleay32.dll in 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 do not want to copy, you can also directly put the PHP path in the system PATH environment variable. Right-click my Computer = = Property = = Advanced = Environment variable = = System variable has a path, double-click Open, add your PHP path a semicolon ";" In front (;D: \wamp\php), add in is OK. Restarting Apache no longer prompts for this error.
Tip The 2:exif extension is 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 the back of the Extension=php_mbstring.dll.
Tip 3: If PHP comes with an extension library that 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/to download the compiled DLL files, you can go to http://museum.php.net/php5/ Load PECL set of compressed packets.
Tip 4: A lot of people looking for php_zip.dll, in fact, from the beginning of the php5.3 has been integrated zip extension, direct use on the line. You can find the description of the zip extension with <?php phpinfo ()?>.
3. Let PHP support short tags
In the php.ini configuration file, look for short_open_tag = OFF (approximately 266 lines) to modify it to:
On
Let IT support the short label.
PHP code is generally included in the <?php ... > in the label, set Short_open_tag = On, can be written in a more concise form: < .... ? >.
4. Configure the session function of PHP
When using the session function, we must configure the session file to save the directory on the server. We need to create a read-write directory for the session, preferably independent of the site directory.
Here the directory is built in the D:\WAMP\sessiontmp, and then in the php.ini configuration file, Session.save_path = "/tmp" (about 1467 lines), remove the preceding semicolon ";", instead, as follows:
Session.save_path = "D:/wamp/sessiontmp"
5. Configure the PHP file upload function
As with the session, when using PHP file Upload function, we must specify a temporary folder to complete the file upload function, or the file upload function will fail.
We create a read-write directory folder D:\WAMP\fileuploadtmp, which is then found in the php.ini configuration file, Upload_tmp_dir = (approximately 875 lines), modified to:
Upload_tmp_dir = "D:/wamp/fileuploadtmp"
PHP default upload file size of not more than 2M, to upload files larger than 2M
php.ini file Upload feature configuration options description
Open the PHP.ini configuration file with the Text tool (recommended editplus), find the file uploads, and have the following 3 options in this area:
File_uploads = On
Whether to allow HTTP file uploads. The default is on to allow HTTP file uploads, and this option cannot be set to OFF.
Upload_tmp_dir =
Temporary storage directory for file uploads. If not specified, PHP will use the system default temp directory. This option is empty by default, this option is also easy to forget when manually configuring PHP runtime environment, if you do not configure this option, the file upload function will not be implemented, you must assign this option, such as Upload_tmp_dir = "D:/fileuploadtmp", The representative has a fileuploadtmp directory under the D-Disk directory, and reads and writes permissions to this directory.
Upload_max_filesize = 2M
The maximum size of the uploaded file. The default value of this option is 2M, that is, file upload size is 2M, if you want to upload a 50M file, you must set upload_max_filesize = 50M.
However, only setting upload_max_filesize = 50M will not enable uploading of large files, and we must also modify the Post_max_size option in the php.ini file.
Continue to find Data handling in php.ini, there are 1 options in this area:
Post_max_size = 8M
Refers to the maximum value that can be received by a form post to PHP, including all values in the form. The default is 8M. If the post data exceeds the limit, then $_post and $_files will be empty.
To upload a large file, you must set the value of the option value greater than the upload_max_filesize option, for example you set upload_max_filesize = 50M, where you can put post_max_size = 100M.
In addition, if memory limits are enabled, the value should be less than the value of the Memory_limit option.
Continue to find Resource Limits in php.ini, there are 3 options in this area:
Max_execution_time = 30
Maximum time value (in seconds) for each PHP page to run, default 30 seconds. When we upload a larger file, such as 50M files, it is likely to take a few minutes to upload, but php default page the longest execution time is 30 seconds, more than 30 seconds, the script will stop execution, resulting in a situation where the Web page cannot be opened. So we can set the value larger, such as Max_execution_time = 600. If set to 0, no time limit is indicated.
Max_input_time = 60
The time (in seconds) that each PHP script takes to parse the request data, which defaults to 60 seconds. When we upload large files, we can set this value to a larger size. If set to 0, no time limit is indicated.
Memory_limit = 128M
This option is used to set the maximum memory space that a single PHP script can request. This helps prevent poorly written scripts from consuming the available memory on the optical server. If you do not need any in-memory restrictions, set it to-1.
php5.2.0 Previous version default 8M; The php.5.2.0 version defaults to 16M. PHP 5.2.0 After the default version is 128M;
php.ini Configuring the Upload file feature example
Suppose you want to upload a large file of 50M. The configuration php.ini is as follows:
on = "D:/fileuploadtmp"== = = = 128M
Tip: Need to keep Memory_limit > Post_max_size > Upload_max_filesize
6. Set the time zone
In the php.ini configuration file find;d Ate.timezone = (approximately 993 lines), remove the preceding semicolon ";" to read as follows:
Date. TimeZone = PRC
Date.timezone is a newly added configuration parameter for PHP5.1 to set the time zone. The default Date.timezone is commented out, and the default time zone is UTC Greenwich Mean time.
We changed here to Date.timezone = PRC (Prc,people's Republic of China, People's Republic of China), which is the date used in the Chinese time zone. This solves the problem of a time difference of eight hours.
Fifth Step: Configure phpMyAdmin
Open the PhpMyAdmin directory, that is, D:\WAMP\WWW\phpMyAdmin, we can see 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 to find $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 user name password is required for each login phpMyAdmin. This is also the default setting for phpMyAdmin.
Then find the $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 it to your own password.
Here are four ways to log in to phpMyAdmin:
Cookie: This is the default login method for phpMyAdmin configuration. You will need to enter your MySQL admin account and password at the login screen.
When you choose 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, login phpMyAdmin will prompt the "profile now requires a phrase password" error.
Config: Enter the phpMyAdmin login address directly in the address bar of the ground browser to log in and anyone can access it. The user name and password are set in advance in the configuration file.
This sign-in method must add the following 2 lines of 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, can be set to config login mode, eliminating the hassle of entering the password every time.
http: Popup A dialog box, enter the user name and password.
Signon: Similar to the page Jump login method, also need to set $cfg[' Servers ' [$i] [' Signonurl '], when you enter the phpMyAdmin login address will automatically jump to Signonurl set URL.
2. Turn on phpMyAdmin advanced features
After logging in to PhpMyAdmin, you will be prompted at the bottom of the first page: "PhpMyAdmin advanced features are not all set and some features are not available."
Now let's solve the problem. Using the phpMyAdmin Import feature, import the Phpmyadmin/scripts/create_tables.sql file to create the necessary data tables.
The next step is to create a new MySQL user and give it access to the data tables established in the previous operation, which is called the control user and provides support for PhpMyAdmin advanced features.
We use the PMA here as the control user and Pmapass as the password for the control user. You can change it yourself.
Enter the following SQL code in the phpMyAdmin SQL query function box:
GRANT USAGE on mysql.*-' 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) on mysql.tables_priv to ' pma ' @ ' localhost ';
We then found the line in config.inc.php with the User used to manipulate with storage. Remove the 2-line parameter comment (double slash "//") below it. The result is:
$cfg [' Servers '] [$i] [' controluser '] = ' PMA '; $cfg [' Servers '] [$i] [' controlpass '] = ' pmapass ';
These two lines are control user and control user password respectively. That is the user we created above.
Then find Storage database and tables this line, the following several parameters of the comments removed. The result is:
$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 ';
Sixth step: Test
Open service: Go to Apache's Bin directory and execute it sequentially:
Start
Save the following code as a index.php file, and put 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" >PHP$link=mysql_connect("localhost", "your MySQL admin account", "your MySQL admin password"); if(!$link)Echo"MySQL database connection failed!"; Else Echo"MySQL database connection succeeded!"; Mysql_close(); ?> </div> <br/> <?phpPhpinfo();?> </body>Then enter "http://localhost:8080/index.php" in the browser address bar.
Seventh step: Managing the Database
Http://localhost:8080/phpMyAdmin
Windows+apache Build PHP development environment