Several ways to work with PHP under Apache

Source: Internet
Author: User

First, the CGI mode

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

# PHP4 Version
scriptalias/php/"d:/php/"
AddType application/x-httpd-php. php
Action application/x-httpd-php "/php/php.exe"
# PHP5 Version
scriptalias/php/"d:/php/"
AddType application/x-httpd-php. php
Action application/x-httpd-php "/php/php-cgi.exe"

Second, Apache module mode

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

# PHP4 Version
LoadModule php4_module "D:/php/php4apache2.dll"
AddType application/x-httpd-php. php
# Don't forget to copy the Php4apache2.dll from the SAPI directory!
# PHP5 Version
LoadModule php5_module "D:/php/php5apache2.dll"
AddType application/x-httpd-php. php
Phpinidir "d:/php"
# Phpinidir is the path used to indicate the PHP configuration file php.ini

Three, fastcgi mode

The FASTCGI module under Apache currently has two versions of mod_fastcgi and Mod_fcgid online. Recommended for Mod_fcgid.

Configuring fastcgi mode with Mod_fcgid

Download the mod_fcgid and copy the "mod_fcgid.so" file in the archive to Apache's "modules" directory. Open the Apache 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 storage directory    fcgidinitialenv PHPRC "d:/php"    # set php_fcgi_max_requests greater than or equal to fcgidmaxrequestsperprocess, Prevents the php-cgi process    from exiting fcgidinitialenv php_fcgi_max_requests    #php-cgi The maximum number    of requests per process before processing all requests Fcgidmaxrequestsperprocess    #php-cgi Maximum number of processes    fcgidmaxprocesses 5    #最大执行时间    fcgidiotimeout 120    fcgididletimeout    #php-cgi path    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    allowoverride all</directory>
  • 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.