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
|
1,主配置文件模板
# cat httpd.conf
ServerRoot
"/usr/local/apache"
Listen 80
LoadModule authn_file_module modules
/mod_authn_file
.so
LoadModule authn_core_module modules
/mod_authn_core
.so
LoadModule authz_host_module modules
/mod_authz_host
.so
LoadModule authz_groupfile_module modules
/mod_authz_groupfile
.so
LoadModule authz_user_module modules
/mod_authz_user
.so
LoadModule authz_core_module modules
/mod_authz_core
.so
LoadModule access_compat_module modules
/mod_access_compat
.so
LoadModule auth_basic_module modules
/mod_auth_basic
.so
LoadModule reqtimeout_module modules
/mod_reqtimeout
.so
LoadModule filter_module modules
/mod_filter
.so
LoadModule mime_module modules
/mod_mime
.so
LoadModule log_config_module modules
/mod_log_config
.so
LoadModule env_module modules
/mod_env
.so
LoadModule headers_module modules
/mod_headers
.so
LoadModule setenvif_module modules
/mod_setenvif
.so
LoadModule version_module modules
/mod_version
.so
LoadModule unixd_module modules
/mod_unixd
.so
LoadModule status_module modules
/mod_status
.so
LoadModule autoindex_module modules
/mod_autoindex
.so
LoadModule negotiation_module modules
/mod_negotiation
.so
LoadModule dir_module modules
/mod_dir
.so
LoadModule alias_module modules
/mod_alias
.so
LoadModule rewrite_module modules
/mod_rewrite
.so
LoadModule php5_module modules
/libphp5
.so
AddType application
/x-httpd-php
.php .php5
AddType application
/x-httpd-php-source
.phps
<IfModule unixd_module>
User www
Group www
<
/IfModule
>
ServerAdmin you@example.com
ServerName localhost
<Directory />
AllowOverride none
Require all denied
<
/Directory
>
DocumentRoot
"/usr/local/apache/htdocs"
<Directory
"/usr/local/apache/htdocs"
>
Options FollowSymLinks
AllowOverride None
Rquire all granted
<
/Directory
>
<IfModule dir_module>
DirectoryIndex index.php index.html
<
/IfModule
>
<Files
".ht*"
>
Require all denied
<
/Files
>
ErrorLog
"logs/error_log"
LogLevel warn
<IfModule log_config_module>
LogFormat
"%h %a %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
combined
LogFormat
"%h %a %l %u %t \"%r\" %>s %b"
common
<IfModule logio_module>
LogFormat
"%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O"
combinedio
<
/IfModule
>
CustomLog
"logs/access_log"
common
<
/IfModule
>
<IfModule alias_module>
ScriptAlias
/cgi-bin/
"/usr/local/apache/cgi-bin/"
<
/IfModule
>
<IfModule cgid_module>
#
# ScriptSock: On threaded servers, designate the path to the UNIX
# socket used to communicate with the CGI daemon of mod_cgid.
#
#Scriptsock cgisock
<
/IfModule
>
<Directory
"/usr/local/apache/cgi-bin"
>
AllowOverride None
Options None
Require all granted
<
/Directory
>
<IfModule mime_module>
TypesConfig conf
/mime
.types
AddType application
/x-compress
.Z
AddType application
/x-gzip
.gz .tgz
<
/IfModule
>
Include conf
/extra/httpd-mpm
.conf
Include conf
/extra/httpd-multilang-errordoc
.conf
Include conf
/vhosts/
*.conf
Include conf
/extra/httpd-default
.conf
<IfModule proxy_html_module>
Include conf
/extra/proxy-html
.conf
<
/IfModule
>
<IfModule ssl_module>
SSLRandomSeed startup
builtin
SSLRandomSeed connect
builtin
<
/IfModule
>
LoadModule remoteip_module modules
/mod_remoteip
.so
RemoteIPHeader X-Forwarded-For
RemoteIPInternalProxy 127.0.0.1 1.1.1.1 2.2.2
<Files ~
"\.tar|\.bz2|\.svn|\*.gz"
>
Require all denied
<
/Files
>
<DirectoryMatch .*\.svn/.*>
Require all denied
<
/DirectoryMatch
>
2,默认配置文件模板
# cat defaults.conf
#2.4
<VirtualHost *:80>
ServerAdmin root@myself.com
DocumentRoot
/usr/local/apache/htdocs/
<Directory
"/usr/local/apache/htdocs/"
>
Options FollowSymLinks
AllowOverride None
Require all denied
<
/Directory
>
<
/VirtualHost
>
3,禁止ip访问模板
# cat 1.1.1.1.conf
<VirtualHost *:80>
ServerAdmin root@myself.com
ServerName 1.1.1.1
ServerAlias 2.2.2.2
DocumentRoot
/usr/local/apache/htdocs/
<Directory
"/usr/local/apache/htdocs/"
>
Options FollowSymLinks
AllowOverride None
Require all denied
<
/Directory
>
<
/VirtualHost
>
4,虚拟主机配置文件模板
# cat www.test.com.conf
#www.test.com
<VirtualHost *:80>
ServerAdmin admin@
test
.com
DocumentRoot
/data/web_root/www
.
test
.com
/www
ServerName www.
test
.com
ServerAlias iwww.
test
.com
ErrorLog
"/data/logs/apache/www.test.com-error_log"
CustomLog
"|/usr/local/apache/bin/rotatelogs /data/logs/apache/www.test.com-access_log_%Y%m%d.log 86400 480"
combined
RewriteEngine On
<Directory
"/data/web_root/www.test.com/www"
>
Options FollowSymLinks
AllowOverride all
Require all granted
<
/Directory
>
<
/VirtualHost
>
|
本文转自 wpf926 51CTO博客,原文链接:http://blog.51cto.com/wupengfei/1956600,如需转载请自行联系原作者