How PHP works in Apache

Source: Internet
Author: User
There are three ways for PHP to work in Apache: CGI mode, Apache module DLL, FastCGI mode, and I. CGI mode: CGI mode in Apache2. Edit the Apache configuration file httpd. conf as follows: # ScriptAliasphpD in PHP4: php Apache

There are three ways for PHP to work in Apache: CGI mode, Apache module DLL, FastCGI mode,

I. CGI mode

CGI mode of PHP in Apache 2. Edit the Apache configuration file httpd. conf as follows:

# PHP4
ScriptAlias/php/"D:/php /"
AddType application/x-httpd-php. php
Action application/x-httpd-php "/php/php.exe"
# PHP5
ScriptAlias/php/"D:/php /"
AddType application/x-httpd-php. php
Action application/x-httpd-php "/php/php-cgi.exe"

II. Apache module mode

Module mode of PHP in Apache 2. Edit the Apache configuration file httpd. conf as follows:

# PHP4
LoadModule php4_module "D:/php/php4apache2. dll"
AddType application/x-httpd-php. php
# Do not forget to copy php4apache2. dll from the sapi directory!
# PHP5
LoadModule php5_module "D:/php/php5apache2. dll"
AddType application/x-httpd-php. php
PHPIniDir "D:/php"
# PHPIniDir is used to specify the php configuration file php. ini path

III. FastCGI mode

The FastCGI module under Apache currently has two versions on the Internet: mod_fastcgi and mod_fcgid. Mod_fcgid is recommended.

Use mod_fcgid to configure fastCGI mode

Download mod_fcgid and copy the "mod_fcgid.so" file in the compressed package to the "modules" directory of apache. Open the httpd. conf file of Apache and add the following configuration at the end:

LoadModule fcgid_module modules/mod_fcgid.so
 
  
AddHandler fcgid-script. fcgi. php # php. ini storage directory FcgidInitialEnv PHPRC "D:/PHP" # set PHP_FCGI_MAX_REQUESTS to be greater than or equal to FcgidMaxRequestsPerProcess, prevent the php-cgi process from exiting FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 1000 # maximum number of requests for each php-cgi process FcgidMaxRequestsPerProcess 1000 # maximum number of php-cgi processes FcgidMaxProcesses 5 # Maximum execution fcgidIOTimeout 120 FcgidIdleTimeout 120 # php-cgi path FcgidWrapper "D: /PHP/php-cgi.exe ". php AddType application/x-httpd-php. php
 

Modify the configuration of the DocumentRoot path:

 
        Options Indexes FollowSymLinks ExecCGI    Order allow,deny      Allow from all    AllowOverride All
 

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.