PHP-FastCGI的配置和測試(linux下)

來源:互聯網
上載者:User

一、配置PHP-FastCGI

1、安裝 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


2、編輯httpd.conf設定檔,加入fastcgi模組裝載代碼:
LoadModule fastcgi_module modules/mod_fastcgi.so


3、配置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
 
<IfModule mod_fcgid.c>
    AddHandler fcgid-script. .php .fcgi   ### 暫時只配置支援.php
    IdleTimeout 300
    ProcessLifeTime 1800
    MaxProcessCount 100
    DefaultMinClassProcessCount 3
    DefaultMaxClassProcessCount 8
    IPCConnectTimeout 15
    IPCCommTimeout 300
    MaxRequestsPerProcess 100
</IfModule>
### fastcgi ###


4、編輯httpd.conf檔案,建立虛擬機器主機可以這樣配置:
<VirtualHost *:80>
 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
 <Directory /usr/local/apache/htdocs>
 Options Indexes ExecCGI
 Order allow,deny
 allow from all
 </Directory>

</VirtualHost>


二、壓力測試

500人總共請求5000次,命令如下:

/usr/local/apache/bin/ab -c 500 -n 5000 http://localhost/index.php

以下為配置了PHP-FastCGI的測試結果:



以下為未配置PHP-FastCGI的測試結果:



三、總結

PHP-FastCGI的效能效果還是挺顯著的。。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.