- 先用yum安裝好Apache、PHP
- 到 http://www.fastcgi.com/dist/ 下載最新的 mod_fastcgi
我是下載 http://www.fastcgi.com/dist/mod_fastcgi-2.4.6.tar.gz
wget http://www.fastcgi.com/dist/mod_fastcgi-2.4.6.tar.gz - 解壓縮
tar -zxvf mod_fastcgi-2.4.6.tar.gz - 安裝FastCGI
cd mod_fastcgi-2.4.6
cp Makefile.AP2 Makefile
make top_dir=/usr/lib/httpd
make install top_dir=/usr/lib/httpd
此時在 /usr/lib/httpd/modules/ 底下應該產生了 mod_fastcgi.so - 移除原本Apache的PHP設定
mv /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php.conf.bak - 設定Apache支援以FastCGI跑PHP
將/usr/bin/php-cgi這個檔複製一份到 /var/www/cgi-bin/底下
cp /usr/bin/php-cgi /var/www/cgi-bin/
於 /etc/httpd/conf.d/ 建立mod_fastcgi.conf檔案
vi /etc/httpd/conf.d/mod_fastcgi.conf
內容為
LoadModule fastcgi_module modules/mod_fastcgi.so
<IfModule fastcgi_module>
FastCgiServer /var/www/cgi-bin/php-cgi -processes 20
AddType application/x-httpd-php .php
AddHandler php-fastcgi .php
Action php-fastcgi /cgi-bin/php-cgi
</IfModule> - 重新啟動apache
/etc/init.d/httpd restart - 檢查
使用phpinfo()查看 Server API 是不是 CGI/FastCGI
再查看 FastCgiServer /var/www/cgi-bin/php-cgi -processes 20 設定有無生效
ps aux | grep php
應該會看到 20 個php-cgi的process,若沒有,可查看apache log
less /var/log/httpd/error
我查看後,error log顯示
Permission denied: FastCGI: can't create server "/var/www/cgi-bin/php-cgi"
所以沒有自動建立20個FastCgiServer
原因為/var/log/httpd 底下,系統建立了 fastcgi 資料夾,
但/var/log/httpd權限為700(root),所以apache無法對/var/log/httpd/fastcgi存取
解決方式為
chmod o+x /var/log/httpd
參考:
http://boomshadow.net/tech/php-handlers/ (DSO (mod_php) 、CGI 、suPHP、FastCGI比較)
http://www.fastcgi.com/drupal/?q=node/17#typical_httpd.conf
http://www.cnblogs.com/fangbo/archive/2011/12/02/2272400.html
http://wangyan.org/blog/apache-fastcgi-module.html
http://www.cyberciti.biz/tips/rhel-centos-fedora-apache2-fastcgi-php-configuration.html
http://blog.shian.tw/apache-fastcgi.html
http://www.felix021.com/blog/read.php?2022
http://hi.baidu.com/sky_traveller/blog/item/04a8291bcc8c7d1e4a90a7eb.html
http://hi.baidu.com/thinkinginlamp/blog/item/127209f77f3a9c26720eecda.html
http://fun.idv.tw/fun/2007/01/apache_2_fast-cgi_242_mt_334.html
http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html
http://www.pigo.idv.tw/archives/832
http://www.pigo.idv.tw/archives/827
http://blog.csdn.net/liu_hang_yu/article/details/7614185
http://blog.wu-boy.com/2012/06/fix-apache-mod_fcgid-http-request-length-136000-so-far-exceeds-maxrequestlen/
http://www.howtoforge.com/how-to-set-up-apache2-with-mod_fcgid-and-php5-on-centos-6.2
http://bbs.linuxtone.org/thread-5205-1-1.html
http://pzg.me/skill/1386/advanced-guide-fastcgi-incomplete/
http://hi.baidu.com/ihihshan/blog/item/c0c5ee227cb9d95b9822eddf.html
http://www.echotar.com/blog/index.php/archives/23/
http://syre.blogbus.com/logs/20092011.html
http://www.mike.org.cn/articles/what-is-cgi-fastcgi-php-fpm-spawn-fcgi/
沒有留言:
張貼留言