<-
Apache > HTTP Server > Documentation > Version 2.4

αH

݋b _ _ Ɯ”. ٿ ~@ ݋ O[.

ȿڷ ݋L [R Te[b ` ݋L 񵿰 ɿ ˾ƾ Ѵ. Hġ ݋Lb ſ vJƽO Ϟ α @ Ѵ. ݋b α @ r[b Ҏ^ α׿ 齁 ~@ Ѵ.

Support Apache!

O

top

O

Hġ αHϓ b 丮 oѓ ٔR ( root) ݋L [b uid ȮǞ @ ] . Ƹ O[ʽO αװ v 丮 o@ . ڼ ~@ ݋ O[.

, Ŭƾh rb αHϿ ״ Uȴ. E݋ ǰ b Ŭƾh αHϿ ڸ @ ] ڹǷ, α׸ ٷVb ؾ Ѵ.

top

α (Error Log)

ErrorLog Cb ߿ αH ݋L α Ɠ ġ rѴ. Hġ ݋Lb HϿ Zr ]@ Q[b n Te UѴ. ݋L C۸[ų ۸[b ٔR ߽oǾO VV Oġb ˷־b ^@ v Ѵ.

α׾b (ڷ Ϟ[z Czۿ݋b error_log, Un OS/2݋b error.log) HϿ Uȴ. Ϟ[z Czۿ݋ ݋Lb syslog H ȝ~[ ٸ α׷ڷ m ]n .

α e@ ڷ ϞӽO ڼ[. ׵\ κ α H ڷ b r . 齁, H@ ٞ .

[Wed Oct 11 14:32:52 2000] [error] [client 127.0.0.1] client denied by server configuration: /export/home/live/ap/htdocs/test

α H݋ ù偓 H@ ǿ Cƴ. 偓 H@ O[b U@ t. LogLevel C α׿ UǾb U@ ] . 偓 H@ Te Ŭƾh IP ּғƴ. ٞ 얓 , ݋L Ŭƾh @ źθ[nU rǾٽO ͘. ] ݋ ( ΰ Ƈ) HϳCz Ιn δ.

α׿b ſ ل v 얂䰡 ] . κл@ 񔇸[. CGI zrxh L ™n α׿ Uȴ. CGI zrxh stderr rb ״ α׷ ȝȴ.

α׿ r ߰[ e ] ^. ׵\ ] α αn [[b H e׃. 齁, ƒȵ尡 403 α H e׃. α׾b ȝ~ڞr ] ڹǷ H@ O[ Ȳ ߰r @ ] .

ȝV eb α׸ 캸b ͓ . Ϟ[z Czۿ݋ ٞ Ѵ:

tail -f error_log

top

α (Access Log)

݋L α׾b ݋L Q[b ]@ UѴ. CustomLog Cb α ġ ~@ rѴ. LogFormat C ȝ~[ α׿ ` ~@ ] . @ ݋L α׿ R ~@ r[b Ҏ^@ Ѵ.

α׿ r U[b ͻ@ α C ]ƴ. ٞ Zb r м[ Ϟ~ 踦 b ͓ƴ. ݋b ^ α м ݋ L ʙڸ, α м@ ݋L ϓ ”. α м r α׸ м[b h ݋b Open Directory O[.

Hġ ݋Lb mod_log_referer, mod_log_agent, CustomLog @ C ȝ~[ α׸ L. ݻ@ CustomLog C E C @ ƽ޾Ҵ.

α e@ ſ ȝ~ڞr ɸ[. e@ C printf(1) eڄP ſ Ϟȝ eڄP@ ȝ~[ rѴ. ٞ . eڄP ȝ~ ~@ ˷R mod_log_config eڄP@ O[.

Common α e

α r@ ٞ .

LogFormat "%h %l %u %t \"%r\" %>s %b" common
CustomLog logs/access_log common

׵\R r α eڄP@ commonڷ rѴ. eڄP@ ۼh C 伺Ǹ, @ r U ˸. eڄP ^ ڸ ڔR ״ α׿ µȴ. F (") ¸[O ʹٔR wE{ տ ٿ݋ eڄP ƅ@ FCѴ. eڄP Rَ "\n", "\t" @ Ư] ڸ ȝ~ ] .

CustomLog Cb r @ ȝ~[b ؛ο αH@ 늴. α Hϸ E{ C۸[ʙڔR ServerRoot Γƴ.

r@ αe(Common Log Format, CLF)ƶb eڷ α H@ UѴ. \ ٸ ݋Ln Ʒ F eڷ α׸ , \ α м α׷݋ @ ] . CLF αH H@ ٞ :

127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326

α H κ@ Ѵ.

127.0.0.1 (%h)
݋L ]@ Ŭƾh( xzh) IP ּғƴ. HostnameLookups OnƶR xzh@ ã݋ IP ּ ڸ _ . ׵\ r@ ݋L ſ ] ڹǷ õ[ ʾb. xzh@ ˷R _ ߿ logresolve @ α׸ Q[b α׷@ ȝ~[b ͓ . ⿡ IP ּҾb ȝ~ڰ ȝ~[b ǻ ּҰ ƴ ] . UC ݋L ȝ~ڿ ݋Lȝƿ ZѴٔR, E ǻ ּҰ ” UC ּҰ U ͓ƴ.
- (%l)
¿݋ "Wx"b ] r ^@ t. ⿡ rb Ŭƾh ǻ identd Ŭƾh RFC 1413 _ƴ. rb ſ @ ] ^V얿, ׃ Ǿb h̝ ”R r ȝ~[R ȵȴ. IdentityCheck On ”R Hġ ݋Lb r ˾ƺO Cn[n ʾb.
frank (%u)
ƾb HTTP ΄ڷ ˾Ƴ ݋ ] ȝ~ useridƴ. @@ CGI zrxh REMOTE_USER ȯ溯] є. ] ƒȵ尡 401ƶR (E O) ȝ~ڰ ΄@ ġ ʾҙڹǷ @@ ϙڔR ȵȴ. ݋ x x[ ʾbٔR H@ H "-"ƴ.
[10/Oct/2000:13:55:36 -0700] (%t)
݋L ]Q ģ C. e@:

[day/month/year:hour:minute:second zone]
day = 2
month = 3
year = 4
hour = 2
minute = 2
second = 2
zone = (`+' | `-') 4

α eڄP %{format}t ȝ~[ ٸ eڷ C@ ] . format@ C F ƺ\ strftime(3) .
"GET /apache_pb.gif HTTP/1.0" (\"%r\")
Ŭƾh ]R ֵF . ]R@ ſ Ϟ~ r O . ù, Ŭƾh ȝ~ ޽Yb GETƴ. ѓ, Ŭƾhb ڿ /apache_pb.gif ]Ѵ. 偓, Ŭƾhb HTTP/1.0 @ ȝ~Ѵ. ]R \ κ@ α ]n . 齁, eڄP "%m %U%q %H"@ "%r" Ȱ ޽Y, , ڄP, @ αѴ.
200 (%>s)
ƾb ݋L Ŭƾh b ƒȵƴ. rb (2 C۸[b ȵ) ] [b, (4 C۸[b ȵ) Ŭƾh b, (5 C۸[b ȵ) ݋L b ˷ֹǷ ſ ߿[. ƒȵ ü U@ HTTP Ծ (RFC2616 section 10)݋ ã@ ] .
2326 (%b)
H@ [ c ܸ[O Ŭƾh b ~ r⸦ t. Ŭƾh b ~ ^ٔR @@ "-"ƴ. ~ ^b "0"@ α׸[R _ %B ȝ~Ѵ.

Combined α e

ȝ~Ǿb ٸ eڄP@ Jȷαe(Combined Log Format)ƴ. ٞ ȝ~Ѵ.

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined
CustomLog log/access_log combined

e@ H@ ߰ @ ܸ[Ob Common α e . ߰ H@ ۼh C %{header}i ȝ~Ѵ. ݋ header ڸ HTTP ] c Ɠ ] . e α׾b ٞ :

127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326 "http://www.example.com/start.html" "Mozilla/4.08 [en] (Win98; I ;Nav)"

߰ H@:

"http://www.example.com/start.html" (\"%{Referer}i\")
"Referer" (^ ƲʾҞ) HTTP ] c. Ŭƾh ߴٽO ݋L ˸ ȝhƴ. (, /apache_pb.gif r[ų ` ȝhƴ.)
"Mozilla/4.08 [en] (Win98; I ;Nav)" (\"%{User-agent}i\")
User-Agent HTTP ] c. Ŭƾh v _ ˸b erƴ.

\ α

rHϿ \ CustomLog C ȝ~[R αװ \ 齁. 齁, ٞ r@ α׸ 늴. ù偓b ⺻ CLF r U[O, 偓 偓b referer v r UѴ. CustomLog R@ ReferLog AgentLog C @ 䳻m ] b ش.

LogFormat "%h %l %u %t \"%r\" %>s %b" common
CustomLog logs/access_log common
CustomLog logs/referer_log "%{Referer}i -> %U"
CustomLog logs/agent_log "%{User-agent}i"

, b LogFormatڷ ^C @ r ʿb ^@ ش. _ CustomLog C α e@ r ] .

Ǻ α

Ŭƾh ] ݿ ش H@ α׿ U[ʽO @ V . ȯ溯] ȝ~[R ذȴ. v, Ŭƾh Ưr @ [R ȯ溯] rѴ. Eb SetEnvIf ȝ~Ѵ. ׸O CustomLog C env=@ ȝ~[ ȯ溯] Ϟ ]@ \ְų . R:

# loop-back z݋ ]@ FCѴ
SetEnvIf Remote_Addr "127\.0\.0\.1" dontlog
# robots.txt HϿ ]@ FCѴ
SetEnvIf Request_URI "^/robots\.txt$" dontlog
# M α׿ ׃
CustomLog logs/access_log common env=!dontlog

ٸ ȝ~ ]@ αHϿ U[O, 񿵽 ȝ~ ]@ ٸ αHϿ U[b 츦 eغ.

SetEnvIf Accept-Language "en" english
CustomLog logs/english_log common env=english
CustomLog logs/non_english_log common env=!english

Ǻ α׾b ſ K¸[O Ϟ[, ư͓ α ~@ [b Ϟ Ҏ^@ ”. αHϻ@ ݋L ൿ@ UV Ϟ~[. ߿ [ʾb ]@ ܸ[O αH@ м[b ͓ .

top

α bȯ (Log Rotation)

ٻ ݋Lmn αHϿ vǾb r@ ſ . α׾b ] 1MB ƻ Ѵ. ڷ Z α׸ wų b Ҏ^ڷ α׸ ֱڷ b ʿ䰡 . Hġb H@ POb ȿb αHϿ oV얿 ݋L V α׸ bȯ ] ^. _ αH@ wų ݋L C[, αH@ ؛ P Ѵ.

@ C@ ȝ~[R ݋Lb Ŭƾh Z Ȥ@ @ ʽO ؛ αH@ P ] . ׵\ Ƹ ݋Lb E ] ݋z b αH@ ȝ~ؾ Ѵ. ׵\Ƿ C αH@ Q[ 󸶰 ٸ ʿ䰡 . ^ڷ ٞ α׸ bȯ[O, zr@ [ α׸ оdѴ:

mv access_log access_log.old
mv error_log error_log.old
apache2ctl graceful
sleep 600
gzip access_log.old error_log.old

α׸ bȯ[b ٸ Ҏ^@ ٞ ݋ H α ȝ~[b ͓ƴ.

top

α׸ H

Hġ ݋Lb α׿ α׸ HϿ oʽO H ٸ μz m ] . @ ȝ~[R ݋L ȵ带 ߰[ʽOn ſ Ϟ[ α׸ Q ] . α׸ H o Hϸ ڸ H "|" ڿ F؝™ڷ α H@ @ Hϸ@ ڔR ȴ. Hġb ݋L CV H α μz C۸[O, ݋L Ǿb μz יڔR ٳC CѴ. ( V얿 츮b Ҏ^@ "@ ] b H α"O θ.)

H α μzb θ Hġ httpd μz O, μz useridn . , H α α׷@ root ȴ. ׵\Ƿ α׷@ Z[O [ b ͓ ſ ߿[.

H θb ü w F @ U[. b α׿ ͓, αיn U.

݋L C۸[ʽO α׸ bȯ ] b ͓ H α׸ ȝ~[b ߿ Ϟ. Hġ ݋Lb Ƹ rotatelogsb Z α׷@ `Ѵ. 齁 24C α׸ bȯѴٔR:

CustomLog "|/usr/local/apache/bin/rotatelogs /var/log/access_log 86400" common

ٸ ȝh cronologb 񔇸[ μm Ϟ α bȯ α׷ .

Ǻ α׿ H α׾b ſ K n, ߿ Q[b Z Ҏ^ ȝ~݋b ȵȴ.

top

xzh

@ xzh b ݋L V \ Ҏ^ڷ αH@ ٷ ] . v, xzh Ѱ ݋L α׸ ȝ~ ] . <VirtualHost> ӛ Ƈ ݋L r α C ΔR ] @ α׿ α׷ Uȴ. Ҏ^@ xzh Q ] ^.

<VirtualHost> ӛ ȿ CustomLog ErrorLog C ȝ~[R ش xzh ] r HϿ Uȴ. α C ^b ٸ xzhb ݋L α׿ α׸ UѴ. Ҏ^@ xzh ] @ ſ Ϟ~[, xzh ] ٔR [ 齁. , Hϱvڰ ξ TeѴ.

α ſ @ ذå . α eڄP xzh r ߰[R xzh @ α׸ ȝ~[O, ߿ α׸ xzh ] . 齁, ٞ C .

LogFormat "%v %l %u %t \"%r\" %>s %b" comonvhost
CustomLog logs/access_log comonvhost

%vb ]@ ݋z[b xzh Ɠ@ UѴ. ߿ split-logfile @ α׷ڷ α׸ xz ] .

top

ٸ αH

PID H

Hġ ݋Lb CV logs/httpd.pid HϿ θ httpd μz process id vѴ. Hϸ@ PidFile C ] . process-idb ڰ θ μz C׳@ ݋L C۸[ų V ȝ~Ѵ. Un݋b _ -k wӛ@ ȝ~Ѵ. ڼ rb ߸Z C O[.

zrxh α

L@ ScriptLog C ȝ~[ CGI zrxh ° @ U ] . Cb zh~ڷθ ȝ~ؾ Ѵ. ȝ~[b ݋L݋ ȝ~[R ȵȴ. ڼ rb mod_cgi ݋ O[.

ۼ α

mod_rewrite K¸[O @ ȝ~ѴٔR L@ H RewriteLog ȝ~ ʿ䰡 . αHϻ@ ۼ ]@ ȯ[b ڼ ˷ش. ڼ rnb RewriteLogLevel C Ѵ.

:  en  |  fr  |  ja  |  ko  |  tr 

top

Comments

Notice:
This is not a Q&A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our mailing lists.
С͸