Configure Apache to run PHP fastcgi

Source: Internet
Author: User

Configure Apache to run PHP article directory fastcgi[Hide]
    • Installing Apache
    • Installing fastcgi
    • Installing php5.2
    • Configure Apache to support PHP

Apache runs PHP by default with its own mod_php module, and now we describe using fastcgi to execute PHP scripts. First, the advantages of fastcgi:
Advantages of fastcgi:

    • In terms of stability, fastcgi is a separate process pool to run CGI, a single process is dead, the system can easily discard, and then reassign new processes to run the logic.
    • · From a security perspective, FASTCGI supports distributed operations. FastCGI and the host server are completely independent, fastcgi how to down will not bring the server down.
    • · From the performance perspective, fastcgi the processing of dynamic logic from the server, the heavy-duty IO processing is left to the host server, so that the host server can be a single-minded Io, for a normal Dynamic Web page, the logic processing may be only a small part, a large number of pictures and other static
    • IO processing does not require the participation of logic programs at all.
    • · In terms of extensibility, fastcgi is a neutral technical standard that can be fully supported in any language written processing program (Php,java,perl,ruby,c++,python ...).
    • · Applicable operating system, can be used on any platform http://www.fastcgi.com/dist/mod_fastcgi-current.tar.gz
Installing Apache
    1. wget http://apache.ziply.com//httpd/httpd-2.2.21.tar.gz
    2. Tar xzf httpd-2.2.21.tar.gz
    3. CD httpd-2.2.21
    4. ./configure--prefix=/usr/local/apache
    5. Make && make install
Installing fastcgi
    1. wget http://www.fastcgi.com/dist/mod_fastcgi-2.4.6.tar.gz
    2. Tar xzf mod_fastcgi-2.4.6.tar.gz
    3. CD mod_fastcgi-2.4.6
    4. CP MAKEFILE.AP2 Makefile
    5. Make Top_dir=/usr/local/apache
    6. Make Top_dir=/usr/local/apache Install

After you finish editing the httpd.conf configuration file, add the FastCGI module to load the code:

    1. LoadModule Fastcgi_module modules/mod_fastcgi.so
Installing php5.2
    1. wget Http://us2.php.net/get/php-5.2.17.tar.gz/from/am.php.net/mirror
    2. Tar xzf php-5.2.17.tar.gz
    3. CD php-5.2.17
    4. ./configure--prefix=/usr/local/php--enable-fastcgi--disable-cli
    5. Make && make install
Configure Apache to support PHP

To edit the httpd.conf file, add the following code:

    1. # # # fastcgi # #
    2. scriptalias/fcgi-bin/"/usr/local/php/bin/"
    3. AddHandler php-fastcgi. php
    4. Action php-fastcgi/fcgi-bin/php-cgi
    5. AddType application/x-httpd-php. php
    6. <ifmodule mod_fcgid.c>
    7. AddHandler Fcgid-script. . php. fcgi # # # is temporarily only configured for support. PHP
    8. IdleTimeout 300
    9. Processlifetime 1800
    10. Maxprocesscount 100
    11. Defaultminclassprocesscount 3
    12. Defaultmaxclassprocesscount 8
    13. Ipcconnecttimeout 15
    14. Ipccommtimeout 300
    15. Maxrequestsperprocess 100
    16. </IfModule>
    17. # # # fastcgi # #

Setting up a virtual host can be configured like this:

    1. <virtualhost *:80>
    2. Documentroot/usr/local/apache/htdocs
    3. ServerName localhost
    4. Options +execcgi
    5. AddHandler Fastcgi-script. fcgi
    6. AddType application/x-httpd-php. php
    7. Action application/x-httpd-php/fcgi-bin/php-cgi
    8. <Directory/usr/local/apache/htdocs>
    9. Options Indexes execcgi
    10. Order Allow,deny
    11. Allow from all
    12. </Directory>
    13. </VirtualHost>

For detailed fastcgi instruction configuration see: http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html

Reprint please indicate the article source: "https://www.centos.bz/2011/12/configure-apache-run-php-as-fastcgi/"

Configure Apache to run PHP fastcgi

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.