PHP can be successfully run on the Apache server, it depends on how we configure the way PHP runs. There are three main ways in which PHP is run:
A, in the mode of loading the module to run, the beginner may not be easy to understand, in fact, is to integrate PHP into the Apache server to run the same process.
b, in the CGI operation, CGI English is called the Public Gateway Interface, is Apache in the encounter PHP script will be submitted to the CGI application (php-cgi.exe) interpretation, the explanation after the results are returned to Apache, and then returned to the appropriate requesting users.
C, run in a fastcgi manner. This form is a reinforced version of CGI, CGI is a single process, multi-threaded operation, the execution of the program will be destroyed, so each time you need to load the configuration and environment variable Fork-and-execute (Create-execute). And FastCGI is different, FastCGI like a resident (long-live) type of CGI, it can be carried out, as long as the activation, will not have to spend time to fork one time. The FASTCGI process Manager itself initializes, launches multiple CGI interpreter processes (multiple Php-cgi.exe visible in Task Manager) and waits for connections from the Web server. I will configure these three modes of operation separately:
1, regardless of the above mode of operation, the following configuration will usually add, unzip the PHP installation package to c:/php5/, Rename the Php.ini-recommend file as php.ini, looking for the following fields to edit, remove the preceding semicolon (note that the semicolon is not wrong, much is the comment information, carefully identified).
error_reporting = e_all//Open error, easy for programmers to check the wrong line 342display_errors = ON//Display error line 373extension_dir = "c:/php5/ext"//php extension options The directory where the files are located line 542date.timezone = Asia/shanhai//time zone configuration line 716
2, in the mode of operation, in Apache(c:/program files/apache software foundation/apache2.2/conf) configuration file to add the following configuration
LoadModule php5_module "C:/php5/php5apache2_2.dll"//approx. line 127PHPinidir "C:/php5/php.ini"//Modify Configuration DirectoryIndex index.html index.php//append index.phpaddtype application/x-httpd-php. php//line Add around 408
Next we are under the Apache root directory, the default C:/Program files/apache software foundation/apache2.2/htdocs new php file index.php, edit add the following code:
<?phpphpinfo ();? >
Then we enter http://localhost/in the address bar will appear the following interface: Note the relationship between the red and the configuration
3, theCGI way to run, you need to do the following configuration PHP configuration file
Cgi.force_redirect = 0//Original is 1 and remove the comment symbol;
Modify the Apache configuration to remove the original module configuration
AddType application/x-httpd-php phploadmodule php5_module "C:/php5/php5apache2_2.dll" PHPinidir "C:/php5/php.ini"
+ = Add the following configuration
AddHandler cgi-script. CGI//Line 396
Then we create a new CGI file in directory C:/Program Files/apache software Foundation/apache2.2/cgi-bin and write the following code:
#!c:/php5/php-cgi.exe<?php php phpinfo ();? >
Finally, we visited http://localhost/cgi-bin/test.cgi and the following results showed that the configuration was successful:
If you open more than one at a time, there will be many php-cgi.exe and disappear after execution is complete:
4, PHP fastcig Mode of operation, the first need to download the FastCGI module, the default is not with this module, and CGI is self-contained; Http://httpd.apache.org/mod_fcgid/. Unzip and copy the MoD _fcgid.so and mod_fcgid.pdb, the following configuration is done:
LoadModule fcgid_module modules/mod_fcgid.so//Line 128 append fcgidinitialenv phprc "c:/php5"//php config file line 129 append AddHandler Fcgid-script. PHP//Add handle suffix What kind of file needs fastcgi explanation line 407 append fcgidwrapper "C:/php5/php-cgi.exe". PHP//interpreter path line 408Options I Ndexes followsymlinks execcgi//line 221 append execcgi means directory allows execution of CGI scripts
Whether the installation is successful, only need to do a PHP file check on it, we will use the above index.php file:
Finally, the operation of PHP is finished, the beginner must personally test it, this tutorial has a certain degree of difficulty, to think repeatedly to understand the meaning, involving some professional knowledge, of course, you can use the module directly in the running mode, and so you have a certain understanding of PHP can then look back to this article , today I spent a few hours to organize the operation of PHP, due to the author's own limited level, the error is unavoidable!
Windows three ways to run PHP (Php_mod, CGI, fastcgi)