Configure PHP + Apache + MySql in win7 [reprint + Supplement]

Source: Internet
Author: User
This post references the following post: http://apachewin7.jiaogen.com/2010/04/21/win7%E4%B8%8Bphp5-3apache2-2%E9%85%8D%E7%BD% AE/

 

Http://www.umgr.com/Blog/PostView.aspx? Bpid = 1, 67938

 

Http://www.cnblogs.com/good_hans/archive/2010/04/01/1702059.html

 

 

 

(1) install and configure Apache (install it to D: \ myprograms \ apache)

 

 

You can use localhost and administrator's email address if the network domain and server name are not installed by default. You can modify the information in the httpd. conf file later. After Apache is started, Use http: // localhost/or http: // 127.0.0.1 to test whether it is successful. If it succeeds, there will be an it works on the screen!

For Apache configuration, see the following content.

(2) Configure PHP (decompress the PHP compressed package to D: \ myprograms \ PHP \)

First of all, for the PHP version Description: PHP version: php-5.3.2-Win32-VC6-x86, vc9 is specifically customized for IIS, vc6 is provided for other Web service software, such as Apache.

 

Decompress PHP to a non-Chinese path without spaces (I use D: \ myprograms \ PHP \ Program, and the detailed installation steps are displayed in the install.txt file of the installation document. The installation steps are full of E files and very detailed, it is estimated that many people may not be patient with reading it, but it is really useful and will be used as a reference later in this article.

If you are installing PHP 5, extract to c: \ php as the ZIP file doesn' t expand as in PHP 4. you may choose a different location but do not have spaces in the path (like c: \ Program Files \ PHP) as some Web servers will crash if you do.

So please confirm again that the decompression path does not contain spaces.

All DLL files need to be copied to the system folder (% SystemRoot % \ system32) according to the internet and most teaching materials. I personally do not like this practice. There is a description in install.txt:

To make php5ts. DLL available you have three options: copy the file to the Windows System directory, copy the file to the web server's directory, or add your PHP Directory, C: \ PHP to the path. for better maintenance, we advise you to follow the last option, add c: \ PHP to the path, because it will be simpler to Upgrade PHP in the future. read more about how to add your PHP Directory to path in the corresponding FAQ entry (and then don't forget to restart the computer-Logoff isn't enough ).

Therefore, for future upgrade and maintenance convenience, the best way is to add the PHP decompression path (such as D: \ myprograms \ PHP \) to the path environment variable, and then reboot.

PHP stores two files in the decompression path: PHP. ini-Development and php.ini-production. although install.txt strongly recommends the latter for standard servers, it is suitable for PHP for development. ini-development, which is backed up and renamed as PHP. INI, open it in a text editor.

First, find extension_dir, which is used to specify the location of the PHP extension DLL. You can change the line on Windows

Extension_dir = "D: \ myprograms \ PHP \ Ext"

Search for doc_root, which is used to specify the root path of the web server and change it

Doc_root = "D: \ myprograms \ PHP \ apache \ htdocs"; if you want to change the root path later, enter the new root path.

Then select to run some extensions required by PHP, search for extension, and remove the comments semicolon before the following extension.

Extension = php_gd2.dll
Extension = php_imap.dll
Extension = php_mysql.dll; required to use MySQL
Extension = php_mysqli.dll; required to use MySQL

Save and disable PHP. ini.

==== Configure Apache ====

First, check whether there is a php5apache2_2.dll file in the PHP decompression path (if not, it indicates that you have selected the PHP compressed package version). Then, open httpd In the conf directory under the Apache installation directory with a text editor. CONF file to check whether the following statements exist in loadmodule. If not, add the following statements to all loadmodules:

Loadmodule php5_module D:/myprograms/PHP/php5apache2_2.dll # load the PHP Module
Phpinidir "D:/myprograms/PHP" # specify the path of PHP. ini
Addtype application/X-httpd-PHP. php # Allow PHP syntax to be used in. php files
Addtype application/X-httpd-PHP. html # signature extension. Remember, this will eventually lead to a consequence. Every time you request an HTML file, the file will be parsed by PHP. "(Derived from PHP and mysql5 programming), we do not recommend adding this sentence.
(The above # And the following prompts may sometimes cause the problem that the apache service cannot be started. It is best to remove the annotations .)
If you need to change the web root path, you can find DocumentRoot and modify the relevant lines:

DocumentRoot "D:/myprograms/Apache/htdocs"

At the same time, you must make changes in the following areas:

<Directory "D:/myprograms/Apache/htdocs">

Next, find directoryindex. this parameter indicates that urlis the sequence of the uploaded files in the latest directory. It is usually index.php, index.html, and so on. You can use the following settings for PHP:

Directoryindex index. php index.html default. php default.html

Note that the file names are separated by spaces.

If you need to modify the port, search for the value after the listen modification.

Save and close httpd. conf, double-click the Apache tray icon to open the interface, and click restart to restart Apache.

Then we can test whether PHP works normally. Create a test. php file in the Web root path (htdocs in the Apache installation directory by default) and add the following line of content.

<? PHP phpinfo ();?>

Save and exit. Enter http: // localhost/test. php In the browser. If detailed PHP configuration information is displayed, the configuration is successful.

 

 

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.