Configure Apache + FastCGI (mod_fastcgi) + PHP on RHEL5.3 (Tikanga)

Source: Internet
Author: User
I. Detailed version information using software: Apache (apache2.2.15) ApacheFastCGImodule (mod_fastcgi-2.4.6) PHP5.3.3 (php-cgi) read: Configure Apache + FastCGI (mod_fastcgi) on RHEL5.3 (Tikanga) + PHPhttp: // www.linuxidc.com/Linux/2012-02/

1. The detailed version information of the software used is as follows:
Apache (apache 2.2.15)
Apache FastCGI module (mod_fastcgi-2.4.6)
PHP 5.3.3 (php-cgi)

Related reading:

Configure Apache + FastCGI (mod_fastcgi) + PHP http://www.linuxidc.com/Linux/2012-02/53418.htm on RHEL 5.3 (Tikanga)

Build PHP + Memcached http://www.linuxidc.com/Linux/2012-02/53421.htm in RHEL 5.4 (Tikanga)

Build Git http://www.linuxidc.com/Linux/2012-02/53420.htm at RHEL 5.3 (Tikanga)

2. Detailed configuration steps:

(The premise of the following steps is that Apache and PHP (php-cgi) have been installed)

1. Install the mod_fastcgi module.

1) download:

Wget http://www.fastcgi.com/dist/mod_fastcgi-current.tar.gz

2) Compile and install from source code

Tar-xzvf mod_fastcgi-current.tar.gz

Cd mod_fastcgi-2.4.6


Cp Makefile. AP2 Makefile

Edit Makefile and modify the value of top_dir:/opt/httpd

(The value of top_dir is the installation directory of apache .)

Make

Make install

(Use updatedb to manually refresh the locate database and use locate mod_fastcgi.so to check whether mod_fastcgi is successfully installed .)

 

2. Configure Apache (mod_fastcgi provides three modes: static, dynamic, and external)

1) Search for the path of the binary file php-cgi (here I use to compile and install PHP 5.3.3 from the source code under the/opt directory, readers can use locate php-cgi to find it .)

/Opt/bin/php-cgi

 

2)

Static Mode

A. Add the following two lines to/opt/httpd/conf/httpd. conf:

[Xhtml]

  1. LoadModule fastcgi_module modules/mod_fastcgi.so
  2. Include conf. d/mod_fastcgi.conf

B. Create mod_fastcgi.conf IN THE/opt/httpd/conf. d directory.

[Xhtml]

  1. <IfModuleFastcgi_module>
  2. FastCgiServer/opt/httpd/cgi-bin/php. fcgi-processes 4
  3. # Define a new handler "php-fcgi" for ". php" files, plus the action that must follow
  4. AddHandler php-fcgi. php
  5. Action php-fcgi/cgi-bin/php. fcgi
  6. IfModule>

C. Create php. fcgi in the/opt/cgi-bin directory (note that the permission to modify this file is 755)

[Xhtml]

  1. #! /Bin/bash
  2. # Path to php. ini
  3. PHPRC=/Usr/local/lib
  4. ### Set PATH ###
  5. PHP_CGI=/Opt/bin/php-cgi
  6. PHP_FCGI_CHILDREN=2
  7. PHP_FCGI_MAX_REQUESTS=1000
  8. ### No editing below ###
  9. Export PHPRC
  10. Export PHP_FCGI_CHILDREN
  11. Export PHP_FCGI_MAX_REQUESTS
  12. Exec $ PHP_CGI

D. Use apachectl to check whether the configuration syntax is correct, and then restart Apache

[Root@www.linuxidc.com bin] #/opt/httpd/bin/apachectl configtest

[Root@www.linuxidc.com bin] #/opt/httpd/bin/apachectl restart

 

E. Create config. inc. php In the/opt/httpd/www directory and access it through a browser. (If the configuration is correct, the value of _ SERVER ["SERVER_SOFTWARE"] in the PHP Variables column is Apache/2.2.15 (Unix) mod_fastcgi/2.4.6)

[Xhtml]

  1. PhpPhpinfo ();?>

If you use ps axu | grep php-cgi for viewing, the number of php-cgi processes started with Apache is 13 (formula: max-process * (PHP_FCGI_CHILDREN + 1 )).

Related Article

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.