After a period of enthusiastic PHP programming, I was deeply touched by the configuration of PHP on the Windows platform. At first, I used a one-click installation of the dummies package, however, considering that the installation version of the dummies package is lagging behind, many problems are encountered when you manually configure the PHP environment. After reading a lot of information and trying to do so, the configuration is successful. Now, I will share my configuration experience with you. I believe this will solve your confusion when configuring the PHP environment.
First, let's talk about the software version I used.
PHP 5.1.6
Apache 2.0.59 (Note: To support PHP 5, add a plug-in later than Apache 2.2.x)
MySQL 5.0.24a
Now, start the installation. I installed PhP5 first, and directly decompress the file to C:/PHP (the installation won't be affected, thanks to my personal lucky number, all the paths in this article are based on my installation path. Please change the path to your own when installing it on your machine), and then install Apache, I directly installed it in the C root directory. During the installation process, three text boxes will appear, the above two enter your local IP address, and the bottom enter your email, OK. Installation is complete. Edit the httpd. conf file under ../Apache Group/apache2/CONF. Open the file in notepad and add the following two lines of code:
Loadmodule php5_module "C:/PHP/php5apache2_2.dll"
Addtype application/X-httpd-PHP. php
I created a WWW directory under the C:/directory to store my site files, in httpd. conf finds the following sentence: DocumentRoot "C:/apache2/htdocs" changed to DocumentRoot "C:/www ". In this way, the home directory is set to C:/www. If you do not want to change the home directory location, do not change this item.
Modify the default homepage of a directory:
Find the name of the file you want to set as the homepage after directoryindex, such as index.html index. php.
Language priority. Find the following statements.
Export agepriority ZH-cn zh-tw en ca CS da de El EO es et Fr he hr it Ja ko ltz nl nn no pl pt Pt-Br Ru SV set Chinese (zh-CN ZH -tw) cut the part to the Front (that is, change the corresponding part of the original file to the above.
There are no other changes. The configuration of Apach is here. Next, let's talk about the PHP configuration.
Copy PHP. ini-Dist to C:/windows and change it to PhP. ini (you have installed PHP before). Then, modify the following:
In data handling, locate post_max_size = 8 m
This is the maximum size of post data that PHP will accept, which can be changed to 20 mb.
Find extension_dir = under paths and directories
Here, the PHP search extension library location is set, and its path is set to the location of the extensions folder, that is, changed:
Extension_dir = "C:/PHP/EXT"
Under file uploads, find upload_max_filesize = 2 m, the maximum file size that can be uploaded
It can be changed to 20 mb.
Dynamic extensions is part of PHP extension settings. All extensions supported by PHP are listed. A semicolon comment is added before, indicating that the current PHP configuration does not support extension, we can remove the semicolon to allow PHP to support this extension. Below are a few common and useful PHP extensions listed below.
; Extension = php_mbstring.dll
; Extension = php_dba.dll
; Extension = php_dbase.dll
; Extension = php_filepro.dll
; Extension = php_gd2.dll
; Extension = php_imap.dll
; Extension = php_mysql.dll
The configuration of php. ini is complete. Next, it is very important
C:/PHP/libmysql. dll, C:/PHP/ext/php_mysql.dll, C:/PHP/ext/php_mysqli.dll
Copy to C:/Windows/system32 so that PHP5 can support MYSQL.
Restart APACHE and create a new notepad file named test in the main directory.
<? Php
Phpinfo ();
?>
Save and modify the suffix to PHP. Enter http: // 127.0.0.1/test. php In the browser to see the PHP version information. Next, install MYSQL.
Step 1: double-click the. exe file. The first dialog box to be selected is Setup Type, that is
Installation type. Here we can select Custom to install components and configure the installation path as needed.
Click Next, right-click the hard drive icon in the dialog box, and choose to install the component as needed,
Click the Change button in the lower-right corner of the window to Change the installation path. After setting the path, click Next to start installation.
The three options in the following dialog box are as follows:
1: If you do not have a MYSQL.com account, select the first account to create a new free MYSQL.com account.
2: If you have a MYSQL.com account, select the Second Account and enter the registered mailbox name and password.
3: skip this step
Select the first one.
Next, three dialog boxes are displayed. The "*" part in the three dialog boxes must be filled,
They are respectively the mailbox name, password, and confirm the password; first name, last name; zip code,
Country, Province name. Select china as the country name, and select other or N/A as the province name. Version 4.1.x and 4.0.x
One major difference is that after the installation is complete, winmysqladmin.exe is not running under the mysqlfolder.
After the server is started, you can set the options.
Step 2: Set MYSQL
First, you will see a window with two options: detailed configuration and standard configuration,
Select the second option for a small application and click Next. The following dialog box appears. This is important and must be
Select MySQL41 from the drop-down menu. Otherwise, the startup will fail. The following options are used to determine whether to apply the command line,
It is best to select the dialog box for setting the database password after clicking Next. The options in the middle right and below are:
Allow remote control and allow anonymous account login. For security reasons, do not select the option. Click Next to go out.
In the final dialog box, click Execute to start the database server.
Click Finish to end the installation.
Install PHPMYADMIN and test the connection.
#1251-Client does not support authentication protocol requested by server; consider upgrading MySQL client
Find the MYSQL command line tool installed in the Start Menu, enter the root password, and enter the following words:
Mysql> UPDATE mysql. user SET Password = OLD_PASSWORD ('root Password just SET ')
-> WHERE Host = 'localhost' AND User = 'root ';
Mysql> flush privileges; (Note that there are spaces after FLUSH)
Then browse "http: // localhost/phpmyadmin", oh yeah! Test successful!
Let's talk about how to solve the garbled problem caused by UTF8 after MYSQL 4.1. First of all, when creating a database, You must select UTF8 as the character set. In PHPMYADMIN, create a database. There is a drop-down list on the left of the create button. The default value is "sort ", select UTF8. You will find that the data in the table is not a question mark.
However, the webpage output is still a question mark. Do not change it in the PHP statement as soon as possible:
In mysql_connect (... Connection parameter); then add mysql_query ("set names 'gbk '");
However, if there are many web pages, this is not very troublesome, so when I write PHP, I will write all the database operations as a class such:
Class db {
.... Including some database call methods ....
// Create a database connection and select a database
Function createcon (){
Mysql_connect (...); Mysql_query ("set names 'gbk '");
}
}
In this way, you can change one location. Is it very convenient? Haha, I believe that it is difficult to configure the PHP environment after reading this article. Well, I am so tired to write so much. I wish you a pleasant learning experience!