httpd.conf :
ServerRoot "/usr"
#因为安装到/usr下,所以ServerRoot是/usr。在以下配置中,以相对路径写的就是对于相对/usr
PidFile /var/run/httpd.pid
#httpd启动时的pid存放位置,用于start/stop apache
Timeout 300
#连接超时时间
KeepAlive On
#允许持续连接,一个连接多个请求.
MaxKeepAliveRequests 200
#持续连接中最大连接数,推荐大一些获得最佳性能
KeepAliveTimeout 15
#Client 在15秒内没有下次请求则断线
MinSpareServers 5
MaxSpareServers 10
httpd服务进程的数量,ps aux 可以看到
MaxClients 150
最大连接人数
Listen 80
#监听端口
#ExtendedStatus On
#使用/server-status查询服务器状态时给予完全信息(ON)或基本信息(OFF) 默认为OFF
User apache
Group apache
#httpd进程的user,group
ServerAdmin yzhang0207@126.com
#admin的E-mail
ServerName 127.0.0.1
#服务器名称,需要是合法的DNS NAME 或者设置成IP
DocumentRoot "/srv/www/htdocs"
#主页存放目录
UserDir public_html
#每个用户的主页目录 (例如:/home/blue/public_html)
DirectoryIndex index.php index.html index.html.var
#当输入http://localhost 就会在主页根目录下搜索以上几个文件名做为首页显示
HostnameLookups Off
#记录log时,Client以主机名(On)或以IP(Off)记录,以IP记录更快些.
ErrorLog /var/log/apache/error_log
#错误日志位置
LogLevel warn
#日志记录等级,由信息多->少记录等级:debug, info, notice, warn, error, crit,alert,emerg
CustomLog /var/log/apache/access_log common
#访问日志位置
ServerTokens Prod
#当client访问到不存在的网页时提供信息的多少。少点好些 :)
#由多-->少 :Full | OS | Minor | Minimal | Major | Prod
LanguagePriority zh-CN en ca cs da de ..........
#语言优先级
ErrorDocument 404 /missing.html
#错误网页处理,当出现404(找不到该页)则会显示/missing.html
目录设定:
设定根目录属性:
Options FollowSymLinks
AllowOverride None
Options 属性:
Indexes 当该目录下没有index.*时则以ftp-style列出该目录下所有文件
Includes Allow server-wide includes
FollowSymLinks 当该目录下软连接的文件/目录链接到外部目录时,仍然可以正常显示。
MultiViews 由一个*.var管理同一网页的多种语言版本,如apache默认主页多种语言的index.html
ExecCGI 允许执行CGI程序
ALL 开启除MultiViews之外的属性
None 禁止所有属性
AllowOverride 属性:是否允许使用.htaccess覆盖某些设定(All None FileInfo AuthConfig Limit)
设定/srv/www/htdocs/ 目录(根目录)属性:
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
Order allow,deny : 控制访问权限
Order deny,allow
deny from test.org 拒绝test.org访问
deny from 192.168.0.100 拒绝192.168.0.100访问
allow from 192.168.0.1 允许192.168.0.1 访问
Alias /icons/ "/srv/www/icons/"
语法: Alias fakename realname
设置目录的别名,这样当输入http://localhost/icons/ 就可以访问到/srv/www/icons/
注意icons结尾的"/" 应在fakename realname 成对出现,要么全有,要么全没有.
有"/"时需要输入http://localhost/icons/ 才可以正常访问
ScriptAlias /cgi-bin/ "/srv/www/cgi-bin/"
设置可执行程序别名,与Alias类似。
当Client请求Alias realname时,server直接以document形式传送Client
而ScroptAlias则是server执行realname的script程序后将结果传送给Client
服务器的状态,信息:
通过http://localhost/server-status 访问
SetHandler server-status
Order deny,allow
Deny from all
Allow from 127.0.0.1
通过http://localhost/server-info 访问
SetHandler server-info
Order deny,allow
Deny from all
Allow from 127.0.0.1