nginx和apache的PK

首先说明下环境,内存大小都是1G,CPU采用inter的i7处理器,都在vm虚拟机中测试,虚拟机给的cpu核数都是1

场景1:client------>nginx------>html,client------>apache--------->html

首先搭建nginx

使用rpm包安装nginx

rpm -ivh nginx-0.6.36-1.el5.i386.rpm

配置nginx

server {

listen 80;

server_name=www.joker.com;

location / {

root /tmp/www;

index index.html;

}

}

启动服务,使用ab命令测试,ab -n 10000 -c 500 http://192.168.1.105/index.html

时间是:

在另外的服务器上安装apache

yum install httpd -y

echo 1 > /var/www/html/index.html

service httpd restart

ab -n 10000 -c 500 http://192.168.1.104/index.html

时间是:

场景2:nginx和apache处理apache(nginx+php在一台机器上,apache+php在一台机器上)

nginx处理php页面

client------->nginx+php

安装nginx

rpm -ivh nginx-0.6.36-1.el5.i386.rpm

安装php和spawn

yum install php -y

rpm -ivh spawn-fcgi-1.6.3-1.el5.i386.rpm

cp /tmp/php_cgi.txt /etc/init.d/php_cgi

chmod +x /etc/init.d/php_cgi

mkdir -pv /tmp/www

vim /tmp/www/index.php

<?

phpinfo();

?>

/etc/init.d/php_cgi start

vim /etc/nginx/nginx.conf

server {

listen 80;

server_name www.joker.com;

location ~ \.php$ {

root /tmp/www;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME /tmp/www/$fastcgi_script_name;

include fastcgi_params;

}

}

使用ab测试的效果ab -n 10000 -c 500 http://192.168.18.65/index.php

apache处理php页面

client------->apache+php

安装apache+php

yum install httpd php* -y

vim /var/www/html/index.php

<?

phpinfo();

?>

ab -n 10000 -c 500 http://192.168.18.105/index.php

场景3:

nginx和php分离

安装

apache和php分离

 

本文出自 “海纳百川” 博客,谢绝转载!

你可能感兴趣的:(nginx和apache的PK)