php fastcgi,配置apache以fastcgi运行php
apache默認是用自帶的mod_php模塊運行php,現(xiàn)在我們介紹使用fastcgi來執(zhí)行php腳本。先說下fastcgi的優(yōu)點:
Fastcgi的優(yōu)點:
從穩(wěn)定性上看, fastcgi是以獨立的進程池運行來cgi,單獨一個進程死掉,系統(tǒng)可以很輕易的丟棄,然后重新分 配新的進程來運行邏輯.
· 從安全性上看,Fastcgi支持分布式運算. fastcgi和宿主的server完全獨立, fastcgi怎么down也不會把server搞垮.
· 從性能上看, fastcgi把動態(tài)邏輯的處理從server中分離出來, 大負荷的IO處理還是留給宿主server, 這樣宿主server可以一心一意作IO,對于一個普通的動態(tài)網(wǎng)頁來說, 邏輯處理可能只有一小部分, 大量的圖片等靜態(tài)
IO處理完全不需要邏輯程序的參與.
· 從擴展性上講, fastcgi是一個中立的技術標準, 完全可以支持任何語言寫的處理程序 (php,java,perl,ruby,c++,python…)
· 適用操作系統(tǒng),可在任何平臺上http://www.fastcgi.com/dist/mod_fastcgi-current.tar.gz使用
安裝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
安裝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
完成之后編輯httpd.conf配置文件,加入fastcgi模塊裝載代碼:
LoadModule fastcgi_module modules/mod_fastcgi.so
安裝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
配置apache支持php
編輯httpd.conf文件,加入如下代碼:
### 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
AddHandler fcgid-script. .php .fcgi? ?### 暫時只配置支持.php
IdleTimeout 300
ProcessLifeTime 1800
MaxProcessCount 100
DefaultMinClassProcessCount 3
DefaultMaxClassProcessCount 8
IPCConnectTimeout 15
IPCCommTimeout 300
MaxRequestsPerProcess 100
### fastcgi ###
建立虛擬主機可以這樣配置:
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
Options Indexes ExecCGI
Order allow,deny
allow from all
總結(jié)
以上是生活随笔為你收集整理的php fastcgi,配置apache以fastcgi运行php的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php7和php8内核有区别吗,不要在P
- 下一篇: php用go做跳转翻页,go.php跳转