Home  >  Article  >  Backend Development  >  Several working methods of php under Apache

Several working methods of php under Apache

伊谢尔伦
伊谢尔伦Original
2016-11-25 13:55:241080browse

1. CGI mode

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

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

2. Apache module mode

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

# PHP4 version writing method
LoadModule php4_module "D:/php/php4apache2.dll"
AddType application/x-httpd-php .php
# Don't forget to add php4apache2 from the sapi directory Copy the .dll!
# PHP5 version writing method
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

3. FastCGI mode

The FastCGI module under Apache currently has two versions mod_fastcgi and mod_fcgid online. It is recommended to use mod_fcgid.

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 Apache's httpd.conf file and add the following configuration at the end:

LoadModule fcgid_module modules/mod_fcgid.so
<IfModule mod_fcgid.c>
    AddHandler fcgid-script .fcgi .php
    #php.ini的存放目录
    FcgidInitialEnv PHPRC "D:/PHP"
    # 设置PHP_FCGI_MAX_REQUESTS大于或等于FcgidMaxRequestsPerProcess,防止php-cgi进程在处理完所有请求前退出
    FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 1000
    #php-cgi每个进程的最大请求数
    FcgidMaxRequestsPerProcess 1000
    #php-cgi最大的进程数
    FcgidMaxProcesses 5
    #最大执行时间
    FcgidIOTimeout 120
    FcgidIdleTimeout 120
    #php-cgi的路径
    FcgidWrapper "D:/PHP/php-cgi.exe" .php
    AddType application/x-httpd-php .php
</IfModule>

Modify the configuration of the DocumentRoot path to:

<Directory "D:/WWW">  
    Options Indexes FollowSymLinks ExecCGI    Order allow,deny  
    Allow from all
    AllowOverride All
</Directory>


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn