前幾天做了個nginx+php-FastCGI+mysql的性能測試,正好這兩天沒事,索性延伸了一下,做了個小小的對比。
我管nginx+php-FastCGI+mysql叫LNMP了。
硬體環境:VMware虛拟的CentOS_v5.2、CPU:E7200 分了一個cpu、記憶體400MB DDR2-800。
測試結果:
測試結果說明:
測試軟體還是phpspeed,指令行的那個還沒學會。呵呵。
mysql都在預設配置基礎增加query_cache_size=4M,上篇文章說增加好多倍的就是這裡,不開的時候隻有2k-3k。
方案1:apache(fastcgi)+php(fastcgi)+mysql mysql用rpm安裝,其餘編譯安裝。
方案2:nginx+php(fastcgi)+mysql mysql用rpm安裝,其餘編譯安裝。
方案3:apache+php+mysql 全部rpm安裝。
項目1-6就是phpspeed裡面的那6個項目,分别為:
Synthetic PHP、Synthetic MySQL、Synthetic Read/Write
Real World PHP、Real World PHP & MySQL
Server Benchmark
附錄:
方案1環境配置過程:
1. rpm安裝mysql、msyql-devel
2. 編譯安裝apache2.2.x
3. 編譯安裝phpphp-5.2.8.tar.gz:
#tar zxf php-5.2.8.tar.gz
#cd php-5.2.8
#./configure --prefix=/usr/local/php -enable-fastcgi --enable-force-cgi-redirect --with-#mysql=/usr/lib/mysql --with-openssl
#make && make install
修改php.ini,打開output_buffering=4096,不然會有問題。
4. 編譯安裝mod_fastcgi-2.4.6:
#tar zxf mod_fastcgi-2.4.6.tar.gz
#cd mod_fastcgi-2.4.6
如果web伺服器是apache2
#cp Makefile.AP2 Makefile
#vi Makefile
把top_dir = /你的apache2的安裝目錄(預設是/usr/local/apache2)
安裝好以後在apache的 modules 目錄下會有一個mod_fastcgi.so
5. 編譯安裝fcgi-2.4.0.tar.gz
#tar zxf fcgi-2.4.0.tar
#cd fcgi-2.4.0
#./configure
6. 在http.conf中加入:
LoadModule fastcgi_module modules/mod_fastcgi.so
.Alias /fcgi-bin/ "/usr/local/php/bin/"
AddHandler php-fastcgi .php
Action php-fastcgi /fcgi-bin/php-cgi
AddType application/x-httpd-php .php
<Directory "/usr/local/php/bin/">
Options FollowSymLinks ExecCGI
AllowOverride None
Order allow,deny
allow from all
</Directory>
7. 檢查:
放個test.php到主目錄,看看是下載下傳還是顯示phpinfo。
php的fastcgi成功的話phpinfo裡面會有Server API=CGI/FastCGI這麼一行。
apache的mod_fastcgi會在運作phpspeed時看到。
本文轉自 sharkyan 51CTO部落格,原文連結:http://blog.51cto.com/sharkyan/127782,如需轉載請自行聯系原作者