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
- wget http://apache.ziply.com//httpd/httpd-2.2.21.tar.gz
- Tar xzf httpd-2.2.21.tar.gz
- CD httpd-2.2.21
- ./configure--prefix=/usr/local/apache
- Make && make install
Installing fastcgi
- wget http://www.fastcgi.com/dist/mod_fastcgi-2.4.6.tar.gz
- Tar xzf mod_fastcgi-2.4.6.tar.gz
- CD mod_fastcgi-2.4.6
- CP MAKEFILE.AP2 Makefile
- Make Top_dir=/usr/local/apache
- Make Top_dir=/usr/local/apache Install
After you finish editing the httpd.conf configuration file, add the FastCGI module to load the code:
- LoadModule Fastcgi_module modules/mod_fastcgi.so
Installing php5.2
- wget Http://us2.php.net/get/php-5.2.17.tar.gz/from/am.php.net/mirror
- Tar xzf php-5.2.17.tar.gz
- CD php-5.2.17
- ./configure--prefix=/usr/local/php--enable-fastcgi--disable-cli
- Make && make install
Configure Apache to support PHP
To edit the httpd.conf file, add the following code:
- # # # fastcgi # #
- scriptalias/fcgi-bin/"/usr/local/php/bin/"
- AddHandler php-fastcgi. php
- Action php-fastcgi/fcgi-bin/php-cgi
- AddType application/x-httpd-php. php
- <ifmodule mod_fcgid.c>
- AddHandler Fcgid-script. . php. fcgi # # # is temporarily only configured for support. PHP
- IdleTimeout 300
- Processlifetime 1800
- Maxprocesscount 100
- Defaultminclassprocesscount 3
- Defaultmaxclassprocesscount 8
- Ipcconnecttimeout 15
- Ipccommtimeout 300
- Maxrequestsperprocess 100
- </IfModule>
- # # # fastcgi # #
Setting up a virtual host can be configured like this:
- <virtualhost *:80>
- Documentroot/usr/local/apache/htdocs
- ServerName localhost
- Options +execcgi
- AddHandler Fastcgi-script. fcgi
- AddType application/x-httpd-php. php
- Action application/x-httpd-php/fcgi-bin/php-cgi
- <Directory/usr/local/apache/htdocs>
- Options Indexes execcgi
- Order Allow,deny
- Allow from all
- </Directory>
- </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