Mac自帶了Apache環境html
打開「終端(terminal)」,輸入 sudo apachectl -v,(可能須要輸入機器祕密)。以下顯示Apache的版本apache
接着輸入 sudo apachectl start,這樣Apache就啓動了。打開Safari瀏覽器地址欄輸入 「http://localhost」,能夠看到內容爲「It works!」的頁面。其位於「/Library(資源庫)/WebServer/Documents/」下,這就是Apache的默認根目錄。windows
Apache的安裝目錄在:/etc/apache2/,etc默認是隱藏的。有三種方式查看:瀏覽器
windows能夠去http://httpd.apache.org/download.cgi下載,或者從命令行安裝cookie
1. 安裝apache併發
sudo port install apache2app
啓動apache: sudo apachectl startpost
2. brew install pcre
3. wget http://ftp.yz.yamagata-u.ac.jp/pub/network/apache//httpd/httpd-2.4.4.tar.bz2
(1)解壓
(2) ./configure
(3) make && make install
(4) sudo cp support/ab /usr/sbin
4. ab -n 1000 -c 10 http://localhost:3000/ 最後這個斜槓不能少測試
這個ab -n1000 -c10 http://localhost:3000/命令,在window系統下,須要先用cd命令定位到你的apache安裝目錄的bin文件夾。。。url
ab的參數說明
-n 須要執行的請求次數
-c 併發的數量
-t 等待返回的最長時間
-b TCP收發緩衝區的大小,單位(byte)
-p 使用post (同時須要定義-T參數)
-u 使用put (同時須要定義-T參數)
-T content-type, 例如application/x-www-form-urlencoded, 默認爲text/plain
-w 把結果打印在html的表格裏
-x 表格的屬性
-y tr行屬性
-z td列屬性
-C 設置cookie 例如Apach=1234
-H header行, 例如Accept-Encoding:gzip
-k 是否標示位HTTP Keep Alive
測試結果:
This is ApacheBench, Version 2.3 <$Revision: 1663405 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking localhost (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: Server Hostname: localhost Server Port: 3000 Document Path: / Document Length: 14 bytes Concurrency Level: 10 Time taken for tests: 0.323 seconds Complete requests: 1000 Failed requests: 0 Total transferred: 115000 bytes HTML transferred: 14000 bytes Requests per second: 3097.37 [#/sec] (mean) Time per request: 3.229 [ms] (mean) Time per request: 0.323 [ms] (mean, across all concurrent requests) Transfer rate: 347.85 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.1 0 1 Processing: 1 3 2.2 2 16 Waiting: 1 3 2.2 2 16 Total: 1 3 2.2 2 16 Percentage of the requests served within a certain time (ms) 50% 2 66% 3 75% 3 80% 4 90% 5 95% 7 98% 13 99% 15 100% 16 (longest request)