Getting started: A detailed explanation of PHP Dynamic Web page configuration in Windows environment

Source: Internet
Author: User
Tags character set file size flush ini mysql mysql client php programming phpmyadmin

  Getting Started: Detailed Windows PHP5+APACHE+MYSQ full configuration

After a period of frenzied PHP programming, the configuration of PHP under the Windows platform is a deep feeling, at first I used a button to install the fool bag, but consider the installation version of the Fool package has been behind, in the real manual configuration of the PHP environment encountered many problems, after consulting a lot of information and try, Finally configured successfully. Now, I will be my configuration experience and share with you, I believe you can solve the configuration of the PHP environment of confusion.

First of all, I use the software version.

PHP 5.1.6
Apache 2.0.59 (Note: Apache 2.2.X version above to add Plug-ins to support PHP 5)
MYSQL 5.0.24a

OK, now start the installation, I installed the PHP5, directly unzip the file to C:\php (installed to where there will be no impact, with personal hi, all the paths in this article to my installation path, please install on their own machine when the attention to modify their own path), and then install Apache, I put it directly into the C-packing directory, in the installation process, there will be 3 text boxes, above two input your native IP, the bottom of the input of your email, OK. Installation completed. Edit Now ... \apache group\apache2\conf\ under the httpd.conf file. Open the file in Notepad and add the last two lines of code:

LoadModule php5_module "C:/php/php5apache2.dll"
AddType application/x-httpd-php. php

I set up a www directory in the C:\ directory to store My site files, in httpd.conf find such a word: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, you may not change this item.

To modify the default home page for a directory:
Find DirectoryIndex behind the file name you want to set the home page, such as: index.html index.php.

Language priority, locate the following statement
languagepriority zh-cn ZH-TW en ca cs da de el eo et fr he hr it ja ko ltz nl nn no pl pt pt-br Ru sv put Chinese (zh-c N ZH-TW part of the cut to the front (that is, change the corresponding part of the original file as above.)

There's nothing else to change. Apach's configuration is here. Then talk about the configuration of PHP.

Copy the php.ini-dist to the C:\windows under the name php.ini (installed PHP have done it) and then modified a few places:

Find post_max_size = 8M under Data handling
This is the maximum size of post data that PHP will accept, and can be changed to 20M.

Find extension_dir= under Paths and directories
Here is the location of the PHP Search extension library, set its path to the location of the Extensions folder, which is changed to:
Extension_dir= "C:\php\ext"

Upload_max_filesize = 2M is found under file uploads to allow maximum file size to be uploaded
Can be changed to 20M.

Dynamic extensions This is the PHP extension Settings section, which lists all of the support extensions for PHP, preceded by a semicolon annotation, indicating that the current PHP configuration does not support scaling, We can remove the semicolon and let PHP support it. The extensions listed below are several common and more useful PHP extensions to remove the semicolon before the following sentences

; 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

Here PHP.ini the end of the configuration. And then a very important point will be
C:\php\libmysql.dll,c:\php\ext\php_mysql.dll,c:\php\ext\php_mysqli.dll
Copy to C:\Windows\system32, so PHP5 can support MySQL.

Restart Apache, create a new Notepad file in the home directory test input in
<?php
Phpinfo ();
?>
After saving, modify the suffix named PHP. In the browser input http://127.0.0.1/test.php is not see the PHP version information, yes, so the configuration of PHP is complete. Next install MySQL.

Step one: Double-click the first dialog box that appears for the. exe file to be selected is the Setup Type, which is
Installation type, here we can choose custom, according to their own needs to install components and configure the installation path

Click Next, right click on the dialog box to appear several hard disk shape icons, according to their own needs to choose the installation components,

Click on the Change button at the bottom right of the window to modify the installation path, after setting, click Next to install the installation to the most
There will be one of the following dialog boxes here three options are:

1: If you don't have a mysql.com account, choose the first one and create a new free mysql.com account

2: If you have a mysql.com account, select the second one, and fill in the registered mailbox name and password

3: Skip this step

We choose the first one.

There will be three dialog boxes at a time, and the parts of the three dialog boxes that have * must be filled in.
In order, the mailbox name, password, confirm password, the number one name, last name, zip code,
Country, province name. The name of China, the province selected other or N/a can 4.1.x and 4.0.x series version
This is a big difference is that after the installation is not running the MySQL folder under the Winmysqladmin.exe to
When you start the server, you set the options, but you have a setup procedure.

Step two: Set up MySQL

First you will see a window that has two options, namely detailed configuration and standard configuration,
Small application Select the second item you can click Next to appear in the following dialog box, this is important, must
To select MySQL41 in the Drop-down menu, it will not start properly, the following option is whether to apply the command line,
The best choice is to set the Database Password dialog box after clicking Next, and the center right and below options are respectively whether
Allow remote control and whether to allow anonymous account login, for security, do not choose the right, click Next to Out
Now the final dialog box, click the Execute button database server will be started, and then appear after four
Click Finish to finish installation

Test the connection after installing the phpMyAdmin, and if it appears
#1251-client does not support authentication protocol requested by server; Consider upgrading MySQL client
In the Start menu, locate the MySQL command-line tool that you just installed, and then type the password for root as follows:
Mysql> UPDATE mysql.user Set Password = Old_password (' Just set the root password ')
-> WHERE Host = ' localhost ' and User = ' root ';
Mysql> FLUSH Privileges (note that there are spaces after FLUSH)
Then browse "Http://localhost/phpmyadmin", OH yeah! Test success!

After talking about MySQL 4.1 due to the use of UTF8 caused by the garbled problem solution. First of all, in the new database when the character set must choose UTF8, in phpMyAdmin New database, create the left side of the button, there is a drop-down list, the default is "collation", select UTF8. You will find that the data in the table is not a question mark.
But the output of the page is still a question mark, do not hurry then in the PHP statement to be changed:
In Mysql_connect (.....) connection parameters); plus mysql_query ("SET NAMES ' GBK '");
But if a lot of web pages, this is not very troublesome, so I write PHP in the operation of all the database to write a class such as:

Class db{
.... contains some database call methods ....
Create a database connection and select the appropriate database
function Createcon () {
Mysql_connect (...); mysql_query ("SET NAMES ' GBK '");
}
}

In this way, to change a place on it, is it convenient? Oh, I believe you read this article in the PHP environment is difficult to configure, well, write so much, exhausted, I wish you all a happy learning!



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.