文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>LINUX网络服务器架设笔记

LINUX网络服务器架设笔记

时间:2004-11-25  来源:aeolus

    最近自己闲着无聊,弄了一台机器想用UNIX完整的做一台网络服务器,实现Proxy、Web、FTP、MAIL、DNS、DHCP等功能,起初想的简单,结果做了才知道其中滋味。因为以前只是纸上谈兵,并没多少实战经验,现在空机器上一大堆的服务需要配置,满篇的代码需要一行一行的看,怎一个苦字了得。也是因为这个,这段时间一直没空上来管理版块。现在我已经将服务器配的差不多,顺便花点小时间整理了一下安装笔记,现在贴上来供大家一起探讨。因为过程比较烦乱,我只记录最终的版本,会在以后陆续贴上来,欢迎大家批评指导。

    最近自己闲着无聊,弄了一台机器想用UNIX完整的做一台网络服务器,实现Proxy、Web、FTP、MAIL、DNS、DHCP等功能,起初想的简单,结果做了才知道其中滋味。因为以前只是纸上谈兵,并没多少实战经验,现在空机器上一大堆的服务需要配置,满篇的代码需要一行一行的看,怎一个苦字了得。也是因为这个,这段时间一直没空上来管理版块。现在我已经将服务器配的差不多,顺便花点小时间整理了一下安装笔记,现在贴上来供大家一起探讨。因为过程比较烦乱,我只记录最终的版本,会在以后陆续贴上来,欢迎大家批评指导。

***********************************正文****************************************

LINUX网络服务器架设笔记

*** 面向用户:初级
*** 文章属性:原创 (最先发布于www.52xfu.com校友网论坛电脑知识版)
*** 作者:aeolus ([email protected])
*** 编写时间:2004年7月
*** 版权声明:可自由以电子格式(非印刷)转载,但请保留此说明;如需印刷出版请与作者联系。

一、操作系统及环境

    现在流行的UNIX操作系统种类繁多,分为Linux、BSD、Solaris、SCO UNIX、HP-UX、AIX、Tru64 UNIX、Mac OS X等等很多种类,而每个种

类还不尽相同。就拿Linux来说,有很多分支,比如很出名的RedHat,SlackWare,TurboLinux,SUSE,Debian,teamLinux,BluePoint,以及

中国的红旗Linux等,就Linux而言,现在RedHat是当之无愧的老大;而BSD下面也分为FreeBSD、NetBSD、BSD/OS、4.4BSDLite等等,这当中

FreeBSD应用最广;Solaris是Sun公司的标准操作系统,我就不多说了;SCO UNIX是指Open UNIX、UnixWare、SCO OpenServer等SCO公司的操作

系统;HP-UX是HP的,AIX是IBM的,Tru64 UNIX是Compaq的,Mac OS X是苹果公司最新的UNIX操作系统。

    上面说了一大堆废话,就是想让大家了结一下UNIX的现状。好了,现在我们言归正传,看看我是怎么做的吧。
    我选择的软件是:
    RedHat Linux 版本 9.01 内核版本 2.4.20-8
    Proxy:  netfilter/iptables 版本 1.2.7a-2
    Web:  APACHE  版本 2.0.40-21
    FTP:  Proftp  版本 1.2.9
    DNS:  BIND  版本 9.2.1-16
    DHCP:  DHCPD  版本 3.0pl-23
    MAIL:  PostFix  版本 2.0.19
    LDAP:  OpenLDAP 版本 2.1.29
    编译器:  GCC  版本 3.2.2-5    

    再看看我的硬件:
    CPU: P3 800Hz intel
    IDE: 20G  昆腾
    RAM: 128M  HY
    CD-ROM: 50X  Acer
    DISPLAY: TNT2 M64 不清楚
    NET: 530TX两块 D-Link
    同时我还准备了另外一台机子作为它的子机试验用,这台机子配置无关紧要,有个网卡能上网就行了。

二、系统安装

系统安装只需要将RedHat Linux9.01的第一张光盘放进光驱重启,进入安装界面,然后一步步按照提示选择即可,在这里略过不提。因为我的

硬件都是比较老的,所以全部都被系统认出,没什么麻烦。但是如果在安装过程中遇到这种硬件无法驱动的情况,可以直接去红帽子网站

http://www.redhat.com寻找答案。

值得提醒的是,安装中有一个界面是要选择安装模式,station、server或者all,选择server就可以了,不过我为了后面配置简便,在这里为

每一项做了详细选择,安装了许多系统默认不会安装的东西。还有就是在安装时,系统会提醒输入主机名,我的主机名是aeolus。

三、配置网络

系统安装好并以root登陆后,就该开始逐步配置应用模块了。首先我需要aeolus这台机器能上网。先用ifconfig命令看看情况:
[root@aeolus//]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:05:5D:0A:1C:ED
 inet addr:0.0.0.0
 ........(代表省略,我是用手敲的这些文字,照抄下去我会疯掉的,只留了有用的两行)
eth1 Link encap:Ethernet HWaddr 00:05:BA:2B:B8:E5
 inet addr:0.0.0.0
 ........
lo Link encap:Local Loopback
 inet addr:127.0.0.1 Mask:255.0.0.0
 ........
我准备将eth0设为内网入口,将eth1设为外网出口,架设我有个外网公有IP地址为202.100.100.100,网关是202.100.100.1那么:
[root@aeolus//]# ifconfig eth0 192.168.0.1 netmask 255.255.225.0
[root@aeolus//]# route add default gw 192.168.0.1 eht0
[root@aeolus//]# ifconfig eth1 202.100.100.100 netmask 255.255.255.0
[root@aeolus//]# route add default gw 202.100.100.1 eht1
再用ifconfig命令看看情况:
[root@aeolus//]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:05:5D:0A:1C:ED
 inet addr:192.168.0.1 Bcast:192.168.0.255 Mask:255.255.255.0
 ........
eth1 Link encap:Ethernet HWaddr 00:05:BA:2B:B8:E5
 inet addr:202.100.100.100 Bcast:202.100.100.255
 ........
lo Link encap:Local Loopback
 inet addr:127.0.0.1 Mask:255.0.0.0

四、Proxy和firewall

我选用的proxy工具是netfilter/iptables,它是与最新的 2.4.x 版本 Linux 内核集成的 IP 信息包过滤系统。如果 Linux 系统连接到因特

网或 LAN、服务器或连接 LAN 和因特网的代理服务器,则该系统在 Linux 系统上能更好地控制 IP 信息包过滤和防火墙配置。虽然

netfilter/iptables IP 信息包过滤系统被称为单个实体,但它实际上由两个组件 netfilter 和 iptables 组成。
netfilter 组件也称为内核空间(kernelspace),是内核的一部分,由一些信息包过滤表组成,这些表包含内核用来控制信息包过滤处理的规

则集。
iptables 组件是一种工具,也称为用户空间(userspace),它使插入、修改和除去信息包过滤表中的规则变得容易。
在开始安装 iptables 用户空间工具之前,需要对系统做某些修改。首先,需要使用 make config 命令来配置内核的选项。在配置期间,必须

通过将 CONFIG_NETFILTER 和 CONFIG_IP_NF_IPTABLES 选项设置为 Y 来打开它们,因为这是使 netfilter/iptables 工作所必需的。下面是

可能要打开的其它选项:

CONFIG_PACKET:如果要使应用程序和程序直接使用某些网络设备,那么这个选项是有用的。
CONFIG_IP_NF_MATCH_STATE:如果要配置有状态的防火墙,那么这个选项非常重要而且很有用。这类防火墙会记得先前关于信息包过滤所做的

决定,并根据它们做出新的决定。
CONFIG_IP_NF_FILTER:这个选项提供一个基本的信息包过滤框架。如果打开这个选项,则会将一个基本过滤表(带有内置的 INPUT、FORWARD

和 OUTPUT 链)添加到内核空间。
CONFIG_IP_NF_TARGET_REJECT:这个选项允许指定:应该发送 ICMP 错误消息来响应已被 DROP 掉的入站信息包,而不是简单地杀死它们。

ok,开始吧。首先从www.netfilter.org 下载iptables的压缩文件iptables-1.2.7a-2.tar.bz2,我把这个文件存放到/tmp/temp/fire/目录。
首先必须关闭和卸载以前系统上默认安装的iptables或者ipchains,然后继续:
# cd /tmp/temp/fire
# bzip2 -d iptables-1.2.7a-2.tar.bz2
# tar -xvf  iptables-1.2.6a.tar
# cd iptables-1.2.7a-2
# make
# make install
先用iptables --list查看一下没有定义规则时iptables的样子:
Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination        

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
好了,现在可以定义iptables规则了,首先进入/etc/rc.d目录,可以看到在这个目录下有rc.local和rc.sysinit文件,这两个文件都很重要,

是机器每次启动时都会加载运行的脚本。首先新建一个脚本,命名为firewall,然后在这个脚本里按照自己的条件定义规则:

#缺省情况下,IP转发都处于不可用状态,将其设置为可用状态:
echo 1 > /proc/sys/net/ipv4/ip_forward
#加载所需的内核
/sbin/modprobe ip_tables
/sbin/modprobe iptable_filter
/sbin/modprobe iptable_nat
/sbin/modprobe ip_conntrack
/sbin/modprobe ip_conntrack_ftp
/sbin/modprobe ip_nat_ftp
#定义规则
/sbin/iptables --flush INPUT
/sbin/iptables --flush FORWARD
/sbin/iptables --flush POSTROUTING --table  nat
/sbin/iptables --policy FORWARD DROP
/sbin/iptables --table nat --append POSTROUTING --out-interface eth1 --source 192.168.0.0/24 --jump MASQUERADE
/sbin/iptables --append FORWARD --in-interface eth1 --match state --state ESTABLISHED,RELATED --jump ACCEPT
/sbin/iptables --append FORWARD --source 192.168.0.0/24 --jump ACCEPT
#限制一些流出的信息
$IPTABLES -A OUTPUT -o eth0 -p tcp -dport 31337 -j DROP
$IPTABLES -A OUTPUT -o eth0 -p tcp -sport 31337 -j DROP
此外,31335、27444、27665、20034 NetBus、9704、137-139(smb)等端口也应被禁止,如果不想让局域网的人QQ,还可以在这里定义禁止

8000端。(好像是8000吧,我不记得QQ端口是多少了)。
定义好iptables规则之后,保存firewall脚本,用./firewall执行就可以用了。然后编辑rc.sysinit文件,添加一行:
/etc/rc.d/firewall
这样在机器每次启动时都可以加载firewall脚本。

更详尽的资料可参照Oskar Andreasson的Iptables Tutorial 1.1.19一文,地址是:

http://www.linuxsecurity.com/resource_files/firewalls/IPTables-Tutorial/iptables-tutorial.html

五、Web

在安装系统时,只要选择了服务器模式,RH是会自动安装好Apache的,所以安装一节略过不提,我主要说配置。Apache传统上使用三个配置文

件httpd.conf,access.conf和srm.conf来配置Apache服务器的行为。httpd.conf是Apache服务器主要配置文件,它包含服务器的影响服务器运行

的配置指令,被分为三个部分:1. 控制整个Apache服务器行为的部分(即全局环境变量)2. 定义主要或者默认服务参数的指令,也为所有虚拟

主机提供默认的设置参数 3. 虚拟主机的设置参数 ,下面就是httpd.conf文件:

## httpd.conf - configuration for the Apache web server
#
### Section 1: Global Environment
#
# 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
# 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: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"

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

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

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

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

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

##
## 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
MinSpareServers 5
MaxSpareServers 20
MaxClients 150
MaxRequestsPerChild 100
</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>

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

#
# 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
#
LoadModule access_module modules/mod_access.so
LoadModule auth_module modules/mod_auth.so
LoadModule auth_anon_module modules/mod_auth_anon.so
LoadModule auth_dbm_module modules/mod_auth_dbm.so
LoadModule auth_digest_module modules/mod_auth_digest.so
LoadModule include_module modules/mod_include.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule env_module modules/mod_env.so
LoadModule mime_magic_module modules/mod_mime_magic.so
LoadModule cern_meta_module modules/mod_cern_meta.so
LoadModule expires_module modules/mod_expires.so
LoadModule headers_module modules/mod_headers.so
LoadModule usertrack_module modules/mod_usertrack.so
LoadModule unique_id_module modules/mod_unique_id.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 asis_module modules/mod_asis.so
LoadModule info_module modules/mod_info.so
LoadModule cgi_module modules/mod_cgi.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 imap_module modules/mod_imap.so
LoadModule actions_module modules/mod_actions.so
LoadModule speling_module modules/mod_speling.so
LoadModule userdir_module modules/mod_userdir.so
LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so

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

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

#
# 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;
#  don't use Group #-1 on these systems!
#
User apache
Group apache

#
# 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. [email protected]
#
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 doesn't 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.aeolus.com

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

#
# 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 "/etc/httpd/html"

#
# Disable autoindex for the root directory, and present a
# default Welcome page if no other index page is present.
#
<LocationMatch "^/$">
    Options -Indexes
    ErrorDocument 403 /error/noindex.html
</LocationMatch>

#
# 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 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 user's public_html
    # directory, use this directive instead of "UserDir disable":
    #
    #UserDir public_html

</IfModule>

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

#
# AccessFileName: The name of the file to look for in each directory
# for access control information.  See also the AllowOverride directive.
#
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>

#
# TypesConfig describes where the mime.types file (or equivalent) is
# to be found.
#
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

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

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

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

#
# 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 mailto: link to the ServerAdmin.
# Set to one of:  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" 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/"

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


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

#
# 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 /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 is which icon to show for files which do not have an icon
# explicitly set.
#
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

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

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

#
# AddEncoding allows you to have certain browsers (Mosaic/X 2.1+) uncompress
# information on the fly. Note: Not all browsers support this.
# Despite the name similarity, the following Add* directives have nothing
# to do with the FancyIndexing customization directives above.
#
AddEncoding x-compress Z
AddEncoding x-gzip gz tgz

#
# 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
#
# 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
AddLanguage nl .nl
AddLanguage en .en
AddLanguage et .et
AddLanguage fr .fr
AddLanguage de .de
AddLanguage he .he
AddLanguage el .el
AddLanguage it .it
AddLanguage ja .ja
AddLanguage pl .po
AddLanguage kr .kr
AddLanguage pt .pt
AddLanguage nn .nn
AddLanguage no .no
AddLanguage pt-br .pt-br
AddLanguage ltz .ltz
AddLanguage ca .ca
AddLanguage es .es
AddLanguage sv .se
AddLanguage cz .cz
AddLanguage ru .ru
AddLanguage tw .tw
AddLanguage zh-tw .tw
AddLanguage hr .hr

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

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

#
# 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/assignments/character-sets for
# the official list of charset names and their respective RFCs
#
AddCharset ISO-8859-1  .iso8859-1  .latin1
AddCharset ISO-8859-2  .iso8859-2  .latin2 .cen
AddCharset ISO-8859-3  .iso8859-3  .latin3
AddCharset ISO-8859-4  .iso8859-4  .latin4
AddCharset ISO-8859-5  .iso8859-5  .latin5 .cyr .iso-ru
AddCharset ISO-8859-6  .iso8859-6  .latin6 .arb
AddCharset ISO-8859-7  .iso8859-7  .latin7 .grk
AddCharset ISO-8859-8  .iso8859-8  .latin8 .heb
AddCharset ISO-8859-9  .iso8859-9  .latin9 .trk
AddCharset ISO-2022-JP .iso2022-jp .jis
AddCharset ISO-2022-KR .iso2022-kr .kis
AddCharset ISO-2022-CN .iso2022-cn .cis
AddCharset Big5        .Big5       .big5
# For russian, more than one charset is used (depends on client, mostly):
AddCharset WINDOWS-1251 .cp-1251   .win-1251
AddCharset CP866       .cp866
AddCharset KOI8-r      .koi8-r .koi8-ru
AddCharset KOI8-ru     .koi8-uk .ua
AddCharset ISO-10646-UCS-2 .ucs2
AddCharset ISO-10646-UCS-4 .ucs4
AddCharset UTF-8       .utf8

# 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/assignments/character-sets
# for a list of sorts. But browsers support few.
#
AddCharset GB2312      .gb2312 .gb
AddCharset utf-7       .utf7
AddCharset utf-8       .utf8
AddCharset big5        .big5 .b5
AddCharset EUC-TW      .euc-tw
AddCharset EUC-JP      .euc-jp
AddCharset EUC-KR      .euc-kr
AddCharset shift_jis   .sjis

#
# AddType allows you to add to or override the MIME configuration
# file mime.types for specific file 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-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

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

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

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

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


### Section 3: Virtual Hosts
#
# <VirtualHost *>
# ServerAdmin [email protected]
# DocumentRoot /etc/httpd/html1
# ServerName www1.aeolus.com
# ErrorLog logs/aeolus-error_log
# CustomLog logs/dummy-aeolus.com-access_log commom
# </virtualHost>
因为我没必要设置虚拟主机,所以第三部分只给出了示例。
然后把自己做好的web站点(假设只有一个index.htm文件)放进配置文件设置的路径:
# mkdir /etc/httpd/html
# mv -rf index.htm /etc/httpd/html/
开启守护进程
# service httpd start          [ ok ]
 
六、 FTP

porftpd是一个配置方法与APACHE相类似的FTP服务器,有两种运行方式,独立服务器与超级服务器的子服务器。无论从安全性还是稳定性还是

可配置性来说都是非常好的选择。一般来说redhat上的wu-ftp的问题太多,为了安全起见用proftpd还好一些.

取得:
http://www.proftpd.net是其公司网站上有大量资料,到ftp://ftp.proftpd.net/pub/proftpd/可以下载最新的proftpd-1.2.9.tar.gz
安装:
# tar proftpd-1.2.9.tar.gz
# cd proftpd-1.2.9
设定安装到/www/protpd目录中
# ./configure --prefix=/www/proftpd
# make
# make install 
设定:
几个文件的功能及路径:
/www/proftpd/sbin/proftpd  执行程序
/www/proftpd/etc/proftpd.conf  设置文件
/www/proftpd/var/proftpd.pid proftpd做为一个服务的ID号

配置proftpd.conf文件:(./doc目录内有proftpd.conf的说明)

 ServerName                 "ProFTPD Default Installation"
 ServerType                 standalone
 DefaultServer                      on
 Port                               21
 User                               nobody
 Group                              ftp
 DefaultRoot ~
 〈Directory /*>
 AllowOverwrite            on
 〈/Directory>
 〈Anonymous ~ftp>
 User                               ftp
 Group                              ftp
 UserAlias                  anonymous ftp
 MaxClients                 10
 DisplayLogin                       welcome.msg
 DisplayFirstChdir          .message
 RequireValidShell            no
 〈Limit WRITE>
        DenyAll
 〈/Limit>
 〈/Anonymous>

在默认的"/www/proftpd/etc/proftpd.conf/"文件中有一行文字"ServerType standalone",指定"/www/proftpd/sbin/proftpd"以一个服务的

式来工作,可以放"/www/proftpd/sbin/proftpd"到"/etc/rc.d/rc.local"文件中,以便开机起动. 也可以改变"ServerType

standalone"为"ServerType inetd", 并修改"/etc/inetd.conf"中的
ftp stream tcp nowait root      /usr/sbin/in.ftpd in.ftpd
改变为 tp stream tcp nowait root      /www/proftpd/sbin/proftpd proftpd
但是因为我没有随机开启ftp的必要,所以我没有设定这些,只是将启动脚本放在/etc/rc.d/init.d/目录下,进行手动开启:
# cp ./contrib/dist/rpm/proftpd.init.d  /etc/rc.d/init.d/proftpd
# chmod o+x /etc/rc.d/init.d/proftpd
添加in.proftpd:
# vi /etc/rc.d/init.d/fuctions
在PATH后面添加 /usr/local/sbin
试验启动:
# /etc/rc.d/init.d/proftpd start       [ OK ]

七、 DHCP

大多数的情况下Linux作为DHCP服务器而windows 95/98作为DHCP客户。Linux也可以作为DHCP客户,但你要安装dhcpcd rpm 软件包 ,Linux作为

DHCP服务器,只需要安装dhcpd rpm 包。RH9.0自带的dhcp版本比较低,所以我从网上下载新版本。下载两个软件包:dhcp-3.0pll-

23.i386.rpm和dhcp-devel-3.0pll-23.i386.rpm,然后:
# rpm -e dcp
# rpm -ivh dhcp-3.0pll-23.i386.rpm
# rpm -ivh dhcp-devel-3.0pll-23.i386.rpm

使DHCP服务器为windows机器服务,需要创建一个到地址255.255.255.255的路由,加这条路由命令到/etc/rc.d/rc.local使得每次启动后自动

运行。
# route add -host 255.255.255.255 dev eth0
但是报告错误消息:255.255.255.255:Unkown host
于是,我试着加下面的入口到/etc/hosts文件:
# route add -host dhcp dev eth0 。

DHCPd后台程序总是读取配置文件/etc/dhcpd.conf, 下面就是DHCP配置文件的例子:

    ddns-update-style interim;
    ignore client-updates;
    subnet 192.168.0.0 netmask 255.255.255.0 {
    option routers 192.168.0.1;
    option subnet-mask 255.255.255.0;
    option domain-name-servers 192.168.0.1,202.100.100.100;
    option time-offset -18000;
    range dynamic-bootup 192.168.0.10  192.168.0.254;
  default-lease-time 21600;
  max-lease-time 43200;
  }

ok,可以启动dhcp了:
# service dhcpd start
然后在另一台windows机器上测试,成功!

八、 DNS

RH9默认就安装了BIND9.2.1,所以我的主要动作就在修改配置文件上,首先:
# vi /etc/resolv.conf
nameserver 127.0.0.1
nameserver 202.100.100.100
nameserver 202.100.100.1

然后:
# vi /etc/named.conf

// generated by named-bootconf.pl

options {
directory "/var/named";

// query-source address * port 53;
};

//
// a caching only nameserver config
//
controls {
inet 127.0.0.1 allow { localhost; } keys { rndckey; };
};
zone "." IN {
type hint;
file "named.ca";
};

zone "localhost" IN {
type master;
file "localhost.zone";
allow-update { none; };
};

zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
allow-update { none; };
};

zone "aeolus.com" IN {
type master;
file "aeolus.com";
allow-update { none;};
};

include "/etc/rndc.key";

接着:
# vi /var/named/localhost.zone

$TTL 86400
$ORIGIN localhost.
@ 1D IN SOA @ root.localhost (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expire
1D ) ; minimum

1D IN NS @
@ IN A 127.0.0.1

最后:
# vi /var/named/aeolus.com

@ IN SOA aeolus.com. root.localhost (
200211131 ; serial, todays date + todays serial
28800 ; refresh, seconds
7200 ; retry, seconds
604800 ; expire, seconds
86400 ) ; minimum, seconds
NS ns.aeolus.com.
@ IN A 192.168.0.1
www IN A 192.168.0.1
mail IN 192.168.0.1
ftp IN A 192.168.0.1
@ MX 10 www

ok了,配置文件就是这些,至于原理我就不讲了。
# service named start  [ OK ]
试验一下,用客户端机器设置网络地址为192.168.0.99,DNS设为192.168.0.1和202.100.100.100,然后在DOS窗口试着ping随便一个常用网址

,比如www.sohu.com,只要能ping通就说明解析成功。


九. Sendmail

确保以下安装包已经安装完毕:
imap-2001a-18.i286.rpm
sendmail-8.12.8-4.i386.rpm
m4-1.4.1-13.i386.rpm
cyrus-sasl-2.1.10-4.i386.rpm
cyrus-sasl-md5-2.1.10-4.i386.rpm
cyrus-sasl-plain-2.1.10-4.i386.rpm
cyrus-sasl-gssapi-2.1.10-4.i386.rpm
 
修改/etc/mail/sendmail.mc,修改后文件如下:
divert(-1)dnl
dnl #
dnl # This is the sendmail macro config file for m4. If you make changes to
dnl # /etc/mail/sendmail.mc, you will need to regenerate the
dnl # /etc/mail/sendmail.cf file by confirming that the sendmail-cf package is
dnl # installed and then performing a
dnl #
dnl # make -C /etc/mail
dnl #
include(`/usr/share/sendmail-cf/m4/cf.m4')dnl
VERSIONID(`setup for Red Hat Linux')dnl
OSTYPE(`linux')dnl
dnl #
dnl # Uncomment and edit the following line if your outgoing mail needs to
dnl # be sent out through an external mail server:
dnl #
dnl define(`SMART_HOST',`smtp.your.provider')
dnl #
define(`confDEF_USER_ID',``8:12'')dnl
define(`confTRUSTED_USER', `smmsp')dnl
dnl define(`confAUTO_REBUILD')dnl
define(`confTO_CONNECT', `1m')dnl
define(`confTRY_NULL_MX_LIST',true)dnl
define(`confDONT_PROBE_INTERFACES',true)dnl
define(`PROCMAIL_MAILER_PATH',`/usr/bin/procmail')dnl
define(`ALIAS_FILE', `/etc/aliases')dnl
dnl define(`STATUS_FILE', `/etc/mail/statistics')dnl
define(`UUCP_MAILER_MAX', `2000000')dnl
define(`confUSERDB_SPEC', `/etc/mail/userdb.db')dnl
define(`confPRIVACY_FLAGS', `authwarnings,novrfy,noexpn,restrictqrun')dnl
define(`confAUTH_OPTIONS', `A')dnl
dnl #
dnl # The following allows relaying if the user authenticates, and disallows
dnl # plaintext authentication (PLAIN/LOGIN) on non-TLS links
dnl #
dnl define(`confAUTH_OPTIONS', `A p')dnl
dnl #
dnl # PLAIN is the preferred plaintext authentication method and used by
dnl # Mozilla Mail and Evolution, though Outlook Express and other MUAs do
dnl # use LOGIN. Other mechanisms should be used if the connection is not
dnl # guaranteed secure.
dnl #
define(QUEUE_DIR, `/var/spool/mqueue/q*')
TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
dnl #
dnl # Rudimentary information on creating certificates for sendmail TLS:
dnl # make -C /usr/share/ssl/certs usage
dnl #
dnl define(`confCACERT_PATH',`/usr/share/ssl/certs')
dnl define(`confCACERT',`/usr/share/ssl/certs/ca-bundle.crt')
dnl define(`confSERVER_CERT',`/usr/share/ssl/certs/sendmail.pem')
dnl define(`confSERVER_KEY',`/usr/share/ssl/certs/sendmail.pem')
dnl #
dnl # This allows sendmail to use a keyfile that is shared with OpenLDAP's
dnl # slapd, which requires the file to be readble by group ldap
dnl #
dnl define(`confDONT_BLAME_SENDMAIL',`groupreadablekeyfile')dnl
dnl #
dnl define(`confTO_QUEUEWARN', `4h')dnl
dnl define(`confTO_QUEUERETURN', `5d')dnl
dnl define(`confQUEUE_LA', `12')dnl
dnl define(`confREFUSE_LA', `18')dnl
define(`confTO_IDENT', `0')dnl
dnl FEATURE(delay_checks)dnl
FEATURE(`no_default_msa',`dnl')dnl
FEATURE(`smrsh',`/usr/sbin/smrsh')dnl
FEATURE(`mailertable',`hash -o /etc/mail/mailertable.db')dnl
FEATURE(`virtusertable',`hash -o /etc/mail/virtusertable.db')dnl
FEATURE(redirect)dnl
FEATURE(always_add_domain)dnl
FEATURE(use_cw_file)dnl
FEATURE(use_ct_file)dnl
dnl #
dnl # The -t option will retry delivery if e.g. the user runs over his quota.
dnl #
FEATURE(local_procmail,`',`procmail -t -Y -a $h -d $u')dnl
FEATURE(`access_db',`hash -T<TMPF> -o /etc/mail/access.db')dnl
FEATURE(`blacklist_recipients')dnl
EXPOSED_USER(`root')dnl
dnl #
dnl # The following causes sendmail to only listen on the IPv4 loopback address
dnl # 127.0.0.1 and not on any other network devices. Remove the loopback
dnl # address restriction to accept email from the internet or intranet.
dnl #
dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
dnl #
dnl # The following causes sendmail to additionally listen to port 587 for
dnl # mail from MUAs that authenticate. Roaming users who can't reach their
dnl # preferred sendmail daemon due to port 25 being blocked or redirected find
dnl # this useful.
dnl #
DAEMON_OPTIONS(`Port=25, Name=MSA')dnl
dnl #
dnl # The following causes sendmail to additionally listen to port 465, but
dnl # starting immediately in TLS mode upon connecting. Port 25 or 587 followed
dnl # by STARTTLS is preferred, but roaming clients using Outlook Express can't
dnl # do STARTTLS on ports other than 25. Mozilla Mail can ONLY use STARTTLS
dnl # and doesn't support the deprecated smtps; Evolution <1.1.1 uses smtps
dnl # when SSL is enabled-- STARTTLS support is available in version 1.1.1.
dnl #
dnl # For this to work your OpenSSL certificates must be configured.
dnl #
dnl DAEMON_OPTIONS(`Port=smtps, Name=TLSMTA, M=s')dnl
dnl #
dnl # The following causes sendmail to additionally listen on the IPv6 loopback
dnl # device. Remove the loopback address restriction listen to the network.
dnl #
dnl # NOTE: binding both IPv4 and IPv6 daemon to the same port requires
dnl # a kernel patch
dnl #
dnl DAEMON_OPTIONS(`port=smtp,Addr=::1, Name=MTA-v6, Family=inet6')dnl
dnl #
dnl # We strongly recommend not accepting unresolvable domains if you want to
dnl # protect yourself from spam. However, the laptop and users on computers
dnl # that do not have 24x7 DNS do need this.
dnl #
FEATURE(`accept_unresolvable_domains')dnl
dnl #
dnl FEATURE(`relay_based_on_MX')dnl
dnl #
dnl # Also accept email sent to "localhost.localdomain" as local email.
dnl #
LOCAL_DOMAIN(`localhost.localdomain')dnl
dnl #
dnl # The following example makes mail from this host and any additional
dnl # specified domains appear to be sent from mydomain.com
dnl #
dnl MASQUERADE_AS(`mydomain.com')dnl
dnl #
dnl # masquerade not just the headers, but the envelope as well
dnl #
dnl FEATURE(masquerade_envelope)dnl
dnl #
dnl # masquerade not just @mydomainalias.com, but @*.mydomainalias.com as well
dnl #
dnl FEATURE(masquerade_entire_domain)dnl
dnl #
dnl MASQUERADE_DOMAIN(localhost)dnl
dnl MASQUERADE_DOMAIN(localhost.localdomain)dnl
dnl MASQUERADE_DOMAIN(mydomainalias.com)dnl
dnl MASQUERADE_DOMAIN(mydomain.lan)dnl
MAILER(smtp)dnl
MAILER(procmail)dnl

文件中,红色字体的行为需要修改的地方,共有五行需要修改。
第一行是手动添加的,与认证无关,作用是启动多个邮件队列,为了获得更好的传输性能。
第二行和第三行是去掉行首的注释。”TRUST_AUTH_MECH”的作用是使sendmail不管access文件中如何设置,都能 relay 那些通过EXTERNAL, LOGIN, PLAIN, CRAM-MD5或DIGEST-MD5等方式验证的邮件,”confAUTH_MECHANISMS" 的作用是确定系统的认证方式。Outlook Express支持的认证方式是LOGIN。
第四行是加上注释,以便让sendmail可以侦听所有网络设备,为整个网络提供服务,而不仅仅只对本机提供服务。
第五行是修改的,原来内容是:
dnl DAEMON_OPTIONS(`Port=submission, Name=MSA, M=Ea')dnl
去掉行首的注释符,并且将内容修改成Port=25:
DAEMON_OPTIONS(`Port=25, Name=MSA')dnl
在smtp的默认端口(25)上进行认证,而不是587端口。这样就强制所有使用该邮件服务器进行邮件转发的用户在认证后才能发邮件了。


运行:
# m4 /etc/mail/sendmail.mc > /etc/sendmail.cf
用m4重新生成sendmail.cf文件

既然打开了多个队列,现在在/var/spool/mqueue/下创建任意多个队列目录,运行:
# cd /var/spool/mqueue
# mkdir q1 q2 q3 q4 q5 q6

修改/etc/mail/local-host-names,将希望该邮件服务器使用的邮箱名加进去,比如邮箱为:[email protected]则将abc.com.cn加入到该文件中


重新启动sendmail服务,运行:
# killall –HUP sendmail
可以通过telnet 本机IP 25来验证sendmail服务是否已经正常启动,若登陆成功,则说明sendmail服务已经成功启动。
# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'
220 localhost.localdomain ESMTP Sendmail 8.12.8/8.12.8; Wed, 12 May 2004 15:57:01 +0800
ehlo localhost
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-AUTH GSSAPI LOGIN PLAIN
250-DELIVERBY
250-HELP
quit
#
在AUTH后面有LOGIN就基本上可以在OutlookExpress上认证了。

十. Pop3
运行:
# ntsysv
在系统服务列表中选中ipop3,选’OK’保存推出
重启xinetd服务,运行:
# service xinetd restart
运行netstat命令看smtp和pop3服务是否都已经启动
# netstat -l

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载