Detailed steps to build PHP environment _php instance

Source: Internet
Author: User

Next, go on to learn about how IIS supports PHP configuration:

1, go to PHP website download php:http://windows.php.net/download/. IIS7 We need to select more than 5.3 VC9 packages in PHP to download the zip file. As shown in figure:


2, unzip the ZIP package to the directory of your choice, such as C:\PHP\. after extracting the PHP package, copy the php.ini-production to the php.ini in the same directory. Then modify the configuration file php.ini. Directives that must be modified:

Extension_dir = < path to the extension library directory > -extension_dir need to point to the directory where the PHP extension library files are stored. can be an absolute path (such as "C:\PHP\ext") or a relative path (such as ". \ext"). The extension libraries to be loaded in the php.ini file must be in the directory specified by Extension_dir.

Extension = Xxxxx.dll -For each extension that needs to be activated, a row of corresponding "extension=" statements is required to describe which extensions are loaded in the Extension_dir directory when PHP starts.

log_errors = on-php with error logging can send error reports to a file, or system services (such as system logs), and the following

error_log instructions to work with. When running under IIS, the log_errors should be activated and be in conjunction with a valid error_log.

Error_log = < The path to the error log file > -error_log needs to point to a filename with an absolute or relative path to log the error log of PHP. The WEB server needs to have writable permissions on this file. The most commonly used locations are various temporary directories, such as "C:\inetpub\temp\php-errors.log".

cgi.force_redirect = 0 -this directive needs to be turned off when running under IIS. This is a directory security feature that needs to be activated on many other Web servers, but if activated under IIS, it can cause the PHP engine to make errors in Windows.

cgi.fix_pathinfo = 1 -this directive allows PHP to follow CGI rules to access true path information. The FastCGI implementation of IIS requires this directive to be activated.

fastcgi.impersonate = 1 -fastcgi under IIS supports the ability to simulate calling user side security tokens. This allows IIS to define the requestor's security context.

fastcgi.logging = 0 -fastcgi log should be closed under IIS. If activated, any message for any class is FastCGI as an error condition, causing IIS to produce an HTTP 500 error.

3. Configure instructions for cgi-and fastcgi-in the php.ini file:

Fastcgi.impersonate = 1 
fastcgi.logging = 0 
cgi.fix_pathinfo=1 
cgi.force_redirect = 0 

4. Use the IIS admin interface to create PHP's program mappings: Select handler mappings--> right Action--> Add module Mappings--> add PHP mappings--> Request Restrictions--> Select " The handler is invoked only if the request is mapped to the following content (I): "--> selected" file or folder (O)--> ok--> OK. As shown in the figure:




5, in IIS to set the index.php as the default document. Select the default document--> add--> edit index.php--> OK. As shown in figure:


6, add the test index.php file.

<?php 
 
phpinfo (); 
 

Save the file in the Web and directory. Restart IIS, browse the index.php file, and the PHP information page shows that your environment has been built successfully. As shown in the figure:


The above is I build IIS 7 and PHP server The whole process, I hope to help you learn.

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.