php支援mod及php-cgi的方式

來源:互聯網
上載者:User

標籤: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.gzgzip -cd php-5.2.8-fpm-0.5.10.diff.gz | patch -d php-5.2.8 -p1cd php-5.2.8patch -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.gzgzip -cd php-5.2.8-fpm-0.5.10.diff.gz | patch -d php-5.2.8 -p1cd php-5.2.8patch -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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.