Three PHP running modes in Window: Graphic explanation _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
Three PHP running methods in Window are illustrated. Whether PHP can be successfully run on the Apache server depends on how we configure the PHP running mode. There are three main ways to run PHP so far: a. run PHP in the mode of module loading. If PHP can run successfully on the Apache server, it depends on how to configure the PHP running mode.

Currently, PHP is run in three ways:

A. It may be hard for beginners to understand how to load modules. In fact, it is to integrate PHP into the Apache server and run the same process.

Explain), explain the results returned to Apache, and then request the user.

C. run in FastCGI mode. This form is the enhanced CGI version. CGI is a single process and multi-thread running mode. after the program is executed, it will be destroyed, therefore, each time you load the configuration and environment variable fork-and-execute (create-execute ). FastCGI is different. FastCGI is like a long-live CGI, which can be executed all the time. Once activated, it will not take time to fork every time. FastCGI Process Manager initializes itself, starts multiple CGI interpreter processes (multiple php-cgi.exe in the Task Manager), and waits for a connection from the Web Server. Below I will configure the three running modes for edge splitting:

1. whatever the above method, the following configuration is usually added. unzip the PHP installation package to c:/PHP5/and rename PHP. the ini-recommend File is PHP. ini, edit the following fields respectively, and remove the semicolon (note not to mistake the semicolon, many of which are comments, carefully identified ).

The code is as follows:


Error_reporting = E_ALL // enable error reporting for programmers to troubleshoot line 342
Display_errors = On // The error line 373 is displayed.
Extension_dir = "C:/php5/ext" // Directory of the php extension option file line 542
Date. timezone = Asia/shanhai // Time zone configuration line 716



2. run as a module. add the following configuration in the configuration file of Apache (C:/Program Files/Apache Software Foundation/Apache2.2/conf ).

The code is as follows:


LoadModule php5_module "C:/php5/php5apache2_2.dll" // About line 127
PHPinidir "C:/php5/php. ini"
// Modify the configuration
DirectoryIndex index.html index. php // Append index. php
AddType application/x-httpd-php. php // line 408



Next, under the apache root directory, the default C:/Program Files/Apache Software Foundation/Apache2.2/htdocs creates the php file index. php and edits and adds the following code:

The code is as follows:


Phpinfo ();
?>



Then, enter http: // localhost/in the address bar to display the following interface: pay attention to the relationship between the red part and the configuration.

3. for cgi running, you need to configure the following: first, the php configuration file

The code is as follows:


Cgi. force_redirect = 0 // Originally 1 and remove the annotator;



Modify apache configuration and remove the original module configuration.

The code is as follows:


AddType application/x-httpd-php. php
LoadModule php5_module "C:/php5/php5apache2_2.dll"
PHPinidir "C:/php5/php. ini"



=> Add the following configuration

The code is as follows:


AddHandler cgi-script. cgi // line 396



Then, create a new cgi file test. cgi in the directory C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin and write the following code:

The code is as follows:


#! C:/php5/php-cgi.exe
Php phpinfo ();
?>



If you open multiple php-cgi.exe files at the same time, there will be a lot of php-cgi.exe files, and they will disappear after the execution is completed:

4. to run PHP in fastcig mode, you must first download the fastcgi module. this module is not included by default, while cgi is built-in:

The code is as follows:


LoadModule fcgid_module modules/mod_fcgid.so // line 128 append
FcgidInitialEnv PHPRC "c:/php5" // Append the php configuration file line 129.
AddHandler fcgid-script. php // add a handle, that is, the suffix of a file. fastcgi explains how to append line 407.
FcgidWrapper "c:/php5/php-cgi.exe". php // interpreter path line 408
Options Indexes FollowSymLinks ExecCGI // line 221 append ExecCGI, which means that the directory allows CGI script execution.



If the installation is successful, you only need to check the php file. we will use the following index. php file:

Finally, I have finished the PHP running method. beginners must experiment with it in person. this tutorial is difficult. you must think twice before you can understand what it means. it involves some professional knowledge, of course, you can directly use the module running mode for the moment. after you have some understanding of PHP, you can look back at this article. today, I spent several hours organizing the PHP running mode, due to the limited level of the author himself, errors are inevitable!

Bytes. PHP is run in three ways: a. It is run in the mode of module loading ,...

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.