3.17 Apaceh ab压力测试
ab -n 100 -c 10 http://test.com/
ab常用参数的介绍:
-n:总共的请求执行数,缺省是1;
-c: 并发数,缺省是1;
-t:测试所进行的总时间,秒为单位,缺省50000s
-p:POST时的数据文件
-w: 以HTML表的格式输出结果
[root@localhost html]# ab -n 3000 -c 10 https://121.42.183.93/index.php
This is ApacheBench, Version 2.3
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 121.42.183.93 (be patient)
Server Software:
Server Hostname: 121.42.183.93
Server Port: 443
SSL/TLS Protocol: TLSv1/SSLv3,RC4-MD5,2048,112
Document Path: /index.php
Document Length: 274 bytes
Concurrency Level: 10 # 并发请求
Time taken for tests: 471.724 seconds # 整个测试持续时间
Complete requests: 259 # 完成请求数
Failed requests: 0 # 失败请求数
Write errors: 0
Non-2xx responses: 269
Total transferred: 123471 bytes # 整个场景中的网络传输量
HTML transferred: 73706 bytes # 整个场景中HTML内容传输量
Requests per second: 0.55 [#/sec] (mean) # 吞吐率
Time per request: 18213.293 [ms] (mean) # 用户平均请求等待时间 (mean)平均值
Time per request: 1821.329 [ms] (mean, across all concurrent requests) # 服务器平均请求处理时间
Transfer rate: 0.26 [Kbytes/sec] received # 平均每秒网络上的流量 可以判断是否存在延时
Connection Times (ms) 网络消耗时间
min mean[+/-sd] median max
Connect: 130 212 991.5 145 16070
Processing: 17368 17374 15.7 17373 17622
Waiting: 41 45 2.8 46 53
Total: 17499 17586 991.3 17520 33438
Percentage of the requests served within a certain time (ms) 百分比处理时间(毫秒)
50% 17520 处理到50%时所花费的时间
66% 17524
75% 17526
80% 17528
90% 17533
95% 17539
98% 17556
99% 18267
100% 33438 (longest request)
3.18 Curl命令
见nginx章节
3.19 apache 常见故障
错误日志
tail -fn 100 /var/log/httpd/error_log 故障排错
3.19.1 提示configure: error: APR not found . Please read the documentation
./configure --prefix……检查编辑环境时出现:
checking for APR... no
configure: error: APR not found . Please read the documentation
解决办法:
事先在编译apache时需要安装apr arp-util pcre三个组件
在编译的时候,指定apr apr-util pcre路径
3.19.2 提示Address already in use: make_sock: could not bind to address [::]:80
[root@localhost ~]# /usr/local/apache/bin/apachectl -k start
(98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
解决方法:有服务占用此端口,用netstat-ntupl找到程序停止它
3.19.3 提示apache/bin/apxs:/usr/local/perl: bad interpreter: No such file or directory
apache/bin/apxs:/usr/local/perl: bad interpreter: No such file or directory
configure: error: no - APXSrefers to an old version of Apache
./confiure报错:这是因为apsx文件没有指定perl执行程序位置
解决:[root@localhost ~]# vi /usr/local/apache/bin/apxs
#!/replace/with/path/to/perl/interpreter–w #将第一行修改为#!/usr/bin/perl –w即可
#添加环境变量
[root@localhost ~]# echo "PATH=$PATH/:/usr/local/subversion/bin" >> /etc/profile
[root@localhost ~]# source /etc/profile
[root@localhost ~]# svnserve –version #显示版本信息表示正常
3.19.4 提示You don't have permission to access / on this server.
修改根目录权限
AllowOverride none
Require all granted(denied)
3.19.5 httpd: Could not> (98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
原因:找不到完整的FQDN域名
解决方法: 修改httpd.conf配置
#ServerName 127.0.0.1:80