php支持mod及php-cgi的方式
admin
2023-01-19 13:41:16
0


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的普及范围是有关系的

相关内容

热门资讯

特朗普:胡塞武装若封锁红海,美... 新华社华盛顿7月21日电(记者黄强 徐剑梅)美国总统特朗普21日在白宫会见到访的黎巴嫩总统奥恩时表示...
AI第一城|GOAI世界人工智... 7月21日上午,GOAI世界人工智能开源大赛(Global Open-source AI Chall...
刀闸阀行业解读:申奥阀门的技术... 在工业流体控制领域,高粘度介质、强腐蚀环境以及含固体颗粒的复杂工况,长期是制约管路系统安全运行的关键...
原创 华... 现在的手机屏幕做得是越来越大了,iPhone17 Pro Max也做了6.9英寸大屏,国产自然不能输...
WAIC2026:没有花架子,... 齐鲁晚报·齐鲁壹点 记者 任磊磊 “逛不完,根本逛不完!”在世界人工智能大会展馆现场,不少观众一边逛...
欧洲议会外委会首次派团访华,王... 2026年7月21日,中共中央政治局委员、外交部长王毅在北京会见欧洲议会外事委员会主席麦克阿里斯特率...
大熊猫“福虎”嘴角生疮,官方回... 7月21日,南京紫清湖野生动物世界发布通告,称“福虎”自嘴角边长疮至今,园区一直在中国大熊猫保护研究...
“生产车间没有一颗真水果”,这... 文|张宁燊你家楼下便利店的冷柜里,一定躺着几瓶印着“NFC”3个字母的果汁。透明瓶身中,颜色鲜艳的果...
福建宁德一鞋厂起火,两小时后被... 网络截图。7月21日,福建宁德霞浦县,网友反映有一鞋厂起火,视频显示,起火建筑中冒出阵阵黑烟。9时许...
美国的科学叛徒们惊叫“狼来了”... 中国AI发展突飞猛进,美国的芯片封锁无法阻止这个势头,让华盛顿陷入了恐慌。美国媒体Axios周一报道...