Web 服务器基准测试,nginx+php vs Apache+php
本次测试nginx+php与apache+php哪种组合的计算性能及稳定性更佳
操作系统:Centos6.4 x64
硬件环境:
服务器IP | 硬件配置 | 角色 |
192.168.1.2 | 4核心 8GB | 基准测试服务器 |
192.168.1.3 | 略 | 基准测试客户端 |
实验思路:在本次测试中打算采用,同版本组合测试,如(nginx1.4.4+php5.5.7)vs (httpd2.4.2+php5.5.7) 和 (nginx+php7) vs(apache+php7),测试程序有两种,分别为算法程序和连接数据库的读写程序。
首先安装环境
这里只讲Apache的安装配置nginx配置简单(略)
如不熟悉请参考:http://tchuairen.blog.51cto.com/3848118/1437530
一、编译Apache
Apache官网:http://httpd.apache.org/
这里使用httpd2.4.2 其他httpd2.4.x系列安装配置都是差不多的。
1、安装依赖包
[code=bash;toolbar:false">tar -zxvf apr-1.5.0.tar.gz cp -rf apr-1.5.0 httpd-2.4.2/srclib/apr tar -zxvf apr-util-1.5.3.tar.gz cp -rf apr-util-1.5.3 httpd-2.4.2/srclib/apr-utilServerRoot "/alidata/server/httpd"
Listen 80
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule reqtimeout_module modules/mod_reqtimeout.so
LoadModule filter_module modules/mod_filter.so
LoadModule mime_module modules/mod_mime.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule env_module modules/mod_env.so
LoadModule headers_module modules/mod_headers.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule version_module modules/mod_version.so
LoadModule unixd_module modules/mod_unixd.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule dir_module modules/mod_dir.so
LoadModule alias_module modules/mod_alias.so
LoadModule php5_module modules/libphp5.so
<IfModule unixd_module>
User daemon
Group daemon
</IfModule>
ServerAdmin you@example.com
<Directory />
AllowOverride none
Require all denied
</Directory>
DocumentRoot "/alidata/server/httpd/htdocs"
<Directory "/alidata/server/httpd/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
<Files ".ht*">
Require all denied
</Files>
ErrorLog "logs/error_log"
LogLevel warn
<IfModule log_config_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
<IfModule logio_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
CustomLog "logs/access_log" common
</IfModule>
<IfModule alias_module>
ScriptAlias /cgi-bin/ "/alidata/server/httpd/cgi-bin/"
</IfModule>
<IfModu
4000
le cgid_module>
</IfModule>
<Directory "/alidata/server/httpd/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
<IfModule mime_module>
TypesConfig conf/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
</IfModule>
<IfModule proxy_html_module>
Include conf/extra/proxy-html.conf
</IfModule>
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>[p][strong]./configure --prefix=/alidata/server/php-Apache \
--enable-opcache \
--with-config-file-path=/alidata/server/php-Apache/etc \
--with-apxs2=/alidata/server/httpd/bin/apxs \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--enable-static \
--enable-maintainer-zts \
--enable-zend-multibyte \
--enable-inline-optimization \
--enable-sockets \
--enable-wddx \
--enable-zip \
--enable-calendar \
--enable-bcmath \
--enable-soap \
--with-zlib \
--with-iconv \
--with-gd \
--with-xmlrpc \
--enable-mbstring \
--without-sqlite \
--with-curl \
--enable-ftp \
--with-mcrypt \
--with-freetype-dir=/usr/local/freetype.2.1.10 \
--with-jpeg-dir=/usr/local/jpeg.6 \
--with-png-dir=/usr/local/libpng.1.2.50 \
--disable-ipv6 \
--disable-debug \
--with-openssl \
--disable-maintainer-zts \
--disable-safe-mode \
--disable-fileinfo[p]/* catch legitimate fatal apr_socket_recv errors */
else if (status != APR_SUCCESS) {
err_recv++;
if (recverrok) {
bad++;
close_connection(c);
if (verbosity >= 1) {
char buf[120];
fprintf(stderr,"%s: %s (%d)\n", "apr_socket_recv", apr_strerror(status, buf, sizeof buf), status);
}
return;
} else {
//apr_err("apr_socket_recv", status); // 从这开始
bad++;
close_connection(c);
return; // 到这里
}
}[p]Transactions: 18922 hits
Availability: 94.85 %
Elapsed time: 453.87 secs
Data transferred: 102.05 MB
Response time: 3.05 secs
Transaction rate: 41.69 trans/sec
Throughput: 0.22 MB/sec
Concurrency: 127.28
Successful transactions: 18922
Failed transactions: 1028
Longest transaction: 18.40
Shortest transaction: 0.00[p]
- Web 服务器基准测试,nginx+php vs Apache+php
- Nginx 0.8.x + PHP 5.2.13(FastCGI)搭建胜过Apache十倍的Web服务器
- Nginx 0.8.x + PHP 5.2.13(FastCGI)搭建胜过Apache十倍的Web服务器
- apNginx 0.5.35 + PHP 5.2.5(FastCGI)搭建胜过Apache 10倍的Web服务器
- 张宴 Nginx 0.8.x + PHP 5.2.13(FastCGI)搭建胜过Apache十倍的Web服务器
- 搭建高性能Web服务器Nginx,10倍于Apache---Nginx+Php(FastCgi模式)
- PHPWAMP、IIs、Nginx、Apache三大主流web服务器伪静态的详细设置过程
- 搭建高性能Web服务器Nginx,10倍于Apache---Nginx+Php(FastCgi模式)
- Nginx 0.7.x + PHP 5.2.9(FastCGI)搭建胜过Apache十倍的Web服务器
- Nginx 0.8.x + PHP 5.2.13(FastCGI)搭建胜过Apache十倍的Web服务器
- PHP web服务器终极解决方案:CentOS v6.x Minimal 32bit + LNAMP 一键安装包【Linux+Nginx+Apache+MySQL+PHP+phpMyAdmin】
- Nginx 0.8.x + PHP 5.2.13(FastCGI)搭建胜过Apache十倍的Web服务器
- Nginx 0.8.x + PHP 5.2.10(FastCGI)搭建胜过Apache十倍的Web服务器
- PHP实现每隔1秒(一秒)输出一条信息:禁用PHP缓存和web服务器(兼容Nginx、Apache)缓存、浏览器缓存
- nginx 0.8.x + PHP 5.2.13 胜过apache十倍的web服务器
- nginx 0.8.x + PHP 5.2.13 胜过apache十倍的web服务器
- Nginx+Apache+Mysql+Php+eaccelerator+Zend构建高性能的WEB服务器
- Nginx 0.7.x + PHP 5.2.9(FastCGI)搭建胜过Apache十倍的Web服务器
- Nginx 0.7.x + PHP 5.2.6(FastCGI)搭建胜过Apache十倍的Web服务器
- Nginx+Apache+Mysql+Php+eaccelerator+Zend构建高性能的WEB服务器