标签:php-fpm php-cgi php编译安装 apache mod
PHP运行模式:
1)cgi 通用网关接口(Common Gateway Interface))
2) fast-cgi 常驻 (long-live) 型的 CGI
3) cli 命令行运行 (Command Line Interface)
4)web模块模式 (apache等web服务器运行的模块模式)
HTTPServer有三种架构比较流行:
(1)Apache+mod_php5
(2)lighttp+spawn-fcgi
(3)nginx+PHP-FPM
但在生产环境中,可能会遇到lamp架构与lnmp架构都在同一台物理服务器的环境,此时:
若php版本高于(包括)5.4,则直接编译php支持mod方式和php-cgi方式,参数如下:
./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
若php版本为5.3,则会报错如下:
+--------------------------------------------------------------------+ | *** ATTENTION *** | | | | You‘ve configured multiple SAPIs to be build. You can build only | | one SAPI module and CLI binary at the same time. | +--------------------------------------------------------------------+
若php版本低于(等于)5.2,编译参数同上,编译不会报错,但php-cgi命令不会安装成功。解决办法如下:
将mod_php和php-cgi方式分别指定不同目录安装,如下:
Apache+mod_php5
tar zxvf php-5.2.8.tar.gz gzip -cd php-5.2.8-fpm-0.5.10.diff.gz | patch -d php-5.2.8 -p1 cd php-5.2.8 patch -p1 < ../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.gz gzip -cd php-5.2.8-fpm-0.5.10.diff.gz | patch -d php-5.2.8 -p1 cd php-5.2.8 patch -p1 < ../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版本支持mod与fcgi共存的发展规律,与nginx的普及范围是有关系的
本文出自 “在路上” 博客,请务必保留此出处http://jacker.blog.51cto.com/1333001/1533940
php支持mod及php-cgi的方式,布布扣,bubuko.com
标签:php-fpm php-cgi php编译安装 apache mod
原文地址:http://jacker.blog.51cto.com/1333001/1533940