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]
- LoadModule fastcgi_module modules/mod_fastcgi.so
- Include conf. d/mod_fastcgi.conf
B. Create mod_fastcgi.conf IN THE/opt/httpd/conf. d directory.
[Xhtml]
- <IfModuleFastcgi_module>
- FastCgiServer/opt/httpd/cgi-bin/php. fcgi-processes 4
- # Define a new handler "php-fcgi" for ". php" files, plus the action that must follow
- AddHandler php-fcgi. php
- Action php-fcgi/cgi-bin/php. fcgi
- IfModule>
C. Create php. fcgi in the/opt/cgi-bin directory (note that the permission to modify this file is 755)
[Xhtml]
- #! /Bin/bash
- # Path to php. ini
- PHPRC=/Usr/local/lib
- ### Set PATH ###
- PHP_CGI=/Opt/bin/php-cgi
- PHP_FCGI_CHILDREN=2
- PHP_FCGI_MAX_REQUESTS=1000
- ### No editing below ###
- Export PHPRC
- Export PHP_FCGI_CHILDREN
- Export PHP_FCGI_MAX_REQUESTS
- 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]
- 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 )).