<meta charset="utf-8">
1.按照下图完成Apache的下载及安装( http://httpd.apache.org/ )
下载好解压到指定目录下。
2.使用
命令行下进入Apache下的bin目录,输入:http -k install,将Apache安装成windows后台服务。
E:\Apache\Apache24\bin>httpd -k install
Installing the 'Apache2.4' service
The 'Apache2.4' service is successfully installed.
Testing httpd.conf....
Errors reported here must be corrected before the service can be started.
httpd: Syntax error on line 39 of E:/Apache/Apache24/conf/httpd.conf: ServerRoot must be a valid directory
这时安装时失败的,错误信息告诉你应该以管理员的身份运行,这个时候我们找到C:\Windows\System32下的cmd.exe右键单击选择“以管理员身份运行”
接下来还要做一件事,我们打开E:\Apache\Apache24\conf下的httpd.conf,将其中的serverroot指向你的安装位置:
Define SRVROOT "E:/Apache/Apache24" ServerRoot "${SRVROOT}"
然后执行命令:httpd -k uninstall,并再次执行安装命令httpd -k install
E:\Apache\Apache24\bin>httpd -k uninstall
Removing the 'Apache2.4' service
The 'Apache2.4' service has been removed successfully.
E:\Apache\Apache24\bin>httpd -k install
Installing the 'Apache2.4' service
The 'Apache2.4' service is successfully installed.
Testing httpd.conf....
Errors reported here must be corrected before the service can be started.
表示安装成功,随后执行
E:\Apache\Apache24\bin>httpd -k start
浏览器中输入http://localhost测试是否成功。
3.ab测试
Apache Benchmark简称ab,是Apache自带的用http server测试工具
E:\Apache\Apache24\bin>ab -n1000 -c10 http://cmall.ishaohuo.cn/
This is ApacheBench, Version 2.3 <$Revision: 1807734 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking cmall.ishaohuo.cn (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
Server Software: nginx/1.8.0
Server Hostname: cmall.ishaohuo.cn
Server Port: 80
Document Path: /
Document Length: 651 bytes
Concurrency Level: 10
Time taken for tests: 9.390 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 955000 bytes
HTML transferred: 651000 bytes
Requests per second: 106.49 [#/sec] (mean)
Time per request: 93.903 [ms] (mean)
Time per request: 9.390 [ms] (mean, across all concurrent requests)
Transfer rate: 99.32 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 9 8.1 15 63
Processing: 0 84 13.2 78 156
Waiting: 0 48 25.9 47 140
Total: 16 93 13.7 94 156
Percentage of the requests served within a certain time (ms)
50% 94
66% 94
75% 94
80% 102
90% 109
95% 110
98% 125
99% 141
100% 156 (longest request)
上述的表示每次并发10个请求,总共请求10000次,从结果中我们可以得知服务器的相关信息,time taken for tests整个测试耗时,complete request总共完成的请求数量,total transferred测试过程中产生的网络传输总量,request per second表示服务器吞吐量,Percentage of the requests served within acertain time (ms)整个场景中所有请求的响应情况。在场景中每个请求都有一个响应时间,其中50%的用户响应时间小于94毫秒,80%的用户响应时间小于102毫秒,最大的响应时间小于156 毫秒
Ab命令参数注释:
-n #指定在测试会话中所执行的请求个数。默认时,仅执行一个请求。
-c #指定一次产生的请求个数。默认是一次一个。
-t #测试所进行的最大秒数。其内部隐含值是-n 50000。它可以使对服务器的测试限制在一个固定的总时间以内。默认时,没有时间限制。
-p #包含了需要POST的数据的文件.
-T #POST数据所使用的Content-type头信息。
-v #设置显示信息的详细程度 - 4或更大值会显示头信息, 3或更大值可以显示响应代码(404, 200等), 2或更大值可以显示警告和其他信息。 -V 显示版本号并退出。
-w #以HTML表的格式输出结果。默认时,它是白色背景的两列宽度的一张表。
-I #执行HEAD请求,而不是GET。