小知识:Apache服务器主配置文件httpd.conf详解

apache 2.2

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
# This is the main Apache server configuration file. It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.2/> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.2/mod/directives.html>
# for a discussion of each configuration directive.
# 这是主Apache服务器配置文件
# 它给服务器指示配置指令。
# 可去http://httpd.apache.org/docs/2.2/查看详细信息
# 特别情况可去http://httpd.apache.org/docs/2.2/mod/directives.html
# 对每个配置指示进行讨论
# Do NOT simply read the instructions in here without understanding
# what they do. Theyre here only as hints or reminders. If you are unsure
# consult the online docs. You have been warned.
#
# The configuration directives are grouped into three basic sections:
# 1. Directives that control the operation of the Apache server process as a
#   whole (the global environment).
# 2. Directives that define the parameters of the main or default server,
#   which responds to requests that arent handled by a virtual host.
#   These directives also provide default values for the settings
#   of all virtual hosts.
# 3. Settings for virtual hosts, which allow Web requests to be sent to
#   different IP addresses or hostnames and have them handled by the
#   same Apache server process.
# 要明白这些指令是做什么的。这里只是一点提醒信息。
#
# 配置指示分为三个基本组:# 1. 全局控制Apache操作指示。# 2. main或者default服务器参数定义,#  这些参数响应非虚拟主机的操作请求。同时也为所以虚拟主机提供了默认设定值。# 3. 设置虚拟主机,可以通过一个Apache服务器来实现处理不同IP或者主机名的Web请求。
# Configuration and logfile names: If the filenames you specify for many
# of the servers control files begin with “/” (or “drive:/” for Win32), the
# server will use that explicit path. If the filenames do *not* begin
# with “/”, the value of ServerRoot is prepended — so “logs/foo.log”
# with ServerRoot set to “/etc/httpd” will be interpreted by the
# server as “/etc/httpd/logs/foo.log”.
# 配置名和日志文件名:# 如果用“/”或者Win32的“drive:/”开头,来指定服务器的控制文件名,服务器将使用显式路径。# 如果未用“/”开头,比如文件名“logs/foo.log”,假设服务器根目录为“/etc/httpd”,# 则,服务器会将它解释为“/etc/httpd/logs/foo.log”。
### Section 1: Global Environment
#
# The directives in this section affect the overall operation of Apache,
# such as the number of concurrent requests it can handle or where it
# can find its configuration files.
### 章节1:全局环境# 这节的指令影响Apache的整体操作,比如它能操作的当前连接请求数目或者去哪里# 查找其配置文件等。
# Dont give away too much information about all the subcomponents
# we are running. Comment out this line if you dont mind remote sites
# finding out what major optional modules you are running
ServerTokens OS
# 不要泄漏太多的服务器信息。# 如果不想让远程站点了解到你的主要选型模块信息,可以注释掉该行。
# ServerRoot: The top of the directory tree under which the servers
# configuration, error, and log files are kept.
#
# NOTE! If you intend to place this on an NFS (or otherwise network)
# mounted filesystem then please read the LockFile documentation
# (available at <URL:http://httpd.apache.org/docs/2.2/mod/mpm_common.html#lockfile>);
# you will save yourself a lot of trouble.
#
# Do NOT add a slash at the end of the directory path.
#
ServerRoot “/etc/httpd”
# 服务器的根:目录树的顶部,其下存放着配置、错误,以及日志文件等。## 注意!如果你打算将它放到挂载文件系统的NFS(或者其他网络),建议参阅LockFile文档# (有效链接为http://httpd.apache.org/docs/2.2/mod/mpm_common.html#lockfile)# 你将省去不少麻烦。# # 不要在目录的末尾加斜线“/”# ServerRoot “/etc/httpd”
# PidFile: The file in which the server should record its process
# identification number when it starts.
#
PidFile run/httpd.pid
# Pid文件:当进程启动时,服务器应当在其中记录PID。# PidFile run/httpd.pid
#
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 120
# Timeout:确定发送超时和接收超时的秒数。Timeout 120
#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to “Off” to deactivate.
#
KeepAlive Off
# KeepAlive:是否允许保持连接状态(每次连接可以执行多个请求)。一般设置为“Off”。KeepAlive Off
#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100
# MaxKeepAliveRequests:持续连接最大数。0表示无限数量。# 为了最大性能,推荐将其设置高一点。MaxKeepAliveRequests 100
#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 15
# KeepAliveTimeout:同一客户端同一连接请求的间隔秒数。KeepAliveTimeout 15
##
## Server-Pool Size Regulation (MPM specific)
##
## 服务器池大小调整(MPM 特性)
# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# ServerLimit: maximum value for MaxClients for the lifetime of the server
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule prefork.c>
StartServers    8
MinSpareServers  5
MaxSpareServers  20
ServerLimit   256
MaxClients    256
MaxRequestsPerChild 4000
</IfModule>
# prefork MPM(预分离多进程模块)# StartServices:服务器启动进程数# MinSpareServers:最小空闲进程数# MaxSpareServers:最大空闲进程数# ServerLimit:最大进程数MaxClients时,服务器的最大生存时间值# MaxClients:服务器运行启动的最大进程数量# MaxRequestPerChild:每个服务子进程的最大请求数量<IfModule prefork.c>StartServers    8MinSpareServers  5MaxSpareServers  20ServerLimit   256MaxClients    256MaxRequestsPerChild 4000</IfModule>
# worker MPM
# StartServers: initial number of server processes to start
# MaxClients: maximum number of simultaneous client connections
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule worker.c>
StartServers     2
MaxClients     150
MinSpareThreads   25
MaxSpareThreads   75
ThreadsPerChild   25
MaxRequestsPerChild 0
</IfModule>
# worker 多进程模块# StartServers:服务器启动进程的初始化数目# MaxClients:同时客户端连接的最大数目# MinSpareThreads:最小空闲worker线程数# MaxSpareThreads:最大空闲worker线程数# ThreadsPerChild:每个服务器子进程的worker线程数# MaxRequestsPerChild:每个子进程的最大请求数<IfModule worker.c>StartServers     2MaxClients     150MinSpareThreads   25MaxSpareThreads   75ThreadsPerChild   25MaxRequestsPerChild 0</IfModule>
#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, in addition to the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
#
#Listen 12.34.56.78:80
Listen 80
# Listen:允许将Apache绑定到除了默认值之外的特定的IP地址和/或端口。也可# 查看<VirtualHost>指令。# # 如下设置特定IP地址,可防止Apache接收所有绑定的IP(0.0.0.0)# 默认接收所有IP,特定IP的Listen被“#”注释掉#Listen 12.34.56.78:80Listen 80
#
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l) do not need
# to be loaded here.
#
# Example:
# LoadModule foo_module modules/mod_foo.so
#
# # 动态共享对象(DSO)支持# # 为了能使用编译为DSO的模块函数,我们必须将相应的‘LoadModule行放在此处,这样模块中的指令将有效。# 静态编译模块(用‘httpd -l命令可以列出)不需要在这里加载。# # 示例:# LoadModule foo_module modules/mod_foo.so#
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule auth_digest_module modules/mod_auth_digest.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_alias_module modules/mod_authn_alias.so
LoadModule authn_anon_module modules/mod_authn_anon.so
LoadModule authn_dbm_module modules/mod_authn_dbm.so
LoadModule authn_default_module modules/mod_authn_default.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_owner_module modules/mod_authz_owner.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_dbm_module modules/mod_authz_dbm.so
LoadModule authz_default_module modules/mod_authz_default.so
LoadModule ldap_module modules/mod_ldap.so
LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
LoadModule include_module modules/mod_include.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule logio_module modules/mod_logio.so
LoadModule env_module modules/mod_env.so
LoadModule ext_filter_module modules/mod_ext_filter.so
LoadModule mime_magic_module modules/mod_mime_magic.so
LoadModule expires_module modules/mod_expires.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule headers_module modules/mod_headers.so
LoadModule usertrack_module modules/mod_usertrack.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule mime_module modules/mod_mime.so
LoadModule dav_module modules/mod_dav.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule info_module modules/mod_info.so
LoadModule dav_fs_module modules/mod_dav_fs.so
LoadModule vhost_alias_module modules/mod_vhost_alias.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule dir_module modules/mod_dir.so
LoadModule actions_module modules/mod_actions.so
LoadModule speling_module modules/mod_speling.soLoadModule userdir_module modules/mod_userdir.soLoadModule alias_module modules/mod_alias.soLoadModule rewrite_module modules/mod_rewrite.soLoadModule proxy_module modules/mod_proxy.soLoadModule proxy_balancer_module modules/mod_proxy_balancer.soLoadModule proxy_ftp_module modules/mod_proxy_ftp.soLoadModule proxy_http_module modules/mod_proxy_http.soLoadModule proxy_connect_module modules/mod_proxy_connect.soLoadModule cache_module modules/mod_cache.soLoadModule suexec_module modules/mod_suexec.soLoadModule disk_cache_module modules/mod_disk_cache.soLoadModule file_cache_module modules/mod_file_cache.soLoadModule mem_cache_module modules/mod_mem_cache.soLoadModule cgi_module modules/mod_cgi.soLoadModule version_module modules/mod_version.so## The following modules are not loaded by default:##LoadModule cern_meta_module modules/mod_cern_meta.so#LoadModule asis_module modules/mod_asis.so
#
# Load config files from the config directory “/etc/httpd/conf.d”.
#
Include conf.d/*.conf
# 从config目录“/etc/httpd/conf.d”加载配置文件# *.conf兼容老版本的ApacheInclude conf.d/*.conf
#
# ExtendedStatus controls whether Apache will generate “full” status
# information (ExtendedStatus On) or just basic information (ExtendedStatus
# Off) when the “server-status” handler is called. The default is Off.
#
#ExtendedStatus On
# ExtendedStatus 在“server-status”操作被调用时,控制Apache是否产生“full”状态信息(On)或者# 基本信息(Off)。默认为Off。##ExtendedStatus On
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# . On SCO (ODT 3) use “User nouser” and “Group nogroup”.
# . On HPUX you may not be able to use shared memory as nobody, and the
#  suggested workaround is to create a user www and use that user.
# NOTE that some kernels refuse to setgid(Group) or semctl(IPC_SET)
# when the value of (unsigned)Group is above 60000;
# dont use Group #-1 on these systems!
#
User apache
Group apache
# 如果想要httpd作为一个不同用户或组来运行,最初就必须以root来运行httpd,它会切换到其他用户或组去。# # 用户/组:作为运行httpd的用户/组的名称。# – 在SCO(ODT 3)上,使用“User nouser”和“Group nogroup”。# – 在HPUX上,将无法使用共享存储作为nobody,建议的解决办法是创建一个用户www并使用这个用户。# 注意,有的内核不支持60000以上的组ID值,在这些系统中不要使用“Group #-1”。# User apacheGroup apache
### Section 2: Main server configuration
#
# The directives in this section set up the values used by the main
# server, which responds to any requests that arent handled by a
# <VirtualHost> definition. These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
#
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#
### 章节2:‘Main服务器配置# # 该章节设置‘Main服务器使用的指令,响应所有非<VirtualHost>定义的请求。# 这些指令值也为<VirtualHost>部分提供默认值。# # 所有这些指令都可以在<VirtualHost>段中出现,此时,这些默认值将被虚拟主机的相关设置值所覆盖。
#
# ServerAdmin: Your address, where problems with the server should be
# e-mailed. This address appears on some server-generated pages, such
# as error documents. e.g. admin@your-domain.com
#
ServerAdmin root@localhost
# ServerAdmin:服务器管理员的邮箱地址,该地址一般出现在服务器生成页中,比如错误文档等。ServerAdmin root@localhost
#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If this is not set to valid DNS name for your host, server-generated
# redirections will not work. See also the UseCanonicalName directive.
#
# If your host doesnt have a registered DNS name, enter its IP address here.
# You will have to access it by its address anyway, and this will make
# redirections work in a sensible way.
#
#ServerName www.example.com:80
# ServerName 给出一个服务器用来标识它自己的名称和端口。# 通常被自动指定,但为避免启动时的问题,推荐明确指定它。# # 如果主机没有设置有效的DNS名称,server-generated指令将不会工作。# # 如果主机没有注册DNS,输入其IP地址。这样就可以通过IP地址访问你的主机了。# #ServerName www.example.com:80
#
# UseCanonicalName: Determines how Apache constructs self-referencing
# URLs and the SERVER_NAME and SERVER_PORT variables.
# When set “Off”, Apache will use the Hostname and Port supplied
# by the client. When set “On”, Apache will use the value of the
# ServerName directive.
#
UseCanonicalName Off
# UseCanonicalName:确定apache如何构建自引用URLs和SERVER_NAME、SERVER_PORT变量。# 当设为Off时,apache将使用客户端支持的Hostname和Port。当设为On时,apache将使用# ServerName指令值。#UseCanonicalName Off
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot “/var/www/html”
# DocumentRoot:提供文档的根目录。# 默认,所有请求都由该目录提供,但是可以用连接符和别名指向其他位置。# DocumentRoot “/var/www/html”
#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the “default” to be a very restrictive set of
# features.
#
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
# 每个apache存取的目录(包括子目录)都可配置为允许和禁止。# # 首先,我们配置严格特征集合的默认值。# <Directory />  Options FollowSymLinks  AllowOverride None</Directory>
#
# Note that from this point forward you must specifically allow
# particular features to be enabled – so if somethings not working as
# you might expect, make sure that you have specifically enabled it
# below.
#
# 注意,从此点开始,必须指定使能特殊特性的允许。所以,如果一些事情没有安装你的期望的运行,# 确保你已经指定并使能以下特性。
#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory “/var/www/html”>
# 这里应当根据你设定的DocumentRoot值进行修改。<Directory “/var/www/html”>
#
# Possible values for the Options directive are “None”, “All”,
# or any combination of:
#  Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that “MultiViews” must be named *explicitly* — “Options All”
# doesnt give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
# 指令选项值可以是“None”、“All”,或者下面的任何组合:#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews# # 注意,“MultiViews”必须被清楚地指定—“All”不会帮你指定。# # 指令选项复杂并且重要。详细信息请查阅http://httpd.apache.org/docs/2.2/mod/core.html#options。#    Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be “All”, “None”, or any combination of the keywords:
#  Options FileInfo AuthConfig Limit
#
AllowOverride None
# AllowOverride 允许优先,用来控制哪些指令可以放到.htaccess文件中。# 可以是“All”、“None”,或者下面关键字的任何组合:#   Options FileInfo AuthConfig Limit#   AllowOverride None
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
</Directory>
# 控制谁可能获得服务器阻塞  Order allow,deny  Allow from all</Directory>
#
# UserDir: The name of the directory that is appended onto a users home
# directory if a ~user request is received.
#
# The path to the end user account public_html directory must be
# accessible to the webserver userid. This usually means that ~userid
# must have permissions of 711, ~userid/public_html must have permissions
# of 755, and documents contained therein must be world-readable.
# Otherwise, the client will only receive a “403 Forbidden” message.
#
# See also: http://httpd.apache.org/docs/misc/FAQ.html#forbidden
#
<IfModule mod_userdir.c>
#
# UserDir is disabled by default since it can confirm the presence
# of a username on the system (depending on home directory
# permissions).
#
UserDir disable
#
# To enable requests to /~user/ to serve the users public_html
# directory, remove the “UserDir disable” line above, and uncomment
# the following line instead:
#
#UserDir public_html
</IfModule>
# UserDir:当接收到~user请求时,附加到用户home目录上的目录名称。# # 端用户账户路径‘public_html路径对web服务器用户id必须是可存取的。# 这通常意味着~userid必须拥有711权限值,~userid/public_html必须有755权限值,# 并且其中包含的文件都是公开的。否则,客户端只能收到“403 Forbidden”消息。# # 可查阅:http://httpd.apache.org/docs/misc/FAQ.html#forbidden# <IfModule mod_userdir.c>  # UserDir默认被禁止掉,这样可以确定一个系统用户名的存在(依赖home路径许可)。  UserDir disable    # 要使能/~user/请求以提供用户的public_html目录的话,删除上面的“UserDir disable”行,  # 并且取消下面的注释:  #UserDir public_html</IfModule>
#
# Control access to UserDir directories. The following is an example
# for a site where these directories are restricted to read-only.
#
#<Directory /home/*/public_html>
#  AllowOverride FileInfo AuthConfig Limit
#  Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
#  <Limit GET POST OPTIONS>
#    Order allow,deny
#    Allow from all
#  </Limit>
#  <LimitExcept GET POST OPTIONS>
#    Order deny,allow
#    Deny from all
#  </LimitExcept>
#</Directory>
# UserDir目录的存取控制。以下是一个这些目录被限制到只读的站点示例。# #<Directory /home/*/public_html>#  AllowOverride FileInfo AuthConfig Limit#  Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec#  <Limit GET POST OPTIONS>#    Order allow,deny#    Allow from all#  </Limit>#  <LimitExcept GET POST OPTIONS>#    Order deny,allow#    Deny from all#  </LimitExcept>#</Directory>
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
# The index.html.var file (a type-map) is used to deliver content-
# negotiated documents. The MultiViews Option can be used for the
# same purpose, but it is much slower.
#
DirectoryIndex index.html index.html.var
# DirectoryIndex:如果一个目录被请求时,设置apache将提供文件的目录索引。# # index.html.var文件用来传递内容协商了的文档。MultiViews选项可用于相同目的,但是太慢了。# DirectoryIndex index.html index.html.var
#
# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives. See also the AllowOverride
# directive.
#
AccessFileName .htaccess
# AccessFileName:附加存取指令的文件的名称。也可参照AllowOverride指令。AccessFileName .htaccess
#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<Files ~ “^\.ht”>
Order allow,deny
Deny from all
</Files>
# 下面的行防止.htaccess和.htpasswd文件被Web客户端查看。<Files ~ “^\.ht”>  Order allow,deny  Deny from all</Files>
#
# TypesConfig describes where the mime.types file (or equivalent) is
# to be found.
#
TypesConfig /etc/mime.types
# TypesConfig 描述了mime.types文件在哪TypesConfig /etc/mime.types
#
# DefaultType is the default MIME type the server will use for a document
# if it cannot otherwise determine one, such as from filename extensions.
# If your server contains mostly text or HTML documents, “text/plain” is
# a good value. If most of your content is binary, such as applications
# or images, you may want to use “application/octet-stream” instead to
# keep browsers from trying to display binary files as though they are
# text.
#
DefaultType text/plain
# DefaultType 是服务器无法从文件扩展名确定文档类型时,将使用的默认MIME类型。# 如果你的服务器大部分都是text和html文档,“text/plain”是一个合适值。# 如果你的服务器大部分都是二进制文档,“application/octet-stream”可避免服务器尝试用text来显示二进制。#DefaultType text/plain
#
# The mod_mime_magic module allows the server to use various hints from the
# contents of the file itself to determine its type. The MIMEMagicFile
# directive tells the module where the hint definitions are located.
#
<IfModule mod_mime_magic.c>
#  MIMEMagicFile /usr/share/magic.mime
MIMEMagicFile conf/magic
</IfModule>
# mod_mime_magic模块允许服务器从文件内容来确定文件类型。# MIMEMagicFile指令告诉该模块隐含文件类型信息的位置。<IfModule mod_mime_magic.c>#  MIMEMagicFile /usr/share/magic.mime  MIMEMagicFile conf/magic</IfModule>
#
# HostnameLookups: Log the names of clients or just their IP addresses
# e.g., www.apache.org (on) or 204.62.129.132 (off).
# The default is off because itd be overall better for the net if people
# had to knowingly turn this feature on, since enabling it means that
# each client request will result in AT LEAST one lookup request to the
# nameserver.
#
HostnameLookups Off
# HostnameLookups:将客户端名称或其IP地址加入日志。# 默认为off对整个网络比较好,如果有人明知却非要打开这个特性,那么使能它意味着每个客户端请求都将# 导致至少一个域名服务器查询请求。HostnameLookups Off
#
# EnableMMAP: Control whether memory-mapping is used to deliver
# files (assuming that the underlying OS supports it).
# The default is on; turn this off if you serve from NFS-mounted
# filesystems. On some systems, turning it off (regardless of
# filesystem) can improve performance; for details, please see
# http://httpd.apache.org/docs/2.2/mod/core.html#enablemmap
#
#EnableMMAP off
# EnableMMAP:存储器镜像文件传输控制(需要操作系统的支持)。# 默认为on;如果从NFS-mounted文件系统提供文件则设为off。# 有些系统,设为off(不考虑文件系统)能提高性能;详情请# 查阅http://httpd.apache.org/docs/2.2/mod/core.html#enablemmap# #EnableMMAP off
#
# EnableSendfile: Control whether the sendfile kernel support is
# used to deliver files (assuming that the OS supports it).
# The default is on; turn this off if you serve from NFS-mounted
# filesystems. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#enablesendfile
#
#EnableSendfile off
# EnableSendfile:文件传输内核使能控制(需要系统支持)。# 默认为on;如果从NFS-mounted文件系统提供文件则设为off。# 请查阅http://httpd.apache.org/docs/2.2/mod/core.html#enablesendfile# #EnableSendfile off
#
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here. If you *do* define an error logfile for a <VirtualHost>
# container, that hosts errors will be logged there and not here.
#
ErrorLog logs/error_log
# ErrorLog:错误日志文件的位置。# 如果不在<VirtualHost>段中指定错误日志指令,虚拟主机的错误日志信息也会记录到这个文件。# 如果在<VirtualHost>段中指定错误日志指令,则此虚拟主机的错误将会在那里记录而不在该文件记录。# ErrorLog logs/error_log
#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn
# LogLevel:控制什么级别的信息被记录到error_log日志文件中。# 可能的值包括:debug,info,notice,warn,error,crit,alert,emerg。# LogLevel warn
#
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
#
LogFormat “%h %l %u %t \”%r\” %>s %b \”%{Referer}i\” \”%{User-Agent}i\”” combine
d
LogFormat “%h %l %u %t \”%r\” %>s %b” common
LogFormat “%{Referer}i -> %U” referer
LogFormat “%{User-agent}i” agent
# “combinedio” includes actual counts of actual bytes received (%I) and sent (%O); this
# requires the mod_logio module to be loaded.
#LogFormat “%h %l %u %t \”%r\” %>s %b \”%{Referer}i\” \”%{User-Agent}i\” %I %O” combinedio
# 下面的指令,为CustomLog指令定义了一些昵称。# “combinedio”包含实际接收和发送字节的实际计数;这需要加载mod_logio模块。
#
# The location and format of the access logfile (Common Logfile Format).
# If you do not define any access logfiles within a <VirtualHost>
# container, they will be logged here. Contrariwise, if you *do*
# define per-<VirtualHost> access logfiles, transactions will be
# logged therein and *not* in this file.
#
#CustomLog logs/access_log common
# 普通日志文件的位置和格式。# 若在<VirtualHost>段中定义该指令,则其普通日志文件不会存在该文件中。# #CustomLog logs/access_log common
#
# If you would like to have separate agent and referer logfiles, uncomment
# the following directives.
#
#CustomLog logs/referer_log referer
#CustomLog logs/agent_log agent
# 若是想分离代理和引用日志文件,则取消下面指令的注释。# #CustomLog logs/referer_log referer#CustomLog logs/agent_log agent
#
# For a single logfile with access, agent, and referer information
# (Combined Logfile Format), use the following directive:
#
CustomLog logs/access_log combined
# 若是不想用分离代理和引用日志文件,则用下面的指令:# CustomLog logs/access_log combined
#
# Optionally add a line containing the server version and virtual host
# name to server-generated pages (internal error documents, FTP directory
# listings, mod_status and mod_info output etc., but not CGI generated
# documents or custom error documents).
# Set to “EMail” to also include a mailto: link to the ServerAdmin.
# Set to one of: On | Off | EMail
#
ServerSignature On
# 可选地添加一行包含服务器版本和虚拟主机名称信息到服务器生成的页中(内部错误文档、FTP目录列表、mod_status和# mod_info输出等,但非CGI生成文档或者自定义错误文档)。# 设置为“EMail”也包含mailto管理员邮箱的链接。# 可设置为其中之一: On | Off | EMail# ServerSignature On
#
# Aliases: Add here as many aliases as you need (with no limit). The format is
# Alias fakename realname
#
# Note that if you include a trailing / on fakename then the server will
# require it to be present in the URL. So “/icons” isnt aliased in this
# example, only “/icons/”. If the fakename is slash-terminated, then the
# realname must also be slash terminated, and if the fakename omits the
# trailing slash, the realname must also omit it.
#
# We include the /icons/ alias for FancyIndexed directory listings. If you
# do not use FancyIndexing, you may comment this out.
#
Alias /icons/ “/var/www/icons/”
<Directory “/var/www/icons”>
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
# Aliases:在此添加无限个你需要的别名。# 格式为 Alias 别名 真名# 注意,如果别名中以“/”结尾,则服务器将要求“/”出现在URL中。# 别名中有“/”,则真名中必须有“/”。反之亦然。#
#
# WebDAV module configuration section.
#
<IfModule mod_dav_fs.c>
# Location of the WebDAV lock database.
DAVLockDB /var/lib/dav/lockdb
</IfModule>
# WebDAV模块配置部分。# WebDAV锁定数据库的位置设置。
#
# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the realname directory are treated as applications and
# run by the server when requested rather than as documents sent to the client.
# The same rules about trailing “/” apply to ScriptAlias directives as to
# Alias.
#
ScriptAlias /cgi-bin/ “/var/www/cgi-bin/”
# ScriptAlias:服务器脚本目录别名。# 脚本目录存放服务器响应请求时执行的应用程序,而非发送给客户端的文件。# “/”的处理跟Alias相同。# ScriptAlias /cgi-bin/ “/var/www/cgi-bin/”
#
# “/var/www/cgi-bin” should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory “/var/www/cgi-bin”>
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
# “/var/www/cgi-bin”应当对应到你自己的CGI路径,如果你需要该配置。
#
# Redirect allows you to tell clients about documents which used to exist in
# your servers namespace, but do not anymore. This allows you to tell the
# clients where to look for the relocated document.
# Example:
# Redirect permanent /foo http://www.example.com/bar
# 重定向允许你告诉客户端曾经在你空间中使用的文档已经不存在了。通知客户端去什么位置查找文档。
#
# Directives controlling the display of server-generated directory listings.
#
#
# 服务器生成路径列表显示的控制指令#
#
# IndexOptions: Controls the appearance of server-generated directory
# listings.
#
IndexOptions FancyIndexing VersionSort NameWidth=* HTMLTable
# IndexOptions:服务器生成目录列表的索引控制。IndexOptions FancyIndexing VersionSort NameWidth=* HTMLTable
#
# AddIcon* directives tell the server which icon to show for different
# files or filename extensions. These are only displayed for
# FancyIndexed directories.
#
AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip
AddIconByType (TXT,/icons/text.gif) text/*
AddIconByType (IMG,/icons/image2.gif) image/*
AddIconByType (SND,/icons/sound2.gif) audio/*
AddIconByType (VID,/icons/movie.gif) video/*
…………   …………    …………
# AddIcon* 指令使服务器对不同文件显示不同的文件类型图标。
#
# DefaultIcon is which icon to show for files which do not have an icon
# explicitly set.
#
DefaultIcon /icons/unknown.gif
# DefaultIcon为未明确设置图标的文件指定一个默认类型图标。DefaultIcon /icons/unknown.gif
#
# AddDescription allows you to place a short description after a file in
# server-generated indexes. These are only displayed for FancyIndexed
# directories.
# Format: AddDescription “description” filename
#
#AddDescription “GZIP compressed document” .gz
#AddDescription “tar archive” .tar
#AddDescription “GZIP compressed tar archive” .tgz
# AddDescription 允许你对在服务器生成文件索引后面加入对某类文件的简短描述。#
#AddDescription “GZIP compressed document” .gz
#AddDescription “tar archive” .tar
#AddDescription “GZIP compressed tar archive” .tgz
#
# ReadmeName is the name of the README file the server will look for by
# default, and append to directory listings.
#
# HeaderName is the name of a file which should be prepended to
# directory indexes.
ReadmeName README.html
HeaderName HEADER.html
# ReadmeName 是附加到目录列表的README文件(服务器将默认查找)的名称指定命令。# HeaderName 是应当添加到目录索引中的文件名称。ReadmeName README.html
HeaderName HEADER.html
#
# IndexIgnore is a set of filenames which directory indexing should ignore
# and not include in the listing. Shell-style wildcarding is permitted.
#
IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t
# IndexIgnore索引忽略,即目录索引应当忽略并且不包括在列表里的文件集。允许Shell风格的通配符。IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t

老版本

#

# Apache服务器主配置文件. 包括服务器指令的目录设置.

# 详见

#

# 请在理解用途的基础上阅读各指令。

#

# 再读取此文档后,服务器将继续搜索运行

# E:/Program Files/Apache Group/Apache/conf/srm.conf

# E:/Program Files/Apache Group/Apache/conf/access.conf

# 除非用ResourceConfig或AccessConfig覆盖这儿的标识

#

# 配置标识由三个基本部分组成:

# 1. 作为一个整体来控制Apache服务器进程的标识 (the global environment).

# 2. 用于定义主(默认)服务器参数的标识。

# 响应虚拟主机不能处理的请求。

# 同时也提供所有虚拟主机的设置值。

# 3. 虚拟主机的设置。在一个Apache服务器进程中配置不同的IP地址和主机名。

#

# 配置和日志文件名:指定服务器控制文件命名时,

# 以 “/” (或 “drive:/” for Win32)开始,服务器将使用这些绝对路径。

# 如果文件名不是以”/”开始的,预先考虑服务器根目录–

# 因此 “logs/foo.log”,如果服务器根目录是”/usr/local/apache”,

# 服务器将解释为 “/usr/local/apache/logs/foo.log”.

#

# 注: 指定的文件名需要用”/”代替”\”。

# (例, “c:/apache” 代替 “c:\apache”).

# 如果省略了驱动器名,默认使用Apache.exe所在的驱动器盘符

# 建议指定盘符,以免混乱。

#

### 部分 1: 全局环境

#

# 本部分的表示将影响所有Apache的操作

# 例如,所能处理的并发请求数或配置文件地址

#

#

# ServerType 可取值 inetd 或 standalone. Inetd 只适用于Unix平台

#

ServerType standalone

#

# ServerRoot: 目录树的根结点。服务器配置、出错信息、日志文件都保存在根目录下。

#

# 不要再目录末尾加”/”

#

ServerRoot “C:/Program Files/Apache Group/Apache”

#

# PidFile: 服务器用于记录启动时进程ID的文件。

#

PidFile logs/httpd.pid

#

# ScoreBoardFile: 用于保存内部服务器进程信息的文件。

# 并非必须。 但是如果指定了(此文件当运行Apache时生成)

# 那么必须确保没有两个Apache进程共享同一个scoreboard文件。

#

ScoreBoardFile logs/apache_runtime_status

#

# 在标准配置下,服务器将顺序读取 httpd.conf(此文件可通过命令行中-f参数指定),

# srm.conf 和 access.conf。

# 目前后两个文件是空的。为了简单起见,建议将所有的标识放在一个文件中。

# 以下两条注释的标识,是默认设置。

# 要让服务器忽略这些文件可以用 “/dev/null” (for Unix)

# 或”nul” (for Win32) 作为参数。

#

#ResourceConfig conf/srm.conf

#AccessConfig conf/access.conf

#

# Timeout: 接受和发送timeout的时间

#

Timeout 300

#

# KeepAlive: 是否允许保持连接(每个连接有多个请求)

# “Off” -无效

#

KeepAlive On

#

# MaxKeepAliveRequests: 每个连接的最大请求数。

# 设置为0表示无限制

# 建议设置较高的值,以获得最好的性能。

#

MaxKeepAliveRequests 100

#

# KeepAliveTimeout: 同一连接同一客户端两个请求之间的等待时间。

#

KeepAliveTimeout 15

#

# 在Win32下,Apache每次产生一个子进程来处理请求。

# 如果这个进程死了,会自动产生另一个子进程。

# 所有的进入请求在子进程中多线程处理。

# 以下两个标识控制进程的运行

#

#

# MaxRequestsPerChild: 每个子进程死亡之前最大请求数

# 如果超过这个请求数,子程序会自动退出,避免延期使用导致内存溢出或其他问题。

# 大部分系统,并不需要此设置,

# 但是部分,象Solaris,确实值得注意。

# 对Win32, 可设置为0 (无限制)

# 除非有另外的考虑。

#

# 注: 此值不包括在每个连接初始化请求后,”keptalive”请求

# 例如, 如果一个子进程处理一个初始化请求和10个后续”keptalive”请求,

# 在这个限制下,只会记为一个请求。

#

MaxRequestsPerChild 0

#

# ThreadsPerChild: 服务器所允许的并发线程数。

# 此值的设置取决于服务器的响应能力(约多的请求在同一时间激活,则每个请求的处理时间越慢)

# 和服务器所允许消耗的系统资源。

#

ThreadsPerChild 50

#

# Listen: 允许将Apache绑顶到指定的IP地址和端口,作为默认值的辅助选项。

# 参见

#

#Listen 3000

#Listen 12.34.56.78:80

#

# BindAddress: 通过此选项可支持虚拟主机。

# 此标识用于告诉服务器监听哪个IP地址。

# 包括:”*”, IP地址, 或域名.

# 参见 和 Listen directives.

#

BindAddress 166.111.178.144

#

# Apache模块编译成标准的Windows结构。

#

# 以下模块绑定到标准的Apache二进制windows分布。

# 要修改标准操作,取消以下行的注释并且修改指定模块列表。

#

# 警告:这是高级选项。可能导致服务器崩溃。

# 没有专家的指导,不要轻易修改。

#

#ClearModuleList

#AddModule mod_so.c mod_mime.c mod_access.c mod_auth.c mod_negotiation.c

#AddModule mod_include.c mod_autoindex.c mod_dir.c mod_cgi.c mod_userdir.c

#AddModule mod_alias.c mod_env.c mod_log_config.c mod_asis.c mod_imap.c

#AddModule mod_actions.c mod_setenvif.c mod_isapi.c

#

# 动态共享对象(Dynamic Shared Object,DSO)

#

# 要使用基于DSO的功能模块,需要替换此处相应的

# `LoadModule 行。这样在使用之前这些包含的标识都将生效。

# 有关DSO及至的详细资料请看Apache1.3版中的README.DSOSO。

# 运行”apche -l”将列表显示Apache内奸的模块(类似标准的连接已经生效)

#

# 注:模块载入的顺序很重要。没有专家的建议,不要修改以下的顺序。

#

#LoadModule anon_auth_module modules/ApacheModuleAuthAnon.dll

#LoadModule dbm_auth_module modules/ApacheModuleAuthDBM.dll

#LoadModule digest_auth_module modules/ApacheModuleAuthDigest.dll

#LoadModule cern_meta_module modules/ApacheModuleCERNMeta.dll

#LoadModule digest_module modules/ApacheModuleDigest.dll

#LoadModule expires_module modules/ApacheModuleExpires.dll

#LoadModule headers_module modules/ApacheModuleHeaders.dll

#LoadModule proxy_module modules/ApacheModuleProxy.dll

#LoadModule rewrite_module modules/ApacheModuleRewrite.dll

#LoadModule speling_module modules/ApacheModuleSpeling.dll

#LoadModule info_module modules/ApacheModuleInfo.dll

#LoadModule status_module modules/ApacheModuleStatus.dll

#LoadModule usertrack_module modules/ApacheModuleUserTrack.dll

#

# ExtendedStatus 在服务器状态句柄被呼叫时控制是产生“完整”的状态信息(ExtendedStatus On)

# 还是仅返回基本信息(ExtendedStatus Off)

# 默认是:Off

#

#ExtendedStatus On

### 部分 2: 主服务器配置

#

# 此部分的标识用于主服务器所有的设置值,

# 响应任何定义不处理的请求

# 这些值同时给你稍后在此文件中定义的提供默认值。

#

# 所有的标识可能会在中出现。

# 对应的默认值会被虚拟主机重新定义覆盖。

#

#

# Port: Standalone服务器监听的端口。

# 在Apache能够监听指定端口前,需要在防火墙中进行设置。

# 其它运行httpd的服务器也可能影响此端口。 Disable

# 如果遇到问题,请关闭所有的防火墙、安全保护和其他的服务。

# Windos NT的”NETSTAT -a”指令会有助于问题的分析。

#

Port 80

#

# ServerAdmin: 你的地址。如果服务器有任何问题将发信到这个地址。

# 这个地址会在服务器产生的某些页面中出现,例如,错误报告。

#

ServerAdmin chenyl98@mails.tsinghua.edu.cn

#

# ServerName 允许设置主机名。如果与程序获得的不同,主机名将返回客户端。

# (例如,用”www”代替主机真实的名字)

#

# 注: 主机名不能随便指定。必须是你的机器有效的DNS名称。否则无法正常工作。

# 如果不能理解,倾向你的网络管理员询问。

# 如果你的主机没有注册DNS名,可在此输入IP地址。

# 此时必须用IP地址来访问。(如, http://123.45.67.89/)

# 这样扔可以完成重新定向的工作。

#

# 127.0.0.1 是TCP/IP的本地环路地址, 通常命名为localhost.

# 机器默认此地置为本身。 如果只是使用Apache来进行本地测试和开发,

# 可使用127.0.0.1 作为服务器名.

#

#ServerName new.host.name

#

# DocumentRoot: 放置服务文档的目录。

# 默认状态下,所有的请求都以这个目录为基础。

# 但是直接符号连接和别名可用于指向其他位置。

#

DocumentRoot “D:/www_root”

#

# Apache访问的每个目录可设置相关的服务和特性是允许或(和)不允许。

# (同样影响其子目录)

#

# 首先,设置”default”地址只有最基本的权限。

#

Options FollowSymLinks

AllowOverride None

#

# 注意从现在开始必须制定开启特殊的权限。

# 这样就不会产生意想不到的结果。

# 请仔细确认。

#

#

# 这个地址应与DocumentRoot保持一致

#

#

# 此值可是: “None”, “All”, 或下列的组合: “Indexes”,

# “Includes”, “FollowSymLinks”, “ExecCGI”, 或 “MultiViews”.

#

# 注意”MultiViews”必须明确指定— “Options All”不包括此特性。

#

Options Indexes FollowSymLinks MultiViews

#

# 此项控制目录中哪些.htaccess文件可覆盖。

# 允许值: “All”或者以下项的组合:”Options”, “FileInfo”,

# “AuthConfig”, “Limit”

#

AllowOverride None

#

# 控制哪些用户可从此服务器获得资料。

#

Order allow,deny

Allow from all

#

# UserDir: 当请求~user时,追加到用户主目录的路径地址。

#

# 在Win32下,并不要求指定为用户登陆的主目录。

# 因此可使用以下的格式。

# 详细参照文档UserDir

#

UserDir “f:/homepages/”

#

# 控制访问UserDir目录. The following is an example

# 以下是一个站点的例子,权限限制为只读。

#

#

# AllowOverride FileInfo AuthConfig Limit

# Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec

#

# Order allow,deny

# Allow from all

#

#

# Order deny,allow

# Deny from all

#

#

#

# DirectoryIndex: 预设的HTML目录索引文件名。

# 用空格来分隔多个文件名。

#

DirectoryIndex index.html

#

# AccessFileName: 每个目录中用于控制访问信息的文件名。

#

AccessFileName .htaccess

#

# 以下行防止客户端可访问 .htaccess 文件。

# 因为 .htaccess文件通常包含授权信息,

# 处于安全的考虑不允许访问。

# 如果想让访客看到.htaccess文件的内容,

# 可将这些行注释。

# 如果修改了上面的AccessFileName,

# 请在此进行相应的修改。

#

# 同时,一般会用类似.htpasswd的文件保存密码。

# 这些文件同样可以得到保护。

#

Order allow,deny

Deny from all

#

# CacheNegotiatedDocs: 默认下,Apache对每个文档发送”Pragma: no-cache”

# 这将要求代理服务器不缓存此文档。

# 取消下列行的可取消这个属性,这样代理服务器将缓存这些文档。

#

#CacheNegotiatedDocs

#

# UseCanonicalName: (1.3新增) 当此设置为on时,

# 无论何时Apache需要构建一个自引用的URL(指向响应来源服务器),

# 它将用ServerName和Port来构建一个规范的格式。

# 当此设置为off时,Apache将使用客户端提供的”主机名:端口”

# 这将同时影响CGI脚本中的SERVER_NAME和SERVER_PORT

#

UseCanonicalName On

#

# TypesConfig 记录媒体类型(mime.types)文件或类似的东东放置的位置

#

TypesConfig conf/mime.types

#

# DefaultType 是服务器处理未确认类型的文件,如为止的扩展名,的默认类型。

# 如果你的服务器上主要包含的是文本或HTML文档,”text/plain”是较好的设置

# 如果服务器上主要包含二进制文件,如应用程序或图片,

# 最好设置成”application/octet-stream”防止浏览器将二进制文件以文本的方式显示。

#

DefaultType text/plain

#

# mod_mime_magic模块允许服务器使用文件自身的不同标识来确定文件类型。

# MIMEMagicFile指示模块文件标识的定义所在的位置。

# mod_mime_magic不是默认服务器的一部分。

# (必须自行用LoadModule来追加 [见全局环境部分的 DSO 章节],

# 或者在编译服务器时包含mod_mime_magic部分)

# 包含在 中.

# 就是说,如果该模块是服务器的一部分,MIMEMagicFile标识将执行。

#

MIMEMagicFile conf/magic

#

# HostnameLookups: 注册客户端的机器名或IP地址。

# 例如: www.apache.org (on) 或 204.62.129.132 (off).

# 默认为off,因为对于网络来说,最好让人们有意识的设置为on,

# 因为开启此功能意味着每个客户请求将导致至少向name服务器发送一个lookup请求

#

HostnameLookups Off

#

# ErrorLog: 错误记录文件的地址

# 如果不在内指定ErrorLog

# 改虚拟主机的错误心细将记录到此处。

# 如果在中明确指定了错误记录文件,

# 则错误将记录在那儿而不是这儿。

#

ErrorLog logs/error.log

#

# LogLevel: 控制记录在error.log中信息的个数.

# 可能的值:debug, info, notice, warn, error, crit,

# alert, emerg.

#

LogLevel warn

#

# 以下标识定义CustomLog标识使用的格式。(见下)

#

LogFormat “%h %l %u %t \”%r\” %>s %b \”%{Referer}i\” \”%{User-Agent}i\”” combined

LogFormat “%h %l %u %t \”%r\” %>s %b” common

LogFormat “%{Referer}i -> %U” referer

LogFormat “%{User-agent}i” agent

#

# 访问记录的位置和格式 (功用的记录文件格式).

# 如果不在中定义记录文件,

# 那些访问记录就将保存在这儿。 Contrariwise, if you *do*

# 反之,如果指定了记录文件,那么访问记录将记录在那儿而不是这个文件中。

#

CustomLog logs/access.log common

#

# 如果希望使用代理和参考的记录文件, 取消以下标识的注释符

#

#CustomLog logs/referer.log referer

#CustomLog logs/agent.log agent

#

# 如果想在一个文件中记录访问、代理、参考信息(复合的记录格式)

# 可使用以下标识

#

#CustomLog logs/access.log combined

#

# 在服务器产生的页面(如错误文档信息,FTP目录列表等等,不包括CGI产生的文档)中

# 增加一条服务器版本和虚拟主机名的信息。

# 设置为”EMail”将包含mailto: ServerAdmin的连接.

# 可选值: On | Off | EMail

#

ServerSignature On

#

# 默认下,Apache用工作行解析所有CGI脚本

# 此注释行(脚本的第一行)包括#和!后面跟着执行特殊脚本的程序路径,

# 对perl脚本来说是C:\Program Files\Perl目录中的perl.exe。

# 工作行如下:

#!c:/program files/perl/perl

# 注意真实的工作行不能有缩进,必须是文件的第一行。

# 当然,CGI进程必须通过适当的scriptAlias或ExecCGI选项标识来启动。

#

# 然而,Windows下的Apache即允许以上的Unix方式,也可以通过注册表的形式。

# 用注册表执行文件的方法同在Windows资源管理器中双击运行的注册方法相同。

# 此脚本操作可在Windows资源管理器的“查看”菜单中设置。

# “文件夹选项”,然后查看“文件类型”。点击编辑按钮。

# 修改操作属性。Apache 1.3会尝试执行‘Open操作,

# 如果失败则会尝试工作行

# 这个属性在Apache release 2.0中会有改变.

#

# 每个机制都有自身特定的安全弱点,这样可能导致别人运行你不希望调用的程序。

# 最佳的解决方案还在讨论中。

#

# 要是这个Windows的特殊属性生效 (同时会是Unix属性无效)

# 取消下列标识的注释符。

#

#scriptInterpreterSource registry

#

# 上面的标识可在块或.htaccess文件中单独替换。

# 可选择registry (Windows behavior)或 script

# (Unix behavior) option, 将覆盖服务器的默认值。

#

#

# Aliases: 可无限制的追加别名。格式如下:

# Alias 假名 真名

#

#

# 注意如果假名中包含/,服务器会在当前URL中发出请求。

# 因此”/icons”不能用于别名

# 必须用 “/icons/”..

#

Alias /icons/ “C:/Program Files/Apache Group/Apache/icons/”

Options Indexes MultiViews

AllowOverride None

Order allow,deny

Allow from all

#

# scriptAlias: 控制哪个目录包含服务器脚本。

# scriptAlias本质行和Aliases一样。, except that

# 区别在于真名目录中的文档被看作是一个应用程序。

# 请求时由服务器运行而不是发往客户端。

# “/”符号的规则同

# Alias相同.

#

scriptAlias /cgi-bin/ “C:/Program Files/Apache Group/Apache/cgi-bin/”

#

# “C:/Program Files/Apache Group/Apache/cgi-bin” 可修改为任何放置CGI脚本的目录

#

AllowOverride None

Options None

Order allow,deny

Allow from all

# 别名结束

#php脚本说明

scriptAlias /php/ “d:/php/”

AddType application/x-httpd-php .php

AddType application/x-httpd-php .php3

AddType application/x-httpd-php .phtml

Action application/x-httpd-php “/php/php.exe”

#php脚本说明结束

#

# Redirect 允许告诉客户端服务器上曾经有的文档,但是现在不存在了。

# 并且可以告诉客户端到哪儿去寻找。

# 格式: Redirect old-URL new-URL

#

#

# 控制服务器目录列表显示的标识

#

#

# FancyIndexing标识是使用特定的目录检索还是标准的(standard)

#

IndexOptions FancyIndexing

#

# AddIcon*表明不同文件或扩展名显示的图标。

# 这些图标只在特定检索状态下显示。

#

AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip

AddIconByType (TXT,/icons/text.gif) text/*

AddIconByType (IMG,/icons/image2.gif) image/*

AddIconByType (SND,/icons/sound2.gif) audio/*

AddIconByType (VID,/icons/movie.gif) video/*

AddIcon /icons/binary.gif .bin .exe

AddIcon /icons/binhex.gif .hqx

AddIcon /icons/tar.gif .tar

AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv

AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip

AddIcon /icons/a.gif .ps .ai .eps

AddIcon /icons/layout.gif .html .shtml .htm .pdf

AddIcon /icons/text.gif .txt

AddIcon /icons/c.gif .c

AddIcon /icons/p.gif .pl .py

AddIcon /icons/f.gif .for

AddIcon /icons/dvi.gif .dvi

AddIcon /icons/uuencoded.gif .uu

AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl

AddIcon /icons/tex.gif .tex

AddIcon /icons/bomb.gif core

AddIcon /icons/back.gif ..

AddIcon /icons/hand.right.gif README

AddIcon /icons/folder.gif ^^DIRECTORY^^

AddIcon /icons/blank.gif ^^BLANKICON^^

#

# DefaultIcon 用于为制定图标的文件所显示的图标。

#

DefaultIcon /icons/unknown.gif

#

# AddDescription在服务器生成的检索的某个文件后追加小段说明。

# 此项只在设置为FancyIndexed时有效

# 格式:AddDescription “描述” 文件名

#

#AddDescription “GZIP compressed document” .gz

#AddDescription “tar archive” .tar

#AddDescription “GZIP compressed tar archive” .tgz

#

# ReadmeName是服务器默认的README文件。

# 并且会追加到目录列表的最后。

#

# HeaderName 是目录中需要预先显示内容的文件名。

#

# 如果MultiViews在选项中,作为结果,服务器将先找name.html,

# 如果存在就包含它。如果name.html不存在,

# 服务器会继续寻找name.txt。如果存在就作为纯文本包含进来。

#

ReadmeName README

HeaderName HEADER

#

# IndexIgnore是一系列的文件名。目录索引将忽略这些文件并且不包含在列表中。

# 允许使用通配符。

#

IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t

# indexing标识结束

#

# 文件类型

#

#

# AddEncoding 可用于特殊浏览器(Mosaic/X 2.1+)快速传输压缩信息。

# 注:并不是所有的服务器都支持。

# 除了名字相似,以下Add*标识对上面的FancyIndexing定制标识无影响。

#

AddEncoding x-compress Z

AddEncoding x-gzip gz tgz

#

# AddLanguage用于指定文档的语言。

# 可以使用content标签指定每个文件的语言。

#

# 注 1: 后缀不必与所用语言的关键字相同。

# — 波兰语(Polish,标准代码为pl)的文档可以用

# “AddLanguage pl .po” 来避免与perl脚本文件混淆。

#

# 注 2: 以下例子表明两个字母的语言缩写和两个字母的国家缩写并不一定相同。

# E.g. Danmark/dk 对比 Danish/da.

#

# 注 3: 其中ltz使用了三个字符,与RFC的规定不同。

# 但是这个问题正在修订中,并且重新清理RFC1766

#

# 丹麦Danish (da) – 荷兰Dutch (nl) – 英国English (en) – 爱萨尼亚Estonian (ee)

# 法国French (fr) – 德国German (de) – 现代希腊文Greek-Modern (el)

# 意大利Italian (it) – 朝鲜Korean (kr) – 挪威Norwegian (no)

# 葡萄牙Portuguese (pt) – 卢森堡Luxembourgeois* (ltz)

# 西班牙Spanish (es) – 瑞典Swedish (sv) – 加泰罗尼亚Catalan (ca) – 捷克Czech(cz)

# 波兰Polish (pl) – 巴西Brazilian Portuguese (pt-br) – 日本Japanese (ja)

# 俄国Russian (ru)

#

AddLanguage da .dk

AddLanguage nl .nl

AddLanguage en .en

AddLanguage et .ee

AddLanguage fr .fr

AddLanguage de .de

AddLanguage el .el

AddLanguage he .he

AddCharset ISO-8859-8 .iso8859-8

AddLanguage it .it

AddLanguage ja .ja

AddCharset ISO-2022-JP .jis

AddLanguage kr .kr

AddCharset ISO-2022-KR .iso-kr

AddLanguage no .no

AddLanguage pl .po

AddCharset ISO-8859-2 .iso-pl

AddLanguage pt .pt

AddLanguage pt-br .pt-br

AddLanguage ltz .lu

AddLanguage ca .ca

AddLanguage es .es

AddLanguage sv .se

AddLanguage cz .cz

AddLanguage ru .ru

AddLanguage tw .tw

AddCharset Big5 .Big5 .big5

AddCharset WINDOWS-1251 .cp-1251

AddCharset CP866 .cp866

AddCharset ISO-8859-5 .iso-ru

AddCharset KOI8-R .koi8-r

AddCharset UCS-2 .ucs2

AddCharset UCS-4 .ucs4

AddCharset UTF-8 .utf8

# LanguagePriority 可设置语言的优先级。

#

# 优先级降序排列

# 在此处按照字母顺序,可自行修改

#

LanguagePriority en da nl et fr de el it ja kr no pl pt pt-br ru ltz ca es sv tw

#

# AddType 可临时改变mime.types或者指定特殊文件的格式。

#

# 例如:PHP 3.x 模块 (非Apache标准配件,参见http://www.php.net)可用下面格式定义:

#

#AddType application/x-httpd-php3 .php3

#AddType application/x-httpd-php3-source .phps

#

# PHP 4.x, 使用:

#

#AddType application/x-httpd-php .php

#AddType application/x-httpd-php-source .phps

AddType application/x-tar .tgz

#

# AddHandler 可将特定文件扩展名映射到处理方法上。

# 与文件类型无关。此特性可内建到服务器中或者追加在操作指令中(见下)

#

# 如果希望用服务器端应用或scriptAliased外的CGI,取消以下行的注释符

#

# 用CGI脚本:

#

#AddHandler cgi-script .cgi

#

# 用服务器解析的HTML文档

#

#AddType text/html .shtml

#AddHandler server-parsed .shtml

#

# 取消以下注释符可激活Apache的send-asis HTTP file特性

#

#AddHandler send-as-is asis

#

# 如果使用服务器端解析的图像定位文件,使用以下标识:

#

#AddHandler imap-file map

#

# 要激活type maps使用:

#

#AddHandler type-map var

# 文档类型说明结束

#

# Action 定义在文件匹配时执行相应的脚本。

# 可简化常用CGI文件的调用。

# 格式: Action media/type /cgi-script/location

# 格式: Action handler-name /cgi-script/location

#

#

# MetaDir: 指定保存meta信息文件的目录。

# 这些文件包含附加的HTTP头,在发送文档是一并发送。

#

#MetaDir .web

#

# MetaSuffix: 指定包含meta信息的文件的后缀。

#

#MetaSuffix .meta

#

# 可定制的错误响应(Apache类型)

# 共三种风格:

#

# 1) 纯文本

#ErrorDocument 500 “The server made a boo boo.

# 注: 第一个”号用于表示是文本,实际不输出

#

# 2) 本地重定向

#ErrorDocument 404 /missing.html

# to redirect to local URL /missing.html

#ErrorDocument 404 /cgi-bin/missing_handler.pl

# 注:可重定向到任何一个服务器端的脚本或文档

#

# 3) 外部重定向

#ErrorDocument 402 http://some.other_server.com/subscription_info.html

# 注: 大部分与初始请求关联的环境变量对这样的脚本无效。

#

#

# 基于浏览器的定制操作

#

#

# 以下标识修改普通的HTTP响应操作。

# 第一个标识针对Netscape2.x和其他无此功能的浏览器取消保持激活状态的功能

# 这些浏览器在执行这些功能时会出错。

# 第二个标识针对IE4.0b2设置。其中有一条不完整的HTTP/1.1指令

# 在301或302(重定向)响应时不能正确的保持激活状态

#

BrowserMatch “Mozilla/2” nokeepalive

BrowserMatch “MSIE 4\.0b2;” nokeepalive downgrade-1.0 force-response-1.0

#

# 下面的标识通过不产生基本的1.1响应取消对违反HTTP/1.0标准的浏览器的响应。

#

BrowserMatch “RealPlayer 4\.0” force-response-1.0

BrowserMatch “Java/1\.0” force-response-1.0

BrowserMatch “JDK/1\.0” force-response-1.0

# 浏览器定制标识结束

#

# 允许使用URL”http://servername/server-status”的形式查看服务器状态报告

# 修改 “.your_domain.com”来匹配相应的域名以激活此功能

#

#

# SetHandler server-status

# Order deny,allow

# Deny from all

# Allow from .your_domain.com

#

#

# 允许使用URL”://servername/server-info”(要求加载mod_info.c),

# 来远程察看服务器配置报告。

# 修改 “.your_domain.com”来匹配相应的域名以激活此功能

#

#

# SetHandler server-info

# Order deny,allow

# Deny from all

# Allow from .your_domain.com

#

#

# 据报有人试图利用一个老的1.1漏洞。

# 这个漏洞与CGI脚本在Apache服务器上分布有关。

# 通过取消下面几行的注释符,可以将此类攻击记录转移到phf.apache.org上的记录脚本上。

# 或者也可以利用脚本scriptsupport/phf_abuse_log.cgi记录在本地服务器上。

#

#

# Deny from all

# ErrorDocument 403 http://phf.apache.org/phf_abuse_log.cgi

#

#

# 代理服务器标识。取消下列行的注释符可激活代理服务器。

#

#

# ProxyRequests On

#

# Order deny,allow

# Deny from all

# Allow from .your_domain.com

#

#

# 激活/取消处理HTTP/1.1 “Via:” 报头

# (“Full”:加入服务器版本; “Block”:取消所有外发的Via: 报头)

# 可设置值: Off | On | Full | Block

#

# ProxyVia On

#

# 可修改下列各行并取消注释符来激活缓存。

# (没有CacheRoot标识就不使用缓存)

#

# CacheRoot “E:/Program Files/Apache Group/Apache/proxy”

# CacheSize 5

# CacheGcInterval 4

# CacheMaxExpire 24

# CacheLastModifiedFactor 0.1

# CacheDefaultExpire 1

# NoCache a_domain.com another_domain.edu joes.garage_sale.com

#

# 代理标识结束

### 部分 3: 虚拟主机

#

# 虚拟主机: 如果希望在一台服务器上实现多个域名和主机名的服务,

# 可设置VirtualHost来实现。Most configurations

# 大部分的设置使用基于名称的虚拟主机,这样服务器就不必为IP地址操心。

# 这些用星号在下面的标识中标出。

#

# 在试图设置虚拟主机前

# 请阅读中的文档。

# 以了解细节问题。

#

# 可用命令行参数 -S来确认虚拟主机的设置。

#

#

# 使用基于名称的虚拟主机

#

#NameVirtualHost *

#

# 虚拟主机实例:

# 几乎所有的Apache标识都可用于虚拟主机内。

# 第一个VirtualHost部分用于申请一个无重复的服务器名。

#

#

# ServerAdmin webmaster@dummy-host.example.com

# DocumentRoot /www/docs/dummy-host.example.com

# ServerName dummy-host.example.com

# ErrorLog logs/dummy-host.example.com-error_log

# CustomLog logs/dummy-host.example.com-access_log common

#</VirtualHost>
声明: 猿站网有关资源均来自网络搜集与网友提供,任何涉及商业盈利目的的均不得使用,否则产生的一切后果将由您自己承担! 本平台资源仅供个人学习交流、测试使用 所有内容请在下载后24小时内删除,制止非法恶意传播,不对任何下载或转载者造成的危害负任何法律责任!也请大家支持、购置正版! 。本站一律禁止以任何方式发布或转载任何违法的相关信息访客发现请向站长举报,会员发帖仅代表会员个人观点,并不代表本站赞同其观点和对其真实性负责。本网站的资源部分来源于网络,如有侵权烦请发送邮件至:2697268773@qq.com进行处理。
建站知识

小知识:Apache 安装配置mod_pagespeed加速模块

2023-3-17 13:28:35

建站知识

小知识:PHP脚本内存泄露导致Apache频繁宕机解决方法

2023-3-17 13:43:08

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索