How PHP supports mods and php-cgi

Source: Internet
Author: User
Tags vars zts


PHP operating mode:

1) CGI Universal Gateway Interface (Common Gateway Interface))

2) fast-cgi resident (long-live) type CGI

3) CLI command line run (Interface)

4) Web module mode (module mode for Web server running like Apache)


Httpserver There are three types of architectures more popular:

(1) APACHE+MOD_PHP5

(2) lighttp+spawn-fcgi

(3) NGINX+PHP-FPM


However, in a production environment, you may encounter the environment where the lamp architecture and the LNMP architecture are in the same physical server, at this point:

if PHP version is higher than (including) 5.4, then directly compiled PHP support mod mode and php-cgi mode , the parameters are as follows:

./configure--prefix=/usr/local/php--enable-fastcgi--enable-fpm--with-gd--with-curl--with-jpeg-dir--with-zlib-- With-png-dir--with-freetype-dir--enable-magic-quotes--with-iconv--enable-sockets--enable-bcmath--enable-zip-- With-apxs2=/usr/local/apache2/bin/apxs--with-mysql=/usr/local/mysql--enable-force-cgi-redirect--enable-ftp-- Enable-mbstring--with-config-file-path=/usr/local/php/etc--with-libxml-dir--with-openssl-- Enable-maintainer-zts--with-pdo-mysql=/usr/local/mysql--with-mysqli=/usr/local/mysql/bin/mysql_config-- Enable-sysvsem--enable-shmop--enable-soap


If the PHP version is 5.3, the error will be as follows:

+--------------------------------------------------------------------+|                         ** * attention ***                            | |                                                                        | |  you ' Ve configured multiple sapis to be build. you can build  only   | |  one sapi module and&nbsP cli binary at the same time.                    |+------------------------------------------------ --------------------+


If the Php version is below (equal to) 5.2, the compilation parameter is the same as the compilation will not error, but the php-cgi command will not be installed successfully . The solution is as follows:

Specify a different directory installation for the mod_php and php-cgi methods, as follows:

Apache+mod_php5

tar zxvf php-5.2.8.tar.gzgzip -cd  Php-5.2.8-fpm-0.5.10.diff.gz | patch -d php-5.2.8 -p1cd php-5.2.8patch -p1 &NBSP;<&NBSP, .... /php-5.2.8-max-input-vars.patch./configure --prefix=/usr/local/php --with-gd --with-curl - -with-jpeg-dir --with-zlib --with-png-dir --with-freetype-dir --enable-magic-quotes - -with-iconv --enable-sockets --enable-bcmath --enable-zip --with-apxs2=/usr/local/apache2/ bin/apxs --with-mysql=/usr/local/mysql --enable-force-cgi-redirect --enable-ftp -- Enable-mbstring --with-config-file-path=/usr/local/php/etc --with-libxml-dir --with-openssl  --enable-maintainer-zts --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/ Mysql_config --enable-sysvsem --enable-shmop --enable-soap 

PHP-FPM

tar zxvf php-5.2.8.tar.gzgzip -cd  Php-5.2.8-fpm-0.5.10.diff.gz | patch -d php-5.2.8 -p1cd php-5.2.8patch -p1 &NBSP;<&NBSP, .... /php-5.2.8-max-input-vars.patch./configure --prefix=/usr/local/php-cgi --with-gd --with-curl  --with-jpeg-dir --with-zlib --with-png-dir --with-freetype-dir --enable-magic-quotes  --with-iconv --enable-sockets --enable-bcmath --enable-zip --enable-fastcgi -- Enable-fpm --enable-force-cgi-edirect --with-mysql=/usr/local/mysql --enable-force-cgi-redirect  --enable-ftp --enable-mbstring --with-config-file-path=/usr/local/php-cgi/etc -- with-libxml-dir --with-openssl --enable-maintainer-zts --with-pdo-mysql=/usr/local/mysql - -with-mysqli=/usr/local/mysql/bin/mysql_config --enable-sysvsem --enable-shmop --enable-soap 


PHP version supports the development of MOD and fcgi coexistence, which is related to the scope of Nginx's popularization.

This article is from the "on the Road" blog, please be sure to keep this source http://jacker.blog.51cto.com/1333001/1533940

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.