安装php 5.3.3(5.3.3已包括fpm)
安装php 5.3.3(5.3.3已包括fpm):
wget http://cn.php.net/get/php-5.3.3.tar.bz2/from/this/mirror
tar -jxvf php-5.3.3.tar.bz2
cd php-5.3.3
./configure --prefix=/usr/home/yaoya/php --enable-fpm
make
make install
配置php:
cp php.ini-development /usr/home/yaoya/php/lib/php.ini
cd /usr/home/yaoya/php/etc
cp php-fpm.conf.default php-fpm.conf
编辑php-fpm.conf
[global]
pid = /usr/home/yaoya/php/var/run/php-fpm.pid
error_log = /usr/home/yaoya/php/var/log/php-fpm.log
log_level = notice
[www]
listen = 127.0.0.1:9000
user = yaoya
group = yaoya
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
启动php fastcgi:
/usr/home/yaoya/php/sbin/php-fpm
安装nginx 0.7.67:
wget http://nginx.org/download/nginx-0.7.67.tar.gz
cd nginx-0.7.67
./configure --prefix=/usr/home/yaoya/nginx
make
make install
配置nginx(nginx.conf):
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/home/yaoya/nginx/html/scripts$fastcgi_script_name;
include fastcgi_params;
}
启动nginx:
/usr/home/yaoya/nginx/sbin/nginx
使用ab进行压力测试,和apache2对比:(100000次)
100并发:
apache html(1k):12455.30
nginx html(1k):15127.89
apache php(phpinfo):1158.29
nginx php(phpinfo):3759.40
500并发:
apache html(1k):7884.27
nginx html(1k):16394.00
apache php(phpinfo):1181.46
nginx php(phpinfo):3542.59
结论nginx和apache在默认设置下单台处理性能比约为3:1。
转:http://yaoya.org/wp/index.php/post/93