posts - 8, comments - 7, trackbacks - 0, articles - 64

linux配置文件参考

Posted on 2005-12-17 16:54 YGB.Grushy 阅读(1682) 评论(0)  编辑 收藏 引用 所属分类: Linux目录和文件

linux配置文件参考


/etc/passwd


1.文件格式
/etc/passwd存储了系统中所有用户的基本信息.可以说这是系统中最重要的一个配置文件.对它作任何修改一定要小心谨慎.同时要经常检察这个文件,包括它的内容和权限设置.
使用vi编辑程序打开此文件,可以看到这个文件由许多行记录组成.每一行记录对应着一个用户.我们以第一行为例.第一行一般是root用户的记录,尽管这不是必需的.实际上用户记录出现的顺序并没有任何的意义.
在我的系统中,/etc/passwd的第一行看起来是这样的:
root:x:0:0:root:/root:/bin/bash
每 一条记录都由7个字段组成,每个字段之间用冒号隔开.第一个字段是用户名,示例中是root.第二个字段是用户口令,示例中是一个字符x,但这并不表示 root的口令是单个字符x,而是说用户口令被加密了,并且加密口令也没有放在本文件中,而是放到了/etc/shadow(参考 /etc/shadow).假如删除这个x,那么root的口令就清空了.第三个字段是用户的用户ID,即uid.第四个字段是用户的组ID,即gid. 这里要注意,系统分辨两个用户是看他们的uid是否相同而不是看他们的用户名是否相同.用户名不同但uid相同的两个用户实际上是同一个用户.对组来说也 有类似的规则.所以这两个字段大家一定要注意.第五个字段是用户全称,没有什么实际用途,相当于注释,这里是root.第六个字段是用户的主目录 (home),即登录系统后默认所处目录,这里是/root.最后一个字段是用户的登录shell,可以是系统拥有的任何一个shell的完整路径,这里 是/bin/bash.注意,这个字段可以有一个特殊的值,即/sbin/nologin.如果把一个用户的登录shell设置为 /sbin/nologin的话,系统将禁止此用户的本地登录.

2.安全性
/etc/passwd的默认权限为644,所有者和所有组均为root.切记,在任何情况下都不要更改它.

3.相关命令
passwd
useradd
userdel
adduser
usermod
users


--  作者:admin
--  发布时间:2005-2-9 18:54:45

--  
/etc/group

1.文件格式
/etc/group存储了系统中所有用户的基本信息.它的格式和/etc/passwd的格式基本类似,这里就说简单一点,
/etc/group也是由一条条的记录组成.每条记录分4个字段.分别是组名,组口令,组ID和该组包含用户列表.其中组口令不再使用(现在只是保留为 x).最后一个域是一个用逗号分隔的用户名列表,这个组的成员就是在这里列出的所有用户.

2.安全性
/etc/group的默认权限是644,所有者和所有组均为root.注意经常检察.

3.相关命令
groupadd
groupdel
groupmod
groups

/etc/fstab

1.文件格式
/etc/fstab 记载了系统启动时自动挂载的文件系统。一行为一条记录。每条记录有6个字段,字段间用空格或者tab键分开。这六个字段分别是:设备名称,挂载点(除交换 分区为swap外,都必须是一个存在的目录名),文件系统类型,mount选项,是否需要dump(1表示需要,0表示不需要),在reboot期间 fsck检查的顺序(激活文件系统设定为1,其余文件系统设定为2,若设定为0表示该文件系统不需要被检查)。
在linux和windows共存时,也许想开机自动挂载windows分区,那么就可以在这个文件里加上相应的记录。
某些时候对硬盘分区作了调整以后,这里也需要做一些相应的修改。否则会出现一些问题。

可用的mount选项:

async
对该文件系统的所有I/O操作都异步执行
ro
该文件系统是只读的
rw
该文件系统是可读可写的
atime
更新每次存取inode的存取时间
auto
可以使用 -a 选项mount
defaults
使用预设的选项:rw,suid,dev,exec,auto,nouser,async
dev
解释在文件系统上的字符或区块设备
exec
允许执行二进制文件
noatime
不要在这个文件系统上更新存取时间
noauto
这个文件系统不能使用 -a 选项来mount
nodev
不要解释在文件系统上的字符或区块设备
noexec
不允许在mounted文件系统上执行任何的二进制文件。这个选项对于具有包含非它自己的二进制结构的文件系统服务器而言非常有用
nosuid
不允许setuid和setgid位发生作用。(这似乎很安全,但是在安装suidperl后,同样不安全)。
nouser
限制一般非root用户mount文件系统
remount
尝试重新mount已经mounted的文件系统。这通常是用来改变文件系统的mount标志,特别是让只读的文件系统变成可擦写的
suid
允许setuid和setgid位发生作用
sync
文件系统的所有I/O同步执行
user
允许一般非root用户mount文件系统。这个选项会应用noexec,nosuid,nodev这三个选项(除非在命令行上有指定覆盖这些设定的选项)。

3.安全性
/etc/fstab的默认权限是644,所有者和所有组均为root

2.相关命令
mount
df


--  作者:admin
--  发布时间:2005-2-9 18:55:04

--  
/etc/inittab

1.文件格式
init进程将查看此文件来启动子进程,完成系统引导./etc/inittab描述了一个进程是在系统引导时起动还是在系统引导完成后的某个情形下起动.他也是由一行行的记录组成的.而以 # 开头的行是注释,将被忽略.
记录的格式是:
id:runlevels:action:process

id 域是一个由1到4个字符组成的字符串,这个字符串必需是唯一的,即不能有两条记录拥有相同的id域.id域是一个标志域,由它区分各条记录.注意,对于 gettys或咂渌膌ogin进程来说,id域必须是对应tty的tty后缀,例如,对于tty1来说,id域应该是1.查看你的 /etc/inittab,会发现类似下面这样的记录:
.........
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
.............

runlevels域是一个运行级的列表,可用的运行级有:
0 ---- 停机
1 ---- 单用户模式
2 ---- 不带NFS的多用户模式
3 ---- 完整的多用户模式
4 ---- 没有使用
5 ---- X11
6 ---- 重起系统
S ---- 单用户
s ---- 同S

action域是一个预定义的动作,可用的action有:
respawn
进程终止后立刻重新开始(如getty进程)
wait
进程在进入指定的运行级后起动一次,然后init将等待它的终止
once
进程在进入指定的运行级后起动一次
boot
进程在系统引导时起动,runlevels域将被忽略
bootwait
进程在系统引导时起动,然后init将等待它的终止,runlevels域将被忽略
off
这个action不做任何事
ondemand
有一个特殊的运行级叫做ondemand runlevel,包括a,b和c.如果一个进程被标记了ondemand runlevel,那么当要求切换到这个ondemand runlevel时将会起动这个进程.但实际上的runlevel不会改变
initdefault
标记了initdefault这个action的记录项的runlevel域指定了系统引导完成后进入的运行级
sysinit
在系统引导时起动这个进程.而且在所有的boot和bootwait项之前起动.process域将被忽略
powerwait
在电力中断时起动这个进程.通常会由一个与连接到计算机的UPS系统对话的进程通知init电力切断.init在继续之前将等待这个进程结束
powerfail
同powerwait类似,但是init不会等待这个进程结束
powerokwait
一旦init被通知电力已经恢复,将起动这个进程
powerfailnow
当init被告知UPS的电力亦将耗尽时起动这个进程
ctrlaltdel
当init接到SIGINT信号时起动这个进程.一般是按下了ctrl+alt+del这个组合键
kbrequest
当一个特殊的键盘组合键被按下时起动这个进程

process域指定了将运行的进程,可以有参数.如果这个域以 + 开头,表明init将为这个进程更新utmp/wtmp记录.

范例:
id:3:initdefault:
系统引导完成后进入运行级3
si::sysinit:/etc/rc.d/rc.sysinit
系统引导时运行/etc/rc.d/rc.sysinit
l0:0:wait:/etc/rc.d/rc 0
系统进入运行级0时执行/etc/rc.d/rc 0,这里 0 是参数
ca::ctrlaltdel:/sbin/shutdown -t3 -r now
捕获到ctrl+alt+del时运行/sbin/shutdown -t3 -r now.如果想禁用ctrl+alt+del这个组合键,直接删除或注释掉这行
pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down"
电力中断时执行/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down"
1:2345:respawn:/sbin/mingetty tty1
进入运行级2,3,4或5时执行respawn:/sbin/mingetty tty1.注意指定的action是respawn,这也就是为什么我们在终端下logout后会立刻又出现一个login提示符
x:5:respawn:/etc/X11/prefdm -nodaemon
进入运行级5时执行/etc/X11/prefdm -nodaemon,指定的action是respawm

2.安全性
/etc/inittab的权限是644,所有者和所有组均为root

3.相关命令
init
telinit

更多内容请
man init
man inittab


--  作者:admin
--  发布时间:2005-2-9 18:55:37

--  
wu-ftp的配置

1. 查看、修改/etc/inetd.conf文件
/etc/inetd.conf 档是LINUX系统的超级伺服器inetd的配置档。它负责监听多个TCP/IP埠。当它收到请求,就根据配置档派生一个相应的伺服器。通过使用超级伺服 器,其他服务就可以只在需要时才派生,从而大大节省了系统资源。而wu-ftp就是利用超极伺服器inetd来监听请求的。当超级伺服器inetd收到了 用户端的FTP请求时,就根据配置档打开一个FTP服务进程。所以我们如果要使用wu-ftp,就必须确认在超级伺服器inetd的配置档 inetd.conf中有这样一句:
ftp stream tcp nowait root /usr/sbin/tcpd wu.ftpd
以便当超级伺服器收到FTP请求的时候,能够派生一个wu-ftp的FTP服务进程。(注:要确认是否有这样一行时,可以使用档内容查找命令来确认:
cat /etc/inetd.conf | grep ftp
如果没有,则用手工加入或手工修改。
2. wu-ftpd的命令选项
wu-ftpd就是wu-ftp的服务进程。它可以不带参数执行,也可以带参数执行。下面简单介绍一下wu-ftpd的执行参数。
-d 当FTP伺服器出错时,将错误入系统的syslog中;
-l 将每次FTP用户端进行连接的入系统的syslog中;
-t 设置FTP用户端连接几分钟无操作就切断连接;
-a 使wu-ftp使用/etc/ftpaccess的设定;
-A 使wu-ftp不使用/etc/ftpaccess的设定;
-L 将FTP用户端连线后所执行的程式记录在系统的syslog中;
-I 将FTP用户端上载档的日志记录在/usr/adm.xferlog文件中;
-o 将FTP用户端下载档的日志记录在/usr/adm/xferlog档中。
通过对以上参数的理解,我们建议,将上面系统安装时的那条默认配置改为:
ftp stream tcp nowait root /usr/sbin/tcpd wu.ftpd -a -I
3.提供自动压缩、解压缩的功能
如果想让FTP伺服器有自动压缩、解压缩的功能,必须先将一些压缩、解压缩的命令档如tar、gzip、gunzip、compress、uncompress等命令档拷贝到/home/ftpd/bin目录下。
4. 关于/etc/ftpaccess的设置
这个配置档是FTP伺服器上最重要的配置档,它直接关系到你的FTP伺服器能否正常工作,还有许多许可权上的设置。下面是一个典型的配置实例。
loginfails 3
class local real *
class remote anonymous guest *
limit remote 100 Any /etc/ftpd/toomany.msg
message /etc/ftpd/welcome.msg login
compress yes local remote
tar yes local remote
private yes
passwd-check rfc822 warn
log commands real
log transfer anonymous guest inbound outbound
log transfer real inbound
shutdown /etc/ftpd/shut.msg
delete no anonymous,guest
overwrite no anonymous,guest
rename no anonymous
chmod no anonymous,guest
umask no anonymous
upload /home/ftpd * no
upload /home/ftpd /bin no
upload /home/ftpd /etc no
upload /home/ftpd /pub yes real 0644 dirs
upload /home/ftpd /incoming yes real guest anonymous 0644 dirs
alias in /incoming
email guest@xxx.net
email guest@yyy.net
deny *.com.tw /etc/ftpd/deny.msg
下面我们逐句进行讲解,并给出每条设置的含义,以便大家触类旁通,以便根据自己FTP伺服器的具体情况进行合理的设置。
1. 格式:loginfails [次数]
功能:设定当用户登录到FTP伺服器时,允许用户输错密码的次数。
实例:loginfails 3:密码输入错误三次就切断连接。
2. 格式:class [类名] [real/guest/anonymous] [IP地址]
功能:这个指令的功能设定FTP伺服器上用户的类别。并可对用户端的IP位址进行限制,允许某部分的IP位址或全部的IP位址访问。而在FTP伺服器上的用户基本上可以分为以下三类:
real 在该FTP伺服器有合法帐号的用户;
guest 有记录的匿名用户;
anonymous 许可权最低的匿名用户
实例:class local real *:定义一个名为local的类,它包含了在任何地方登录(*代表所有IP地址)的real用户。
class remote anonymous guest *:定义一个名为remote的类,它包含了在任何地方登录的anonymous用户和guest用户。
3. 格式:limit [类别] [人数] [时间] [档案名]
功能:这个指令的功能为设置指定的时间内指定的类别允许连接的指定人数上限。当达到人数上限的时候,显示指定档的内容。
实 例:limit remote 100 Any /etc/ftpd/toomany.msg:在任何时间内,remote类的访问用户达到100人时,将不再允许无法产生新的连接,当第101位客户要 连接时,连接将失败,并象用户出示档/etc/ftpd/toomany.msg的内容。
4. 格式:message [档案名称] [指令]
功能:当用户执行所指定的指令时,系统将指定的档内容显示出来。
实例:message /etc/ftpd/welcome.msg login:当用户执行login命令时,也就是登录到FTP伺服器上的时候,系统将显示档/etc/ftpd/welcome.msg的内容。
5. 格式:compress [yes/no] [类别]
功能:设置哪一个类别的用户可以使用compress(压缩)功能。
实例:compress yes local remote:允许local和remote两个类别的用户都能使用 compress(压缩)功能。
6. 格式:tar [yes/no] [类别]
功能:设置哪一个类别的用户可以使用tar(归档)功能。
实例:tar yes local remote:允许local和remote两类的用户都能使用tar功能。
7. 格式:private [yes/no]
功能:设定是否支援群组对档的取用。
实例:private yes:支援群组对档的取用。
8. 格式:passwd-check [none/trivial/rfc822] [enforce/warn]
功能:设定对匿名用户anonymous的密码使用方式。
none 表示不做密码验证,任何密码都可以登录;
trival 表示只要输入的密码中含有字元“@”就可以登录;
rfc822 表示密码一定要符合RFC822中所规定的E-Mail格式才能登录;
enfore 表示输入的密码不符合以上指定的格式就不让登录;
warn 表示密码不符合规定时只出现警告资讯,仍然能够登录。
实例:passwd-check rfc822 warn:希望能够得到符合规定的E-Mail作为密码,但如果不是,也允许登录。
9. 格式:log command [real/guest/anonymous]
功能:设置哪些用户登录后的操作记录在档/usr/adm/xferlog中。
实例:log command real:当real用户登录后,将他的操作记录下来。由于其他用户许可权较低,所以操作不会引起太大的安全隐患,所以一般只需记下real用户的操作就可以了。
10. 格式:log transfers [real/guest/anonymous] [inbound/outbound]
功能:设置哪些用户的上载(inbound)和下载(outbound)操作做日志。
实例:log transfer anonymous guest inbound outbound:对于匿名用户要更加的关注它们的档操作,所以无论上载、下载都进行记录。
log transfer real inbound:对于合法用户则只记录他的上载记录。
11. 格式:shutdown [档案名]
功能:FTP伺服器关闭的时间可以设置在后面所指定的档中,当设置的时间一到,便无法登录FTP伺服器了,要恢复的话只有将这个档删掉。而这个档必 须由指令/bin/ftpshut来生成。
实例:shutdown /etc/ftpd/shut.msg
12. 格式:delete [yes/no] [real/anonymous/guest]
功能:设置是否允许指定用户使用delete命令删除档。默认是允许。
实例:delete no anonymous,guest:为了更好地管理FTP伺服器,一般情况下,我们不允许匿名用户执行delete命令。
13. 格式:overwrite [yes/no] [real/anonymous/guest]
功能:设置是否允许指定用户覆盖同名档。默认是允许。
实例:overwrite no anonymous,guest:为了更好地管理FTP伺服器,一般情况下,我们不允许匿名用户覆盖同名档。
14. 格式:rename [yes/no] [real/anonymous/guest]
功能:设置是否允许指定用户使用rename命令来为档改名。默认是允许。
实例:delete no anonymous:为了更好地管理FTP伺服器,一般情况下,我们不允许匿名用户执行rename命令改变档案名。而对有记录的匿名用户则适当的放宽,允许他们使用改名命令。
15. 格式:chmod [yes/no] [real/anonymous/guest]
功能:设置是否允许指定用户使用chmod命令更改档许可权。默认是允许。
实例:delete no anonymous,guest:为了更好地管理FTP伺服器,一般情况下,我们不允许匿名用户执行chmod命令更改档许可权。
16. 格式:umask [yes/no] [real/anonymous/guest]
功能:设置是否允许指定用户使用umask命令。默认是允许。
实例:delete no anonymous:为了更好地管理FTP伺服器,一般情况下,我们不允许匿名用户执行umask命令。
17. 格式:upload [根目录] [上载目录] [yes/no] [用户] [许可权] [dirs/nodirs]
功能:对可以上载的目录进行更加详细的设置。
实例:upload /home/ftpd * no:表示在子目录/home/ftpd下不允许上载;
upload /home/ftpd /bin no:表示在子目录/home/ftpd/bin下不允许上载;
upload /home/ftpd /etc no:表示在子目录/home/ftpd/etc下不允许上载;
upload /home/ftpd /pub yes real 0644 dirs:允许用伺服器上的合法用户在子目录/home/ftpd/pub目录下能上载许可权为0644(也就是-rw-r--r--)的档,而且在这个目录下可以新建子目录。
upload /home/ftpd /incoming yes real guest anonymous 0644 dirs:允许所有的用户在子目录/home/ftpd/incoming下能上载许可权为0644的档,而且在这个目录下可以新建子目录。
18. 格式:alias [目录别名] [目录名]
功能:给指定目录设置一个别名,在切换目录时就可以使用较短的目录别名。
实例:alias inc: /incoming:为子目录incoming设置一个别名inc:。
19. 格式:email [guest的E-Mail地址]
功能:只要将某些E-Mail位址设置在这个地方,那么这些用户登录到FTP伺服器时,他的身份将为guest,一般许可权比real低一些,比anonymous高。
实例:email guest@xxx.net email guest@yyy.net:这里仅是一个示例,实际上可 以包含多个符合规范的E-Mail位址。
20. 格式:deny [IP地址/功能变数名称] [说明文件]
功能:这个设置可以限制哪一些IP位址或功能变数名称的用户无法登入FTP伺服器。
实例:deny *.com.tw /etc/ftpd/deny.msg:设置凡是功能变数名称是以“.com.tw”结束的功能变数名称,都禁止其访问。而将/etc/ftpd/deny.msg的内容显示给用户看。
5. 设置/etc/ftpuser,禁止某些用户登录
有 时我们需要禁止一些用户使用FTP服务。其实这个设置是十分简单的,只需要将要禁止的用户帐号写入档/etc/ftpuser中。由于从系统的安全考虑, 一般我们是不希望许可权过大的用户和一些与命令名相同的用户进入FTP伺服器。所以在缺省的配置中,一般以下用户已经被列入了“黑名单”。
root
uucp
news
bin
adm
nobody
lp
sync
shutdown
halt
mail
6. 设置/etc/ftphosts,禁止某些来自指定机器上的登录如果你需要拒绝来自某些主机的登录,一种方法就是在/etc/ftpaccess中设置 deny命令,另一种更加简单的方法就是在/etc/ftphosts中写入你要禁止的主机的IP位址或功能变数名称。
7. 使新的配置生效
到此为止,我们已经能够根据自己的需要对FTP伺服器配置进行必要的修改和调整。而让我们重新配置后,就必须使其生效。一般的,对/etc/ftpaccess的配置是直接作用于设置后的下一次FTP服务进程。而其他的则要对inetd进程重新启动。
三:wu-ftp相关的其他一些命令的使用
1 连接数统计命令ftpcount
我们可以使用ftpcount命令十分清楚地统计出当前连接到FTP伺服器上的用户数目,并且同时列出上限。命令输出如下所示:
Service class local 0 Users(20maximum)
Service class remote 5 Users(100maximum)
2 线上用户查看命令ftpwho
我们可以使用ftpwho命令十分清楚地列出当前连接的用户的详细情况。
3 FTP关闭文件生成命令ftpshut
我们可以使用ftpshut命令生成一个在/etc/ftpaccess中设置的shut.msg文件,用于关机设定。ftpshut命令的格式为:
Ftpshut <-l min> <-d min> time <说明>
-l 这个参数设定在关闭FTP伺服器功能前多少分钟时停止用户的连接;
-d 这个参数设定在关闭FTP伺服器功能前多少分钟时切断用户连接;
time 指定关闭FTP伺服器的时间。例如6:20分则写为0620;


--  作者:admin
--  发布时间:2005-2-9 18:56:09

--  
hosts的配置

hosts的配置

用途:用于主机名查询的静态表

所在路径:/etc/hosts

格式说明:分为三个域:
IP地址 标准主机名 主机别名
主机名可以由字母数字、减号、小数点组成。
标准主机名一般只有唯一一个主机名,但是主机别名可以是一个列表

代码:
例子:
        127.0.0.1       myhome.com           localhost.localdomain  localhost
        192.167.0.10    foo.mydomain.org     foo
        192.167.0.13    bar.mydomain.org     bar
        216.234.231.5   master.debian.org    master
        205.230.163.103www.opensource.org

权限为-rw-r--r-- root root

实际应用举例:
在系统安装完成以后,我们可以用hostname命令来更改主机名,或者修改/etc/sysconf/network文件。但有时登陆gnome时,提示找不到自己命名的主机,但仍然可以登陆。这时我们只需查看一下/etc/hosts文件把它改一改就可以了。
以上只是hosts的一个应用,就是在系统没有运行DNS服务时(如启动时),设置本地网络。
还有比较重要的应用,例如作为NIS的主机名数据库,连接一些无法用DNS服务找到的站点等等。

/etc/shadow

1.文件格式
/etc/shadow文件保存的是用户名,密码,用户账号设置相关信息。
例:
root:$1$6UviCNvh$WTR0zPMek41KmzD0Z1DdV1:12264:3:4:5:6:12267:
第一段: root----- 用户注册名
第二段: $1$6UviCNvh$WTR0zPMek41KmzD0Z1DdV1 ----加密口令
第三段: 12264-----上次更动密码的日期,以1970年1月1日为1,1天加1
第四段: 3---------密码将被允许修改之前的天数(0 表示“可在任何时间修改”)
第五段: 4---------系统将强制用户修改为新密码之前的天数(1 表示“永远都不能修改”)
第六段: 5---------密码过期之前,用户将被警告过期的天数(-1 表示“没有警告”)
第七段: 6---------密码过期之后,系统自动禁用帐户的天数(-1 表示“永远不会禁用”)
第八段: 12267-----该帐户被禁用的天数(-1 表示“该帐户被启用”).以1970年1月1日为1,1月2日为2
第九段 ------ 保留供将来使用
注:第2段中为*表示帐号不可登录,如密码前为 !! 或只有 !! 表示帐号被锁

2.安全性
/etc/shadow的默认所有者和所有组均为root.
建议运行# chattr +i /etc/shadow来保护文件使其不被意外地删除或重写

3.相关命令

passwd
useradd
userdel
usermod

/ect/gshadow

1.文件格式

/ect/gshadow文件保存的是用户和组群设置的信息
例:
root:!!::root,wa1
第一段:组名
第四段:该组包含用户列表

2.安全性
/etc/gshadow的默认所有者和所有组均为root.
建议运行# chattr +i /etc/shadow来保护文件使其不被意外地删除或重写

3.相关命令
groupadd
groupdel
groupmod
groups


--  作者:admin
--  发布时间:2005-2-9 18:56:33

--  
/etc/syslog.conf

1.文件格式
/etc/syslog.conf 是syslog守护程序的配置文件.syslog守护程序为记录来自运行于系统之上的程序的消息提供了一种成熟的客户机-服务器机制。syslog 接收来自守护程序或程序的消息,根据优先级和类型将该消息分类,然后根据由管理员可配置的规则将它写入日志。结果是一个健壮而统一的管理日志的方法。

这个文件由一条条的规则组成.每条规则应该写在一行内.但是如果某行以反斜线 \\ 结尾的话,他的下个物理行将被认为与此行同属于一行.空白行和以 # 开始的行将被忽略.
每条规则都是下面这种形式:

facility.priority[;facility.priority .....] action

facility和priority之间用一个英文句点分隔.他们的整体称为selector. 每条规则可以有多个selector,selector之间用分号隔开. 而selector和action之间则用空格或者tab隔开.

facility 指定 syslog 功能,主要包括以下这些:

auth 由 pam_pwdb 报告的认证活动。
authpriv 包括特权信息如用户名在内的认证活动
cron 与 cron 和 at 有关的信息。
daemon 与 inetd 守护进程有关的信息。
kern 内核信息,首先通过 klogd 传递。
lpr 与打印服务有关的信息。
mail 与电子邮件有关的信息
mark syslog 内部功能用于生成时间戳
news 来自新闻服务器的信息
syslog 由 syslog 生成的信息
user 由用户程序生成的信息
uucp 由 uucp 生成的信息
local0----local7 与自定义程序使用,例如使用 local5 做为 ssh 功能
* 通配符代表除了 mark 以外的所有功能

priority 指定消息的优先级. 与每个功能对应的优先级是按一定顺序排列的,emerg 是最高级,其次是 alert,依次类推。缺省时,在 /etc/syslog.conf 记录中指定的级别为该级别和更高级别。如果希望使用确定的级别可以使用两个运算符号!(不等)和=。

user.=info

表示告知 syslog 接受所有在 info 级别上的 user 功能信息。

可用的 syslog 优先级如下:

emerg 或 panic 该系统不可用
alert 需要立即被修改的条件
crit 阻止某些工具或子系统功能实现的错误条件
err 阻止工具或某些子系统部分功能实现的错误条件
warning 预警信息
notice 具有重要性的普通条件
info 提供信息的消息
debug 不包含函数条件或问题的其他信息
none 没有重要级,通常用于排错
* 所有级别,除了none

action字段所表示的活动具有许多灵活性,特别是,可以使用名称管道的作用是可以使 syslogd 生成后处理信息。

syslog 主要支持以下action

file
指定文件的绝对路径,如: /var/log/messages . log信息将写到此文件中
terminal 或 printer
完全的串行或并行设备标志符,如/dev/console . log信息将送到此设备
@host
远程的日志服务器. log信息将送到此日志服务器
username
发送信息给指定用户
named pipe
指定使用 mkfifo 命令来创建的 FIFO 文件的绝对路径。


如果对此文件作了改动, 想要使改动生效,您需要向 syslog 守护程序通知所做的更改。向它发送 SIGHUP 是个正确的办法,您可以用 killall 命令轻松地做到这一点:

# killall -HUP syslogd


2.安全性
您 应该清楚如果 syslogd 写的日志文件还不存在的话,程序将创建它们。无论您当前的 umask 如何设置,该文件将被创建为可被所有用户读取。如果您关心安全性,那么您应该用 chmod 命令将该文件设置为仅 root 用户可读写。此外,可以用适当的许可权配置 logrotate 程序(在下面描述)以创建新的日志文件。syslog 守护程序始终会保留现有日志文件的当前属性,因此一旦创建了文件,您就不需要担心它。


3.相关命令
logrotate
klogd
syslogd
dmesg


  /etc/mtab

1.文件格式
/etc/mtab 的格式和/etc/fstab是一样的.但这个文件不能算是用户配置文件,他是由系统维护的.和/etc/fstab的区别在于,fstab是系统启动时 需挂载的文件系统列表,而mtab是系统当前已挂载的文件系统列表,它由系统维护,在用户执行了mount或者umount命令后自动更新.用户不应该对 此文件作任何修改.

2.安全性
/etc/mtab的默认权限仍然是644

3.相关命令
mount
umount
smbmount


--  作者:admin
--  发布时间:2005-2-9 18:58:39

--  
etc/crontab

1.文件格式
crontab文件是cron程序的驱动文件.每个用户都可以有自己的crontab文件,而/etc/crontab是系统crontab文件.文件中的空行将被忽略,以 # 开头的行被认作注释.

crontab文件中的项可分为两类:环境变量设置项和cron驱动项.

环境变量设置项的格式为:
name = velue
等号两边的空格是可选的.
下列环境变量会被cron程序预设:
SHELL被设置为/bin/sh.
LOGNAME和HOME会从/etc/passwod文件中crontab文件属主对应记录中读取.
SHELL和HOME可以在crontab文件中重新设置.但LOGNAME不行.
除 了上述3个环境变量外,如果由于某种原因cron需要发送电子邮件的话,cron还将查找MAILTO这个变量.如果MAILTO已经被定义且非空,那么 cron将把邮件发给MAILTO所指定的用户.如果MAILTO被定义但是为空的话,cron将不发送邮件.如果MAILTO未被定义,则cron将把 邮件发送给root.

cron驱动项大致可分为3个字段:
date usr command
意思是,将在date这个时间以usr的身分执行命令command.
对用户crontab文件(非系统crontab文件/etc/crontab)来说,usr即为crontab文件的属主.故没有usr这个字段.
每一项都以新行符或 % 结束.想在驱动项中使用 % 的话必须转义,即在 % 前加反斜线 \\ .如果驱动项以 % 结束,那么这一行中 % 以后的部分将作为command的标准输入.
date字段又可分为5部分,以空格分开.它们依次为:
minute : 为数字,0到59
hour : 为数字,0到23
day of month : 为数字,1到31
month : 数字1到12或月份的缩写(取英文的前3个字母,大小写无关)
day of week : 数字0到7或星期的缩写(取英文的前3个字母,大小写无关)
可以使用通配符 * .
如果使用数字来表示的话,可以指定一个列表或者范围,或者两者的组合.如:
列表: 1,2,6,7
范围: 1-5
组合: 1-3,6-24
对范围还可以指定步进值.例如:
2-15/2
表示2,4,6,8,10,12,14
2-15/3
表示2,4,7,10,13
通配符可以和步进值混和使用:
*/6
对month和day of week这两个字段来说,如果用的是缩写表示,那么不可以使用列表和范围.

注意: 只要day of month和day of week中的任一字段匹配,command就会在指定的hour和minute执行.

2.安全性
/etc/crontab的默认权限为644

3.See also
cron(8)
crontab(1)
crontab(5)


/etc/at.allow和/etc/at.deny

1.文件格式
这两个文件的内容决定了哪些用户可以使用at和batch命令来配置计划任务.
他们的内容是一个用户名的列表.每行一个用户名
系统首先会检查/etc/at.allow是否存在.若存在,那么只有在他里面列出的用户才可以使用at.如果不存在,系统才会去检查/etc/at.deny.所有列在/etc/at.deny中的用户将不能使用at命令.
注意:root不受此限止.他总是能使用at.

2.安全性
他们的权限均为600,所有者和所有组均为root

3.See also
at(1), atrun(1), cron(8), crontab(1), atd(8).



--  作者:admin
--  发布时间:2005-2-9 18:59:02

--  
/etc/sysctl.conf

1.文件格式
/etc/sysctl.conf是sysctl程序的配置文件.sysctl可以在系统运行时更改内核参数./etc/sysctl.conf中的配置将在系统起动时执行.
以 # 和 ; 开始的行是注释,将和空白行一起被忽略.
配置项的格式为:
token = value
token是一个键名,value是对应的键值.token和value前后的空格将被忽略
token不能是随意的字符串.他和/proc/sys下的文件有一一对应的关系:
假设foo是/proc/sys下的一个文件.删除foo的绝对路径前的 "/proc/sys" 这一部分,然后把剩下部分中的 "/" 替换成 ".",得到的字符串就是foo所对应的键名.例如:
/proc/sys/net/ipv4/ip_forward对应的键名为net.ipv4.ip_forward

应用举例:
Redhat Linux 9默认是禁止ip转发的,而我们在做ip伪装时需要起用ip转发.通常的做法是在iptables的规则之前加上一句:
echo 1>/proc/sys/net/ipv4/ip_forward
实际上我们也可以在/etc/sysctl.conf中写上:
net.ipv4.ip_forward = 1
这样系统就默认起用ip转发了.当然他不会立即生效.因为/etc/sysctl.conf是在系统起动时读入的.想要立即生效的话,请使用sysctl命令.

2.安全性
/etc/sysctl.conf的默认权限是644,所有者和所有组均为root

3.See also
sysctl(8)
sysctl.conf(5)
proc(5)
procinfo(8)


  /etc/nologin

1.文件格式
这是一个普通的文本文件.你可以在里面写上你喜欢的任何东西./etc/nologin的作用在于,如果它存在,那么系统将拒绝任何非root用户的登录请求,并打印/etc/nologin的内容
此文件常由系统在停机前自动生成.有时系统管理员也会手工生成它,用以禁止其它用户登录,方便进行一些管理工作.

2.安全性
...........

3.See also
login(1)
nologin(8)


--  作者:admin
--  发布时间:2005-2-9 18:59:51

--  
/etc/securetty

1.文件格式
这是一个设备文件的列表.文件名取相对于/dev的相对路径.如,/dev/tty1记为tty1
root只有从这个列表中列出的设备上才可以登录系统.
例如:
代码:$cat /etc/securretty
tty1
tty2
tty3
这里root被限定只能从/dev/tty1, /dev/tty2, /dev/tty3这三个设备上登录系统

如果/etc/securretty不存在的话,那么root将可以从任何设备登录系统.

2.安全性
/etc/securetty的默认权限是600,所有者和所有组都是root

3.See also
securetty(5)
login(1)

ect/httpd/conf/httpd.conf (1)

## httpd.conf - configuration for the Apache web server
#
# Generated automatically... if you edit manually, the changes will be lost
# the next time you run "apacheconfig".
#

### 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.
#

#
# Don\'t give away too much information about all the subcomponents
# we are running. Comment out this line if you don\'t mind remote sites
# finding out what major optional modules you are running



ServerTokens OS

客户端连接到Apache服务器的时候,Apache一般会返回服务器版本、非缺省模块等信息,
ServerTokens Prod
返回:Server: Apache
ServerTokens Min
返回:Server: Apache/1.3.0
ServerTokens OS (默认)
返回:Server: Apache/1.3.0 (Unix)
ServerTokens Full(或者不指定)
返回:Server: Apache/1.3.0 (Unix) PHP/3.0 MyMod/1.2


#
# ServerRoot: The top of the directory tree under which the server\'s
# 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:" target=_blank );>http://httpd.apache.org/docs-2.0/mod/core.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"

ServerRoot用于指定守护进程httpd的运行目录.

#
# ScoreBoardFile: File used to store internal server process information.
# If unspecified (the default), the scoreboard will be stored in an
# anonymous shared memory segment, and will be unavailable to third-party
# applications.
# If specified, ensure that no two invocations of Apache share the same
# scoreboard file. The scoreboard file MUST BE STORED ON A LOCAL DISK.
#
#ScoreBoardFile run/httpd.scoreboard

#
# PidFile: The file in which the server should record its process
# identification number when it starts.
#


PidFile "/var/run/httpd.pid"
PidFile指定的文件将记录httpd守护进程的进程号,由于httpd能自动复制其自身,因此系统中有多
个httpd进程,但只有一个进程为最初启动的进程,它为其他进程的父进程,对这个进程发送信号将
影响所有的httpd进程。PidFILE定义的文件中就记录httpd父进程的进程号。


#
# Timeout: The number of seconds before receives and sends time out.
#


TimeOut 300

Timeout定义客户程序和服务器连接的超时间隔,超过这个时间间隔(秒)后服务器将断开与客户
机的连接。

#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#



KeepAlive true
KeepAlive参数用于支持一次连接、多次传输功能,这样就可以在一次连接中传递多个HTTP请求.

#
# 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为一次连接可以进行的HTTP请求的最大请求次数。将其值设为0将支持在一
次连接内进行无限次的传输请求

#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#


KeepAliveTimeout 15

KeepAliveTimeout测试一次连接中的多次请求传输之间的时间,如果服务器已经完成了一次请求,
但一直没有接收到客户程序的下一次请求,在间隔超过了这个参数设置的值之后,服务器就断开连接。

##
## Server-Pool Size Regulation (MPM specific)
##

# 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
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule prefork.c>
StartServers 8 最初建立StartServers子进程数
MinSpareServers 5 设置了最小空闲进程数.
MaxSpareServers 20 设置了最大的空闲进程数. 如果空闲进程数大于这个值,Apache会自
动kill某些多余进程。
MaxClients 150 Apache可以同时处理的请求的个数.
MaxRequestsPerChild 0 每个子进程可以处理的请求数.0为无限
</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>

# perchild MPM
# NumServers: constant number of server processes
# StartThreads: initial number of worker threads in each server process
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# MaxThreadsPerChild: maximum number of worker threads in each server process
# MaxRequestsPerChild: maximum number of connections per server process
<IfModule perchild.c>
NumServers 5
StartThreads 5
MinSpareThreads 5
MaxSpareThreads 10
MaxThreadsPerChild 20
MaxRequestsPerChild 0
</IfModule>

三个模组采用了不同的内存管理方式,其中 perchild 使用线程来提供服务,prefork 使用子程序来提供服务
而 worker 则兼用两种方法,它们的差异在于,线程可共用内存,并使用内存与其他线程沟通;子程序则独立使
用内存,前者性能高,后者比较安全稳定.

小 型网站使用 perchild,它会同时启动5个 Server,每个 Server 最多执行 10 个线程,因此可同时应付50条连线,假设有开启 KeepAlive 功能,则最多可同时服务 5000 个要求,预设的 prefork 是提供給中量级网站使用,最多可同时接受 3000 条连线,服务 30000 个要求,重量级网站则使用 worker,最多可同时接受 22500 条连线,可服务 200000 个要求。



#
# 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 192.168.0.1:80
监听HTTP请求的端口号,*表示所有地址.

#
# Load config files from the config directory "/etc/httpd/conf.d".
#
Include conf.d/*.conf
加载来自于配置目录的配置文件

#
# 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
#

加载HTTP模块
LoadModule access_module modules/mod_access.so
..........(略)

模块功能

mod_access 提供基于主机的访问控制命令
mod_actions 能够运行基于MIME类型的CGI脚本或HTTP请求方法
mod_alias 能执行URL重定向服务
mod_asis 使文档能在没有HTTP头标的情况下被发送到客户端
mod_auth 支持使用存储在文本文件中的用户名、口令实现认证
mod_auth_dbm 支持使用DBM文件存储基本HTTP认证
mod_auth_mysql 支持使用MySQL数据库实现基本HTTP认证
mod_auth_anon 允许以匿名方式访问需要认证的区域
mod_auth_external 支持使用第三方认证
mod_autoindex 当缺少索引文件时,自动生成动态目录列表
mod_cern_meta 提供对元信息的支持
mod_cgi 支持CGI
mod_dir 能够重定向任何对不包括尾部斜杠字符命令的请求
mod_env 使你能够将环境变量传递给CGI或SSI脚本
mod_expires 让你确定Apache在服务器响应请求时如何处理Expires
mod_headers 能够操作HTTP应答头标
mod_imap 提供图形映射支持
mod_include 使支持SSI
mod_info 对服务器配置提供了全面的描述
mod_log_agent 允许在单独的日志文件中存储用户代理的信息
mod_log_config 支持记录日志
mod_log_referer 提供了将请求中的Referer头标写入日志的功能
mod_mime 用来向客户端提供有关文档的元信息
mod_negotiation 提供了对内容协商的支持
mod_setenvif 使你能够创建定制环境变量
mod_speling 使你能够处理含有拼写错误或大小写错误的URL请求
mod_status 允许管理员通过WEB管理Apache
mod_unique_id 为每个请求提供在非常特殊的条件下保证是唯一的标识

ect/httpd/conf/httpd.conf (2)

#
# 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
Apache服务器可以通过特殊的HTTP请求,来报告自身的运行状态,打开这个
ExtendedStatus 参数可以让服务器报告更全面的运行状态信息。


### 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 aren\'t 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.
#

#
# 是分配给httpd的新用户的文件权限,出于安全的考虑把
# 它们的权限设置成为最低
#
User apache
Group apache
User和Group配置是Apache的安全保证,Apache在打开端口之后,就将其本身设置为这两个选项设置的用户和组权限进行运行,这样就降低了服务器的危险性。

#
# 设置Web管理员的邮件地址
#
ServerAdmin www.com">www@www.com

这 一项用于配置WWW服务器的管理员的email地址,这将在HTTP服务出现错误的条件下返回给浏览器,以便让Web使用者和管理员联系,报告错误。习惯 上使用服务器上的webmaster作为WWW服务器的管理员,通过邮件服务器的别名机制,将发送到webmaster 的电子邮件发送给真正的Web管理员

#
# 定义客户端从服务器读取数据时返回给客户端的主机名,其缺省值
# 是localhost,第一次安装Linux的时候经常这里出错。
#
#ServerName new.host.name

#
#
#
UseCanonicalName On
打开这个UseCanonicalName是Web服务器的标准做法,因为客户发送的大部分请求都是对本服务器的引用,这样服务器就能使用ServerName和Port选项的设置内容构建完整的URL,并回应客户,使浏览器能得到规范的URL

#
#
#
DocumentRoot "/var/www/html"
 DocumentRoot定义这个服务器对外发布的超文本文档存放的路径

#
# First, we configure the "default" to be a very restrictive set of
# features.
## 设置/目录的指令。具体说明如下:
#   Option:定义在目录内所能执行的操作。
#       None表示只能浏览.
#       FollowSymLinks允许页面连接到别处,
#       ExecCGI允许执行CGI,
#       MultiViews允许看动画或是听音乐之类的操作,
#       Indexes允许服务器返回目录的格式化列表,
#       Includes允许使用SSI。
#   这些设置可以复选。All则可以做任何事,但不包括MultiViews。
# AllowOverride:
#       加None参数表示任何人都可以浏览该目录下的文件,但不会读取该文件。
#       FileInfo 允许控制文件型态之指令的使用,
#       AuthConfig 允许验认指令的使用,
#       Indexes 允许控制目录索引之指令的使用,
#       Limit 允许控制存取主机之指令的使用,
#       Options 允许控制特定目录特色之指令的使用.
#       设为 All 的话服务器将会允许所有的指令.
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>

#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something\'s not working as
# you might expect, make sure that you have specifically enabled it
# below.
#

#
# 网站根目录的设置

# Options设置 服务器特性设置
All 所有的目录特性都有效,这是缺省状态
None 所有的目录特性都无效
FollowSymLinks 允许使用符号连接,这将使浏览器有可能访问文档根目录 (DocumentRoot)之
外的文档 SymLinksIfOwnerMatch 只有符号连接的目的与符号连接本身为同一用
户所拥有时,才允许访问,这个设置将增加一些安全性。
ExecCGI 允许这个目录下可以执行CGI程序 Indexes 允许浏览器可以生成这个目录下所有文件的
索引,使得在这个目录下没有index.html(或其他索引文件)时,能向浏览器发送这个目
录下的文件列表。
AllowOverride参数
All 缺省值,使访问控制文件可以覆盖系统配置
None 服务器忽略访问控制文件的设置
Options 允许访问控制文件中可以使用Options参数定义目录的选项
FileInfo 允许访问控制文件中可以使用AddType等参数设置
AuthConfig 允许访问控制文件使用AuthName,AuthType等针对每个用户的认证机制,这使目录属主
能用口令和用户名来保护目录 Limit 允许对访问目录的客户机的IP地址和名字进行限制。
Order定义处理Allow和Deny的顺序,而Allow、Deny则针对名字或IP进行访问控制设置.
allowfrom all,表示允许所有的客户机访问这个目录,而不进行任何限制
<Directory "/var/www/html">
#
Options Indexes All
#
AllowOverride None

#
Order allow,deny
Allow from all

</Directory>

#
# 访问错误提示页面
#
<LocationMatch "^/$>
Options -Indexes
ErrorDocument 403 /error/noindex.html
</LocationMatch>


--  作者:admin
--  发布时间:2005-2-9 19:00:18

--  
httpd.conf (3)

#
# UserDir: The name of the directory that is appended onto a user\'s 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 als 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 user\'s public_html
# directory, remove the "UserDir disable" line above, and uncomment
# the following line instead:
#
#UserDir public_html

</IfModule>
> 指定 user 存放网页的目录名称;需有 mod_userdir 模组支援。如果要该主机中拥有
> 系统帐号及家目录的 user 也能拥有网站功能时,需起用此设定,同时该 user 需于家
> 目录中建立一 www (视设定值) 的子目录,所有的网站內容皆放于 www 目录下;而该
> user 的网站位址为︰
> http://your.domain.here/~username。
> 如︰/home/username/www/index.html => http://your.domain.here/~username/index.html


#
# Control access to UserDir directories. The following is an example
# for a site where these directories are restricted to read-only.
#
> UserDir是一个特殊的选项,用来在用户的宿主目录下设置主页,比
> 如,有一个名字叫wanghy的用户,其宿主目录是/home/*而且UserDir象我们刚才
> 那样设定,那么,你可以在浏览器中输入http://www.mydomain.com/~*将对应
> 的是宿主目录+UserDir,也就是/home/*/ublic_html。当然,为了使这个功能生
> 效,你得将这个目录设置为大家都可以读。
> 下面的行就是对这个功能的限制,注意要使得某人的这个功能生效,必须有这个段落
> ,这个段落里别的东西都是熟知的,唯一新的东西是Limit段,它用来提供存取限制,例
> 如<Limit GET POST>对应的段落设置GET和POST权限,诸如此类。上面的段落表示所有人
> 都可以通过www进行GET和POST,而任何人都不能PUT和DELETE、MOVE等等。

#<Directory /home/*/public_html>
# AllowOverride FileInfo AuthConfig Limit
# Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
#


> Limit
> 对某个路径进行存取限制。


<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


> 指定网站各目录中的预设浏览档案,各设定值以空白来间隔。此设定的做用在于当访客于
> 网址列仅打上网址但未包含任何档名时,Apache 会自动搜寻网址路径目录下是否有此设定
> 中的档案,如果有则送出,如果沒有则会显示错误信息或该目录的档案列表(视该目录的设
> 定值而定)。


#
# AccessFileName: The name of the file to look for in each directory
# for access control information. See also the AllowOverride directive.
#
AccessFileName .htaccess


> 设定各目录存取设定的设置档。此功能需要开放才有作用,当有开放此功能时,可针对任一
> 目录來做额外设定,而这些额外设定是存放于该目录下的 $AccessFileName 中的,一般取名为
> htaccess。

> 要开放此功能,需于如下区段中,加入此设定值 -> AllowOverride All
> 如︰
> <Directory /home/*/$UserDir>
> AllowOverride All
> </Directory>
> 然而 $AccessFileName 的內容属于敏感性质,建议同时加入如下设定以作保护︰
> <Files ~ "^\\.ht">
> Order allow,deny
> Deny from all
> Satisfy All
> </Files>


--  作者:admin
--  发布时间:2005-2-9 19:00:44

--  

#
# TypesConfig describes where the mime.types file (or equivalent) is
# to be found.
#

TypesConfig "/etc/mime.types"

> TypeConfig用于设置保存有不同的MIME类型数据的文件名

#
# 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

> 如果Web服务器不能决定一个文档的缺省类型,这通常表示文档使用了非标准的后缀,那么
> 服务器就使用 DefaultType定义的MIME类型将文档发送给客户浏览器。
#
# 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>

> 指定相应的标志文件magic的位置

#
# 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 it\'d 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

> 通常连接时,服务器仅仅可以得到客户机的IP地址,如果要想获得客户机的主
> 机名,以进行日志记录和提供给 CGI程序使用,就需要使用这个HostnameLoo
> kups 选项,将其设置为On打开DNS反查功能。但是这将使服务器对每次客户请
> 求都进行DNS查询,增加了系统开销,使得反应变慢,因此缺省设置为使用Off
> 关闭此选项。关闭选项之后,服务器就不会获得客户机的主机名,而只能使用
> IP地址来记录客户。#
# 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 host\'s errors will be logged there and not here.
#
ErrorLog "/var/log/httpd/error_log"
> 这里定义了系统日志的形式,对于服务器错误记录, 由ErrorLog、 LogLevel 来
> 定义不同的错误日志文件及其记录内容。
>   对于系统的访问日志,缺省使用CustomLog参数定义日志的位置,缺省使用
> combined 参数指定将所有的访问日志放在一个文件中,然而也可以将不同种类的
> 访问日志放在不同的日志记录文件中,这是通过在 CustomLog中指定不同的记录类
> 型来完成的。common表示普通的对单页面请求访问记录,referer表示每个页面的
> 引用记录,可以看出一个页面中包含的请求数,agent表示对客户机的类型记录,显
> 然可以将现有的combined 定义的设置行注释掉,并使用common、referer和agent
> 作为CustomLog的参数,来为不同种类的日志分别指定日志记录文件。
>   显然,LogFormat是用于定义不同类型的日志进行记录时使用的格式, 这里
> 使用了以%开头的宏定义,以记录不同的内容。
>   如果这些参数指定的文件使用的是相对路径,那么就是相对于ServerRoot的
> 路径。

#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: 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\\"" combined
LogFormat "%h %l %u %t \\"%r\\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent


#
# 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
CustomLog logs/access_log combined

#
# If you would like to have agent and referer logfiles, uncomment the
# following directives.
#
#CustomLog logs/referer_log referer
#CustomLog logs/agent_log agent

#
# If you prefer a single logfile with access, agent, and referer information
# (Combined Logfile Format) you can use the following directive.
#
#CustomLog logs/access_log combined
#
# Optionally add a line containing the server version and virtual host
# name to server-generated pages (error documents, FTP directory listings,
# mod_status and mod_info output etc., but not CGI generated documents).
# Set to "EMail" to also include a mailt link to the ServerAdmin.
# Set to one of: On | Off | EMail
#

ServerSignature on

> 一些情况下,例如当客户请求的网页并不存在时,服务器将产生错误文档,缺省情况
> 下由于打开了 ServerSignature选项,错误文档的最后一行将包含服务器的名字、
> A pache的版本等信息。有的管理员更倾向于不对外显示这些信息,就可以将这个参数
> 设置为Off,或者设置为Email,最后一行将替换为对 ServerAdmin 的Email提示
#
# 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" isn\'t 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/"
> A lias参数用于将URL与服务器文件系统中的真实位置进行直接映射,一般的
> 文档将在DocumentRoot 中进行查询,然而使用Alias定义的路径将直接映射到相
> 应目录下,而不再到DocumentRoot 下面进行查询。因此Alias可以用来映射一些
> 公用文件的路径,例如保存了各种常用图标的icons路径。这样使得除了使用符号
> 连接之外,文档根目录(DocumentRoot)外的目录也可以通过使用了Alias映射,
> 提供给浏览器访问。
>  定义好映射的路径之后,应该需要使用Directory语句设置访问限制。
#

#
# This should be changed to the ServerRoot/manual/. The alias provides
# the manual, even if you choose to move your DocumentRoot. You may comment
# this out if you do not care for the documentation.
#
Alias /manual "/var/www/manual"

<IfModule mod_dav_fs.c>
# Location of the WebDAV lock database.
DAVLockDB /var/lib/dav/lockdb
</IfModule>

#
# 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/"

<IfModule mod_cgid.c>
#
# Additional to mod_cgid.c settings, mod_cgid has Scriptsock <path>
# for setting UNIX socket for communicating with cgid.
#
#Scriptsock logs/cgisock
</IfModule>

>  scriptAlias也是用于URL路径的映射,但与Alias的不同在于,
> scriptAlias 是用于映射CGI程序的路径,这个路径下的文件都被定
> 义为CGI程序,通过执行它们来获得结果,而非由服务器直接返回其
> 内容。缺省情况下CGI程序使用cgi-bin目录作为虚拟路径。
#
# Redirect allows you to tell clients about documents which used to exist in
# your server\'s 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.
#

#
# FancyIndexing is whether you want fancy directory indexing or standard.
# VersionSort is whether files containing version numbers should be
# compared in the natural way, so that `apache-1.3.9.tar\' is placed before
# `apache-1.3.12.tar\'.
#

IndexOptions FancyIndexing VersionSort NameWidth=*

> 可以让服务器产生的目录列表中针对各种不同类型的文档引用各种图标。而哪种
> 文件使用哪种图标,则使用下面的 AddIconByEncoding、AddIconByType以及
> AddIcon来定义,分别依据MIME的编码、类型以及文件的后缀来判断使用何种图
> 标。如果不能确定文档使用的图标,就使用 DefaultIcon定义的缺省图标。文件
> 名长度是*(自动适应当前目录下最长文件名)

#
# 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

> 用于告诉一些使用压缩的MIME类型,这样可以让浏览器进行解压缩。

AddIconByType (TXT,/icons/text.gif) text/*
AddIconByType (IMG,/icons/image2.gif) image/*
AddIconByType (SND,/icons/sound2.gif) audio/*
AddIconByType (VID,/icons/movie.gif) video/*

> 按类型增加图标,告诉服务器根据MIME类型决定哪种文件使用哪种图标。

AddIcon /icons/binary.gif .bin .exe
AddIcon /icons/binhex.gif .hqx
AddIcon /icons/tar.gif .tar
..............(略)

> 增加图标,告诉服务器使用那个图标表示文件和目录.

#
# DefaultIcon is which icon to show for files which do not have an icon
# explicitly set.
#

DefaultIcon /icons/unknown.gif

> 用于没有明确定义图标的文件的图标的URL。

#
# 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

#
# 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

> HeaderName允许您把文本添加到目录索引清单的顶部。由于它把类
> 似于Unix界面的目录索引能力转换为一种动态文档界面,所以这种
> 能力是非常有用的。
> 当创建目录索引时,Apache将在目录中寻找HEADER.html.如果找到
> 了,就将该文件的内容送到目录的顶部.如果没,,Apache将寻找文件
> HEADER。如果找到HEADER,那么将假设该文件为纯文本文件,并
> 做一些诸如把《字符转换为<;字符序列,再把它插到目录索引的顶
> 部。
> 对于README文件处理的过程是一样的,所不同的只是将结果文件
> 放到目录索引的底部。
#
# 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

> 用来设置目录列表中应该被忽略不显示的文件。 这一行看上去很像密码,但
> 它基本上是用空格分开的样式列表。第一个样式匹配任何以"."开头且字符数
> 大于3的文件。这样对于上层,目录".."的链接仍然有效。第二个样式(*~)
> 和第三个样式(*#)通常用来匹配老式的emacs备份文件。再接下来是避免列
> 出用于HeaderName和ReadmeName的相同的文件。因为很多网站使用RCS,RCS
> 用于修订控制维护的软件包,它把额外的信息储存在RCS目录中。最后给出的
> 样式是为了避免列出RCS目录。


--  作者:admin
--  发布时间:2005-2-9 19:01:07

--  
ect/httpd/conf/httpd.conf (完)

#
AddEncoding x-compress Z
AddEncoding x-gzip gz tgz

> AddEncoding用于告诉一些使用压缩的MIME类型,这样可以让浏览器进行解压缩操作。

#
# DefaultLanguage and AddLanguage allows you to specify the language of
# a document. You can then use content negotiation to give a browser a
# file in a language the user can understand.
#
# Specify a default language. This means that all data
# going out without a specific language tag (see below) will
# be marked with this one. You probably do NOT want to set
# this unless you are sure it is correct for all cases.
#
# * It is generally better to not mark a page as
# * being a certain language than marking it with the wrong
# * language!
#
# DefaultLanguage nl

> 需要现实中文时将此处改为(1)DefaultLanguage zh-cn

#
# Note 1: The suffix does not have to be the same as the language
# keyword --- those with documents in Polish (whose net-standard
# language code is pl) may wish to use "AddLanguage pl .po" to
# avoid the ambiguity with the common suffix for perl scripts.
#
# Note 2: The example entries below illustrate that in some cases
# the two character \'Language\' abbreviation is not identical to
# the two character \'Country\' code for its country,
# E.g. \'Danmark/dk\' versus \'Danish/da\'.
#
# Note 3: In the case of \'ltz\' we violate the RFC by using a three char
# specifier. There is \'work in progress\' to fix this and get
# the reference data for rfc1766 cleaned up.
#
# Danish (da) - Dutch (nl) - English (en) - Estonian (et)
# French (fr) - German (de) - Greek-Modern (el)
# Italian (it) - Norwegian (no) - Norwegian Nynorsk (nn) - Korean (kr)
# Portugese (pt) - Luxembourgeois* (ltz)
# Spanish (es) - Swedish (sv) - Catalan (ca) - Czech(cz)
# Polish (pl) - Brazilian Portuguese (pt-br) - Japanese (ja)
# Russian (ru) - Croatian (hr)
#
AddLanguage da .dk
................(略)

> 需要现实中文时在此处添加(2)AddLanguage zh-cn .cn

#
# LanguagePriority allows you to give precedence to some languages
# in case of a tie during content negotiation.
#
# Just list the languages in decreasing order of preference. We have
# more or less alphabetized them here. You probably want to change this.
#

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

> 选择语言版本的指令。一个HTML文档可以同时具备多个语言的版本.

#
# ForceLanguagePriority allows you to serve a result page rather than
# MULTIPLE CHOICES (Prefer) [in case of a tie] or NOT ACCEPTABLE (Fallback)
# [in case no accepted languages matched the available variants]
#
ForceLanguagePriority Prefer Fallback

#
# Specify a default charset for all pages sent out. This is
# always a good idea and opens the door for future internationalisation
# of your web site, should you ever want it. Specifying it as
# a default does little harm; as the standard dictates that a page
# is in iso-8859-1 (latin1) unless specified otherwise i.e. you
# are merely stating the obvious. There are also some security
# reasons in browsers, related to javascript and URL parsing
# which encourage you to always set a default char set.
#
AddDefaultCharset ISO-8859-1

> 需要现实中文时将此处改为(3)AddDefaultCharset GB2312

#
# Commonly used filename extensions to character sets. You probably
# want to avoid clashes with the language extensions, unless you
# are good at carefully testing your setup after each change.
# See ftp://ftp.isi.edu/in-notes/iana/ass.../character-sets for
# the official list of charset names and their respective RFCs
#

AddCharset ISO-8859-1 .iso8859-1 .latin1
AddCharset Big5 .Big5 .big5
# For russian, more than one charset is used (depends on client, mostly):
AddCharset WINDOWS-1251 .cp-1251 .win-1251
...........(略)

# The set below does not map to a specific (iso) standard
# but works on a fairly wide range of browsers. Note that
# capitalization actually matters (it should not, but it
# does for some browsers).
#
# See ftp://ftp.isi.edu/in-notes/iana/ass.../character-sets
# for a list of sorts. But browsers support few.
#

>(如果没有的话) 需要现实中文时在此处添加 AddCharset GB2312 .gb2312 .gb
AddCharset GB2312 .gb2312 .gb
.............(略)

#
# AddType allows you to add to or override the MIME configuration
# file mime.types for specific file types.
#
> AddType参数可以为特定后缀的文件指定MIME类型,这里的设置将覆盖 mime.types中的设置。

AddType application/x-tar .tgz

#
# AddHandler allows you to map certain file extensions to "handlers":
# actions unrelated to filetype. These can be either built into the server
# or added with the Action directive (see below)
#
# To use CGI scripts outside of ScriptAliased directories:
# (You will also need to add "ExecCGI" to the "Options" directive.)
#
> AddHandler是用于指定非静态的处理类型,用于定义文档为一个非静态的文档类型,需要进行处理,
> 再向浏览器返回处理结果。例如上面注释中的设置是将以.cgi结尾的文件设置为cgi-script类型,那
> 么服务器将启动这个CGI程序以进行处理。如果需要在前面AliasScript定义的路径之外执行CGI程序,
> 就需要使用这个参数进行设置,此后以.cgi结尾的文件将被当作CGI程序执行。

#AddHandler cgi-script .cgi
#
# For files that include their own HTTP headers:
#
#AddHandler send-as-is asis
#
# For server-parsed imagemap files:
#
AddHandler imap-file map
#
# For type maps (negotiated resources):
# (This is enabled by default to allow the Apache "It Worked" page
# to be distributed in multiple languages.)
#
AddHandler type-map var
# Filters allow you to process content before it is sent to the client.
#
# To parse .shtml files for server-side includes (SSI):
# (You will also need to add "Includes" to the "Options" directive.)
#
AddOutputFilter INCLUDES .shtml
> 使用 SSI 功能
#
# Action lets you define media types that will execute a script whenever
# a matching file is called. This eliminates the need for repeated URL
# pathnames for oft-used CGI file processors.
# Format: Action media/type /cgi-script/location
# Format: Action handler-name /cgi-script/location
#
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
# Some examples:
#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.example.com/subscription_info.html
#

Alias /error/ "/var/www/error/"

> Alias参数用于将URL与服务器文件系统中的真实位置进行直接映射,一般的文档将
> 在DocumentRoot 中进行查询,然而使用Alias定义的路径将直接映射到相应目录下,
> 而不再到DocumentRoot 下面进行查询。
#
# The following directives modify normal HTTP response behavior to
# handle known problems with browser implementations.
#
BrowserMatch "Mozilla/2" nokeepalive
BrowserMatch "MSIE 4\\.0b2;" nokeepalive downgrade-1.0 force-response-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

> BrowserMatch命令为特定的客户程序,设置特殊的参数,以保证对老版本浏览器的
> 兼容性,并支持新浏览器的新特性。
#
# The following directive disables redirects on non-GET requests for
# a directory that does not include the trailing slash. This fixes a
# problem with Microsoft WebFolders which does not appropriately handle
# redirects for folders with DAV methods.
#
BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully
BrowserMatch "^WebDrive" redirect-carefully
#
# Allow server status reports, with the URL of http://servername/server-status
# Change the ".your-domain.com" to match your domain to enable.
#
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from .your-domain.com
</Location>

> 在以上的配置中,存取/server-status 资源时,将提供服务器当前活动的报告。

#
# Allow remote server configuration reports, with the URL of
# http://servername/server-info (requires that mod_info.c be loaded).
# Change the ".your-domain.com" to match your domain to enable.
#
<Location /server-info>
SetHandler server-info
Order deny,allow
Deny from all
Allow from .your-domain.com
</Location>

> 这个页面显示的就是编译到Apache 里面的东西的列表以及其他针对服务器的各种特性。
> 如果你输入:http://your.server/server-info/ 就可以看到服务器内置的模块列表或者通
> 过DSO 加载的模块列表。这对于安装和配置特定的服务器来说是十分有用的。特别是用来对错
> 误的配置文件查找问题时。
#

# Proxy Server directives. Uncomment the following lines to

# enable the proxy server:

#

#<IfModule mod_proxy.c>

#ProxyRequests On

#

> On/Off启用或者禁用Apache代理功能


#<Proxy *>

# Order deny,allow

# Deny from all

# Allow from .your-domain.com

#</Proxy>

#

# Enable/disable the handling of HTTP/1.1 "Via:" headers.

# ("Full" adds the server version; "Block" removes all outgoing Via: headers)

# Set to one of: Off | On | Full | Block

#

#ProxyVia On

#

# To enable the cache as well, edit and uncomment the following lines:

# (no cacheing without CacheRoot)

#


#CacheRoot "/etc/httpd/proxy"
> 指定缓存目录

#CacheSize
> 5代理缓存大小 KB为单位

#CacheGcInterval 4(time)
> 每隔time小时检查缓存区,如果缓存占用超过CacheSize设置的上限,就删除文件

#CacheMaxExpire 24
> 缓存文件中最多保存时间

#CacheLastModifiedFactor 0.1

> 如果没定义文件过期时间则 过期时间 = 最近一次修改时间 * 0.1
#CacheDefaultExpire 1(time)
> 如果文件是通过不支持过期时间协议获得的,使用time作为过期时间


--  作者:admin
--  发布时间:2005-2-9 19:01:45

--  
dhcp

/etc/dhcpd.conf
option domain-name "abcd.com"; // DNS域名
option domain-name-servers 202.115.23.2; //分配DNS服务器
option routers 10.0.0.253; //分配网关
default-lease-time 6000; //默认最大租用时间(秒)
subnet 10.0.0.0 netmask 255.0.0.0 //分配子网掩码
{
range 10.0.0.50 10.0.0.80; // ip分配范围
}

etc/squid.conf

Squid.conf 的配置实例
实例 :
http_port 8080 ###定义squid监听HTTP客户连接请求的端口为8080
cache_mem 32 MB ###指定squid可以使用的内存理想值为32M
cache_swap_low 90
cache_swap_high 95 ###squid使用大量的交换空间来存储对象。那么,过了一定的时间以后,该交换空间就会用完,所以还必须定期的按照某种指标来将低于某个水平线的对象 清除。squid使用所谓的“最近最少使用算法”(LRU)来做这一工作。当已使用的交换空间达到cache_swap_high时,squid就根据 LRU所计算的得到每个对象的值将低于某个水平线的对象清除。这种清除工作一直进行直到已用空间达到cache_swap_low。这两个值用百分比表 示,如果你所使用的交换空间很大的话,建议你减少这两个值得差距,因为这时一个百分点就可能是几百兆空间,这势必影响squid的性能。
maximum_object_size 4096 KB ###可存储最大对象。如果你想要提高访问速度,就请降低该值;如果你想最大限度地节约带宽,降低成本,请增加该值。
httpd_accel_host virtual ##设置为虚拟主机模式(可略)
httpd_accel_port 80 ##设置加速端口(可略)这两个选项是用来定义squid加速模式的。用virtual来指定为虚拟主机模式。80端口为要加速的请求端口。采用这种模式 时,Squid就取消了缓存及ICP功能,假如需要这些功能,必须设置httpd_accel_with_proxy选项。##
httpd_accel_with_proxy on ##(可略)
httpd_accel_uses_host_header on ##(可略)这两个选项在透明代理模式下是必须设置成on的。在该模式下,Squid既是web请求的加速器,又是缓存代理服务器。
cache_dir ufs /usr/local/squid/cache 100 16 256 #指定squid用来存储对象的交换空间的大小及其目录结构。
cache_access_log /var/log/squid/access.log ###指定squid访问日志的完整路径 (可略)
cache_log /var/log/squid/cache.log ##指定squid一般信息日志的完整路径 (可略)
cache_store_log /var/log/squid/store.log ##指定squid存储日志的完整路径 (可略)
cache_dns_program /usr/lib/squid/dnsserver ##指定squid域名解析完整路径 (可略)
dns_nameservers IP 指定一个DNS服务器列表,强制squid使用该列表中的DNS服务器而非使用/etc/resolv.conf文件中定义的DNS服务器。你可以这样指 定多个DNS服务器,如:dns_nameservers 10.0.0.1 19(可略)
unlinkd_program /usr/local/libexec/unlinkd ##指定文件删除进程的完整路径
acl all src 0.0.0.0/0.0.0.0
acl lib src 100.0.0.0/255.255.255.0
acl allowserver1 dst 202.96.31.116/255.255.255.255 166.111.120.60/255.255.255.255 162.105.138.207/255.255.255.255 202.117.24.24/255.255.255.255
acl allowserver5 dst 202.120.13.16/255.255.255.255 202.117.83.12/255.255.255.255 202.117.96.9/255.255.255.255
acl allowsite dstdomain .xait.edu.cn .xjtu.edu.cn .tsinghua.edu.cn .nlc.gov.cn .pku.edu.cn .sjtu.edu.cn .cepiec.com.cn .sybook.com .ruc.edu.cn .163.com
acl denysite dstdomain .com .cn .org
acl SSL_ports port 443 563
acl Safe_ports port 80 21 443 563 70 210 9000 81 1025-65535
acl CONNECT method CONNECT
http_access allow allowsite
http_access deny denysite
http_access allow allowserver1
http_access allow allowserver5
http_access deny !allowserver5
http_access allow lib
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access deny all ######acl aclname acltype "file" ... 当使用文件时,该文件的格式为每行包含一个条目分别说明如下: acltype 可以是 src dst srcdomain dstdomain url_pattern urlpath_pattern time port proto method browser user 中的一种。
src 指明源地址。可以用以下的方法指定:
acl aclname src ip-address/netmask ... (客户ip地址)
acl aclname src addr1-addr2/netmask ... (地址范围) srcdomain 指明客户所属的域。语法为:
acl aclname srcdomain foo.com ... squid将根据客户ip反向查询DNS。
dstdomain 指明请求服务器所属的域。语法为:
acl aclname dstdomain foo.com ... 由客户请求的URL决定。
注意,如果用户使用服务器ip而非完整的域名时,squid将进行反向的DNS解析来确 定其完整域名,如果失败就记录为“none”。
time 指明访问时间。语法如下:
acl aclname time [day-abbrevs] [h1:m1-h2:m2][hh:mm-hh:mm]
day-abbrevs:
S - Sunday
M - Monday
T - Tuesday
W - Wednesday
H - Thursday
F - Friday
A - Saturday
h1:m1 必须小于 h2:m2,表达示为[hh:mm-hh:mm]。
port 指定访问端口。可以指定多个端口,比如:
acl aclname port 0-1024 ... (指定一个端口范围)
proto 指定使用协议。可以指定多个协议:
acl aclname proto HTTP FTP ...
method 指定请求方法。比如:
acl aclname method GET POST ... 。
cache_effective_user nobody (可略)
cache_effective_group nobody (可略) ###说明:如果用root启动squid,squid将变成这两条语句指定的用户和用户组。缺省变为squid用户和squid用户组。注意这里指定的 用户和用户组必须真是存在于/etc/passwd中。如果用非root帐号启动squid,则squid将保持改用户及用户组运行,这时候,你不能指定 小于1024地http_port。


--  作者:admin
--  发布时间:2005-2-9 19:02:25

--  
/etc/resolv.conf

1.文件格式
/etc/resolv.conf 是系统的DNS解析器配置文件,最常见的用途是用来指定系统所使用的DNS服务器地址,您可以最多指定MAXNS个DNS服务器,MAXNS是一个常量, 在/usr/include/resolv.h中定义,一般为3。每个DNS服务器地址应该以点分十进制格式写在单独的行上,前面加上关键字 nameserver。例如:
nameserver 173.26.100.99
nameserver 202.118.224.101
这里我们指定了两个DNS服务器,ip地址分别为173.26.100.99和202.118.224.101。当系统需要进行DNS解析时,优先使用列在前面的DNS Server,如果解析失败则转而使用下一个DNS Server。

2.安全性
/etc/resolv.conf的默认权限为0644

3.See also
resolv.conf(5)
host.conf(5)

/etc/host.conf

1.文件格式
/etc/host.conf 也是一个DNS解析器配置文件,但它最常见的用途是用来指定解析器使用的方法。一般来说,DNS解析可以使用两种方法,一是查询DNS服务器,二是使用本 地hosts主机表。/etc/host.conf可以用来指定优先使用哪一种方法。可以使用order关键字来指定他们的优先级.order后可跟一种 或多种DNS查询方法,之间用逗号隔开,其优先级依次降低。可用的DNS查询方法有:hosts,bind,nis,分别表示使用本地hosts主机表, DNS服务器,NIS服务器来进行DNS查询。最常见的配置是:
order bind,hosts

2.安全性
/etc/host.conf的默认权限为0644

3.See also
resolv.conf(5)
host.conf(5)

只有注册用户登录后才能发表评论。