Whether PHP can be successfully run on the Apache server depends on how we 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 ).
Copy codeThe 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 ).
Copy codeThe 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:
Copy codeThe Code is as follows:
<? Php
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
Copy codeThe Code is as follows:
Cgi. force_redirect = 0 // originally 1 and remove the annotator;
Modify apache configuration and remove the original module configuration.
Copy codeThe 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
Copy codeThe 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:
Copy codeThe 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:
Copy codeThe 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!