ben*_*ben 57 apache-http-server osx-lion
几周前我将 MacBook Pro 13" 更新为 Lion。我刚刚发现 Apache Bench (apache2.2.19) 不起作用。它总是显示这个错误,无论如何:
apr_socket_recv:对等方重置连接(54)
我还在我的 Mac Mini 上进行了全新安装,但它产生了同样的错误。
我怎样才能解决这个问题?
小智 47
这是由于与 Lion 捆绑的 Apache 软件中存在错误。较新版本的 Apache(测试版)修复了该问题。要修复 ab,请执行以下步骤:
下载最新版本的 Apache
$ wget http://apache.mirrors.pair.com//httpd/httpd-2.3.16-beta.tar.bz2
Run Code Online (Sandbox Code Playgroud)如果 2.3.16 不可用,请访问http://apache.mirrors.pair.com/httpd并获取最新的
安装 pcre(你需要 brew 为此)
$ brew install pcre
Run Code Online (Sandbox Code Playgroud)构建 Apache
$ tar xzvf httpd-2.3.16-beta.tar.bz2
$ cd httpd-2.3.16-beta
$ ./configure
$ make
Run Code Online (Sandbox Code Playgroud)用新建的 ab 覆盖现有 ab
$ sudo cp support/ab /usr/sbin
Run Code Online (Sandbox Code Playgroud)在此链接上使用通过自制软件更新 ab 的方法对我有用。
brew install 'https://raw.github.com/simonair/homebrew-dupes/e5177ef4fc82ae5246842e5a544124722c9e975b/ab.rb'
brew test ab
Run Code Online (Sandbox Code Playgroud)
有几件事需要测试:
如果这些都不起作用,你可以打开一个终端并
$ sudo opensnoop
Run Code Online (Sandbox Code Playgroud)
然后运行 apache bench 并在问题中发布 opensnoop 终端的输出。如果这些都不起作用,你可以尝试安装 macports,然后从那里安装 apache,看看这是否可以作为解决方法(有点蹩脚)。
我的Air是lion的,但是apache版本不同(最近有更新,你已经安装了吗?)。我能够验证 ab 对我有用:
$ ab -V
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
$ uname -a
Darwin air.local 11.1.0 Darwin Kernel Version 11.1.0: Tue Jul 26 16:07:11 PDT 2011; root:xnu-1699.22.81~1/RELEASE_X86_64 x86_64
$ ab google.com/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking google.com (be patient).....done
Server Software: gws
Server Hostname: google.com
Server Port: 80
Document Path: /
Document Length: 219 bytes
Concurrency Level: 1
Time taken for tests: 4.130 seconds
Complete requests: 1
Failed requests: 0
Write errors: 0
Non-2xx responses: 1
Total transferred: 511 bytes
HTML transferred: 219 bytes
Requests per second: 0.24 [#/sec] (mean)
Time per request: 4130.343 [ms] (mean)
Time per request: 4130.343 [ms] (mean, across all concurrent requests)
Transfer rate: 0.12 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 4119 4119 0.0 4119 4119
Processing: 11 11 0.0 11 11
Waiting: 11 11 0.0 11 11
Total: 4130 4130 0.0 4130 4130
Run Code Online (Sandbox Code Playgroud)