Apache勉強(2)

教材:日経Linux 2008/6連載 実践!Webサーバー構築 初めてのApacheモジュール


UserDirディレクティブ利用
モジュールが組み込まれているか確認


# ../bin/httpd -M |grep userdir
Syntax OK
userdir_module (shared)

httpd.conf追加




UserDir public_html
UserDir disable root

ホームページを公開するユーザーを作成



# useradd -d /home/user1 -m -k /etc/skel user1
コンテンツを公開


# su - user1
$ mkdir public_html
$ cd public_html/
$ vi index.html

http://サーバー/~user1/ にアクセス


Forbidden

You don't have permission to access /~user1/ on this server.

エラー

/home/user1のアクセス権の変更



# chmod 711 /home/user1

httpd.confを下記のように変更することで表示された




UserDir public_html
UserDir disable root

Order allow,deny
Allow from all


※「」のところを「」としても動いた


ApacheBenchの利用
Apacheに標準で付属しているベンチマーク用ソフト



# ab -n 100 -c 10 http://localhost/
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 localhost (be patient).....done


Server Software: Apache/2.2.15
Server Hostname: localhost
Server Port: 80

Document Path: /
Document Length: 44 bytes

Concurrency Level: 10
Time taken for tests: 0.060 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 32700 bytes
HTML transferred: 4400 bytes
Requests per second: 1678.36 [#/sec] (mean)
Time per request: 5.958 [ms] (mean)
Time per request: 0.596 [ms] (mean, across all concurrent requests)
Transfer rate: 535.96 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 1.2 1 6
Processing: 3 4 0.6 4 6
Waiting: 2 3 1.1 3 5
Total: 3 5 1.6 6 11

Percentage of the requests served within a certain time (ms)
50% 6
66% 6
75% 7
80% 7
90% 7
95% 9
98% 11
99% 11
100% 11 (longest request)

「-n」・・・リクエスト回数
「-c」・・・同時コネクション数