一、实验所需要的源码包
httpd-2.2.19.tar.bz2 #安装源码包apache
mysql-5.0.81.tar.gz #安装源码包mysql
php-5.3.7.tar.bz2 #安装php软件
postfix-2.6.2.tar.gz #postfix主程序
postfix-2.6.2-vda-ng.patch.gz #postfix的补丁包
dovecot-1.1.4.tar.gz #IMAP和POP3邮件服务器软件
squirrelmail-1.4.13.tar.bz2 #web界面邮件管理
zh_CN-1.4.13-20071220.tar.bz2 #汉化包
extman-0.2.5.tar.gz #邮件后台管理程序
extmail-1.0.5.tar.gz #web界面邮件管理
courier-authlib-0.62.4.tar.bz2 #SMTP发信认证
Unix-Syslog-1.1.tar.gz
DBI-1.616.tar.gz
DBD-mysql-4.020.tar.gz #以上三个包为extmail的倚赖包
GD-2.46.tar.gz
File-Tail-0.99.3.tar.gz
rrdtool-1.2.23-3.el5.i386.rpm
rrdtool-perl-1.2.23-3.el5.i386.rpm
二.准备工作
1.安装所需环境,必要的软件包
[root@localhost ~]# mount /dev/cdrom /mnt/cdrom/
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@localhost ~]# yum groupinstall "Development Libraries" "Development Tools" "Legacy Software Development" "X Software Development"
2.把系统自带的mysql卸载并停用sendmail
[root@localhost ~]# yum remove mysql
[root@localhost ~]# service sendmail stop
关闭 sm-client: [确定]
关闭 sendmail: [确定]
[root@localhost ~]# chkconfig sendmail off
[root@localhost ~]# rpm -e sendmail �Cnodeps
三.平台结构
1.安装apache软件
下面我们将把所有需要的安装包解压到/usr/local/src/下面以方便我们统一管理维护
[root@localhost ~]# tar -jxvf httpd-2.2.19.tar.bz2 -C /usr/local/src/
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# ll
总计 8
drwxr-xr-x 11 cms 500 4096 2011-05-21 httpd-2.2.19
[root@localhost src]# cd httpd-2.2.19/
[root@localhost httpd-2.2.19]# ./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite
[root@localhost httpd-2.2.19]# make
[root@localhost httpd-2.2.19]# make install
2安装mysql软件
[root@localhost ~]# useradd -M -s /sbin/nologin mysql #添加mysql用户,如果安装系统时候已经装过mysql会提示用户已存在,建议在安装前先卸载掉系统自带的mysql,卸载完成后必须重启,否则新装的mysql会无法启动,提示错误信息3306端口被占有
[root@localhost ~]# tar -zxvf mysql-5.0.81.tar.gz -C /usr/local/src/
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# ll
总计 16
drwxr-xr-x 12 cms 500 4096 03-23 03:41 httpd-2.2.19
drwxrwxrwx 39 7155 wheel 4096 2009-04-16 mysql-5.0.81
[root@localhost src]# cd mysql-5.0.81/
[root@localhost mysql-5.0.81]# ./configure --prefix=/usr/local/mysql
[root@localhost mysql-5.0.81]# make
[root@localhost mysql-5.0.81]# make install
安装完成。
配置mysql
[root@localhost mysql-5.0.81]# cp support-files/my-medium.cnf /etc/my.cnf #复制主配置文件
[root@localhost mysql-5.0.81]# /usr/local/mysql/bin/mysql_install_db --user=mysql #初始化
[root@localhost mysql-5.0.81]# chown -R root:mysql /usr/local/mysql
[root@localhost mysql-5.0.81]# chown -R mysql /usr/local/mysql/var
[root@localhost mysql-5.0.81]# echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf #添加库文件路径
[root@localhost mysql-5.0.81]# ldconfig #刷新库文件搜索路径
[root@localhost mysql-5.0.81]# /usr/local/mysql/bin/mysqld_safe --user=mysql & #后台安全启动 (如果显示启动并且卡住不动按回车)
[1] 27986
[root@localhost mysql-5.0.81]# Starting mysqld daemon with databases from /usr/local/mysql/var
[root@localhost mysql-5.0.81]# cp support-files/mysql.server /etc/init.d/mysqld #复制启动脚本
[root@localhost mysql-5.0.81]# chmod +x /etc/init.d/mysqld #赋予脚本执行权限
[root@localhost mysql-5.0.81]# chkconfig --add mysqld #添加到系统自动启动服务中
[root@localhost mysql-5.0.81]# chkconfig mysqld on #默认启动mysql
查看mysql在什么级别启动或者关闭
[root@localhost mysql-5.0.81]# chkconfig --list mysqld
mysqld 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
设置系统全局的环境变量PATH值,方便使用mysql数据库命令
[root@localhost mysql-5.0.81]# echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
3.安装php软件
[root@localhost ~]# tar -jxvf php-5.3.7.tar.bz2 -C /usr/local/src/
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# ll
总计 24
drwxr-xr-x 12 cms 500 4096 03-23 03:41 httpd-2.2.19
drwxrwxrwx 39 7155 wheel 4096 03-23 04:16 mysql-5.0.81
drwxr-xr-x 13 1000 1000 4096 2011-08-17 php-5.3.7
[root@localhost src]# cd php-5.3.7/
[root@localhost php-5.3.7]# ./configure --prefix=/usr/local/php5 --enable-mbstring --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php5
[root@localhost php-5.3.7]# make
[root@localhost php-5.3.7]# make test #可省略此步
[root@localhost php-5.3.7]# make install
[root@localhost php-5.3.7]# cp php.ini-production /usr/local/php5/php.ini #复制配置文件
修改apache服务的主配置文件使其支持php
[root@localhost php-5.3.7]# vim /usr/local/apache2/conf/httpd.conf
LoadModule php5_module modules/libphp5.so #确认这行存在,如果没有就重新编译php
AddType application/x-httpd-php .php #添加这行记录
DirectoryIndex index.php index.html #在这行添加关于php格式的首页
然后保存退出
4.测试php是否与apache整合成功
[root@localhost php-5.3.7]# vim /usr/local/apache2/htdocs/test.php #添加下面的内容
<?php
phpinfo();
[root@localhost php-5.3.7]#
?>
[root@localhost php-5.3.7]# /usr/local/apache2/bin/apachectl start #启动apache服务
在浏览器中输入http://192.168.2.50 看到以下结果
在浏览器中输入http://192.168.2.50/test.php 看到下图表示跟apache服务整合成功
Mysql测试
[root@localhost php-5.3.7]# vim /usr/local/apache2/htdocs/testdb.php #添加下面的内容
<?php
$link=mysql_connect(‘localhost’ , ‘test’, ‘’);
If (!$link) echo “Fail!!!”;
else echo “Success!!!”;
mysql_close();
?>
在IE浏览器中输入网址http://192.168.2.50/testdb.php看到下图表示跟mysql服务整合成功
四.安装postfix并进行配置
安装postfix之前首先停止掉系统自带的sendmail服务(前面已经停过)
1.安装配置dns
[root@localhost ~]# yum install bind bind-chroot caching-nameserver
[root@localhost ~]# cd /var/named/chroot/etc/
[root@localhost etc]# ll
总计 32
-rw-r--r-- 1 root root 405 03-22 16:58 localtime
-rw-r----- 1 root named 1230 2009-07-30 named.caching-nameserver.conf
-rw-r----- 1 root named 955 2009-07-30 named.rfc1912.zones
-rw-r----- 1 root named 113 03-23 05:05 rndc.key
[root@localhost etc]# cp -p named.caching-nameserver.conf named.conf
[root@localhost etc]# vim named.conf
[root@localhost etc]# vim named.rfc1912.zones
生成数据库文件
[root@localhost etc]# cd ../var/named/
[root@localhost named]# ll
总计 72
drwxrwx--- 2 named named 4096 2004-08-26 data
-rw-r----- 1 root named 198 2009-07-30 localdomain.zone
-rw-r----- 1 root named 195 2009-07-30 localhost.zone
-rw-r----- 1 root named 427 2009-07-30 named.broadcast
-rw-r----- 1 root named 1892 2009-07-30 named.ca
-rw-r----- 1 root named 424 2009-07-30 named.ip6.local
-rw-r----- 1 root named 426 2009-07-30 named.local
-rw-r----- 1 root named 427 2009-07-30 named.zero
drwxrwx--- 2 named named 4096 2004-07-27 slaves
[root@localhost named]# cp -p localhost.zone a.org.db
[root@localhost named]# vim a.org.db
[root@localhost named]# vim /etc/resolv.conf
修改主机名
[root@localhost named]# vim /etc/sysconfig/network
重启系统
[root@localhost ~]# init 6
重新启动dns
[root@mail ~]# service named start
启动 named: [确定]
[root@mail ~]# chkconfig --add named
[root@mail ~]# chkconfig named on
[root@mail ~]# dig -t mx a.org
Dns安装完成
2.启动mysql数据库,并给mysql的root用户设置密码“redhat”
[root@mail ~]# service mysqld start
[root@mail ~]# chkconfig mysqld on
[root@mail ~]# netstat -tupln|grep mysql
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 3249/mysqld
[root@mail ~]# mysqladmin -uroot password 'redhat
3.启动saslauthd服务,并将其加入到自动启动队列
[root@mail ~]# service saslauthd start
启动 saslauthd: [确定]
[root@mail ~]# chkconfig saslauthd on
4.编译安装postfix软件
[root@mail ~]# groupadd -g 1200 postdrop
[root@mail ~]# groupadd -g 1000 postfix
[root@mail ~]# useradd -M -u 1000 -g postfix -G postdrop -s /sbin/nologin postfix #创建宿主目录 附属组
[root@mail ~]# tar -zxvf postfix-2.6.2.tar.gz -C /usr/local/src/
[root@mail ~]# cp postfix-2.6.2-vda-ng.patch.gz /usr/local/src/ #补丁文件,用以支持虚拟用户设置配额
[root@mail ~]# cd /usr/local/src/
[root@mail src]# ll
总计 52
drwxr-xr-x 12 cms 500 4096 03-23 02:59 httpd-2.2.19
drwxrwxrwx 39 7155 wheel 4096 03-23 03:06 mysql-5.0.81
drwxr-xr-x 17 postfix postfix 4096 03-23 03:39 php-5.3.7
drwxr-xr-x 16 1001 wheel 4096 2009-05-20 postfix-2.6.2
-rw-r--r-- 1 root root 12661 03-23 04:19 postfix-2.6.2-vda-ng.patch.gz
[root@mail src]# gunzip postfix-2.6.2-vda-ng.patch.gz
[root@mail src]# cd postfix-2.6.2
[root@mail postfix-2.6.2]# patch -p1 <../postfix-2.6.2-vda-ng.patch #打补丁(注意此处-p1,后面是数字1而不是字母l)
以上显示表示补丁已经打上。
[root@mail postfix-2.6.2]# make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/local/mysql/include/mysql -DUSE_SASL_AUTH_DUSE_CYRUS_SASL -I/usr/local/include/sasl' 'AUXLIBS=-L/usr/local/mysql/lib/mysql -lmysqlclient -lz -lm -L/usr/local/lib/sasl2 -lsasl2'
[root@mail postfix-2.6.2]# make
[root@mail postfix-2.6.2]# make install
安装过程中会出现互动提问,直接选择默认(按“Enter”)设置即可
5.编辑postfix主配置文件
[root@mail postfix-2.6.2]# vim /etc/postfix/main.cf
Inet_interfaces = all #默认设置
myhostname = mail.a.org #主机名
mydomain = a.org #邮件域名
myorigin = $mydomain #外发邮件时发件人地址中的邮件域名
[root@mail postfix-2.6.2]# postfix check #检查配置
[root@mail postfix-2.6.2]# postfix start #启动postfix
postfix/postfix-script: starting the Postfix mail system
6.编辑postfix的启动脚本
[root@mail ~]# mkdir cms
[root@mail ~]# cd cms/
[root@mail cms]# cp /mnt/cdrom/Server/postfix-2.3.3-2.1.el5_2.i386.rpm ./
[root@mail cms]# ll
总计 3652
-r--r--r-- 1 root root 3734257 03-23 05:07 postfix-2.3.3-2.1.el5_2.i386.rpm
[root@mail cms]# rpm2cpio postfix-2.3.3-2.1.el5_2.i386.rpm |cpio -id
16333 blocks
[root@mail cms]# ll
总计 3664
drwxr-xr-x 5 root root 4096 03-23 05:08 etc
-r--r--r-- 1 root root 3734257 03-23 05:07 postfix-2.3.3-2.1.el5_2.i386.rpm
drwxr-xr-x 7 root root 4096 03-23 05:08 usr
drwxr-xr-x 3 root root 4096 03-23 05:08 var
[root@mail cms]# cd etc/rc.d/init.d/
[root@mail init.d]# ll
总计 4
-rwxr-xr-x 1 root root 2404 03-23 05:08 postfix
[root@mail init.d]# cp postfix /etc/init.d/postfix
[root@mail init.d]# service postfix start
启动 postfix: [确定]
将其加入开机自启动
[root@mail init.d]# chkconfig --add postfix
[root@mail init.d]# chkconfig postfix on
[root@mail init.d]#
7.连接postfix,验正服务启动状况
[root@mail init.d]# telnet 192.168.2.50 25
Trying 192.168.2.50...
Connected to 192.168.2.50 (192.168.2.50).
Escape character is '^]'.
220 mail.a.org ESMTP Postfix
EHLO mail.a.org #此行为输入的内容
250-mail.a.org
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
250 2.1.0 Ok
250 2.1.5 Ok
data #此行为输入的内容
354 End data with <CR><LF>.<CR><LF>
111111111111111111111 #此行为输入的内容
.
250 2.0.0 Ok: queued as EC1D358197
quit #此行为输入的内容
221 2.0.0 Bye
Connection closed by foreign host.
You have new mail in /var/spool/mail/root
[root@mail init.d]# mail
五.安装dovecot
1.安装
[root@mail ~]# useradd -M -s /sbin/nologin dovecot
[root@mail ~]# tar -zxvf dovecot-1.1.4.tar.gz -C /usr/local/src/
[root@mail ~]# cd /usr/local/src/dovecot-1.1.4/
[root@mail dovecot-1.1.4]# ./configure --sysconfdir=/etc --with-mysql
[root@mail dovecot-1.1.4]# make
[root@mail dovecot-1.1.4]# make install
[root@mail dovecot-1.1.4]# cp /etc/dovecot-example.conf /etc/dovecot.conf
[root@mail dovecot-1.1.4]# vim /etc/dovecot.conf
ssl_disable = yes #禁用SSL机制
protocols = pop3 imap #指定邮局协议
disable_plaintext_auth = no #允许明文密码认证
mail_location = maildir:~/Maildir #设置邮件存储格式和位置
#vim /etc/pam.d/dovecot #创建pam认证文件
auth required pam_nologin.so
auth include system-auth
account include system-auth
session include system-auth
[root@mail dovecot-1.1.4]# vim /etc/pam.d/dovecot
[root@mail dovecot-1.1.4]# usr/local/sbin/dovecot -c /etc/dovecot.conf #启动(把这句话写入开机脚本)
2.测试接收服务器dovecot
[root@mail dovecot-1.1.4]# telnet localhost 110
至此dovecot安装成功。
六.安装Webmail软件
[root@mail ~]# tar -zxvf squirrelmail-webmail-1.4.22.tar.gz -C /usr/local/apache/htdocs/
[root@mail ~]# cd /usr/local/apache/htdocs/
[root@mail htdocs]# mv squirrelmail-webmail-1.4.22 webmail
[root@mail htdocs]# cd webmail/
[root@mail webmail]# mkdir -p attach data
[root@mail webmail]# chown -R daemon:daemon attach/ data/
[root@mail webmail]# chmod 730 attach/
[root@mail webmail]# cp config/config_default.php config/config.php
[root@mail webmail]# vim config/config.php
$squirrelmail_default_language = ‘zh_CN’;
$default_charset = ‘zh_CN.UTF-8’;
$domain = ‘wisefund.com’;
$smtpServerAddress = ‘localhost’; #设置发信服务器地址
$smtpPort = 25; #设置发信服务器端口
$imap_server_type = 'dovecot'; #设置收信服务器软件
$imapPort = 143; #设置收信服务器端口
$data_dir = '/usr/local/apache2/htdocs/webmail/data/';
$attachment_dir = '/usr/local/apache2/htdocs/webmail/attach/';
重启服务进行测试
[root@mail webmail]# /usr/local/apache/bin/apachectl restart
输入下面地址来测试
http://192.168.2.50/webmail
七.初始化 extman 软件
1.初始化extman
[root@mail ~]# service mysqld restart
[root@mail ~]# tar -zxvf extman-0.2.5.tar.gz -C /usr/local/src/
[root@mail src]# cd /usr/local/src/extman-0.2.5/docs
[root@mail docs]# mysql -u root -p < extmail.sql #需要输入密码,我的root的密码是redhat
[root@mail docs]# mysql -u root -p <init.sql
2.配置Postfix
[root@mail docs]# postconf -m |grep mysql #返回值有mysql,说明可以支持mysql 数据库的查询表
让postfix支持虚拟域和虚拟用户
[root@mail ~]# vim /etc/postfix/main.cf
#mydestination = $mydomain, $myhostname #该行需要注释掉
virtual_mailbox_base = /mailbox #指定虚拟邮箱存储目录的路径起点
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf #指定虚拟邮件用户对应的别名文件位置
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps. #指定记录虚拟邮箱地址与存储位置对应关系的映射文件位置
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf #设置postfix服务器可以接收的虚拟邮件域的域名
virtual_uid_maps = static:1000 #设置所有虚拟邮件用户映射的本地用户的UID号
virtual_gid_maps = static:1000 #设置所有虚拟邮件用户映射的本地组的GID 号
#cd /usr/local/src/extman-0.2.5/docs
#cp mysql_virtual_* /etc/postfix/ #在上面的三行配置中指定了这三个文件
[root@mail docs]# cp mysql* /etc/postfix/
[root@mail docs]# mysql -u root -p
mysql> GRANT all privileges on extmail.* TO extmail@localhost IDENTIFIED BY 'extmail';
mysql> GRANT all privileges on extmail.* TO
[email protected] IDENTIFIED BY 'extmail';
mysql> FLUSH PRIVILEGES; #让设置的内容生效
八.虚拟用户设置SMTP发信认证
1.安装
[root@mail ~]# tar -jxvf courier-authlib-0.62.4.tar.bz2 -C /usr/local/src/
[root@mail ~]# cd /usr/local/src/courier-authlib-0.62.4/
[root@mail courier-authlib-0.62.4]# ./configure --prefix=/usr/local/courier-authlib --without-stdheaderdir --with-authmysql --with-redhat --with-mysql-libs=/usr/local/mysql/lib/mysql --with-mysql-includes=/usr/local/mysql/include/mysql
[root@mail courier-authlib-0.62.4]# make
[root@mail courier-authlib-0.62.4]# make install
[root@mail courier-authlib-0.62.4]# make install-configure #生成默认配置文件authmysqlrc 和 authdaemonrc
[root@mail courier-authlib-0.62.4]# vim /etc/ld.so.conf #添加courier-authlib的库文件路径
include ld.so.conf.d/*.conf
/usr/local/mysql/lib/mysql
/usr/local/courier-authlib/lib/courier-authlib
[root@mail courier-authlib-0.62.4]# cd /usr/local/courier-authlib/etc/authlib/
[root@mail authlib]# cp authmysqlrc authmysqlrc.bak
[root@mail authlib]# vim authmysqlrc
MYSQL_SERVER #localhost 数据库服务器位置
MYSQL_USERNAME #extmail 数据库管理员账户
MYSQL_PASSWORD #extmail 数据库管理员账户密码
MYSQL_SOCKET #/tmp/mysql.sock 文件位置
MYSQL_DATABASE #extmail 虚拟用户数据库
MYSQL_USER_TABLE #mailbox 从mailbox表获得邮件账户信息
MYSQL_CRYPT_PWFIELD #password 从password字段获得账户密码
MYSQL_UID_FIELD #uidnumber 从uidnumber字段获得映射的本地用户UID
MYSQL_GID_FIELD #gidnumber 从gidnumber字段获得映射的本地组GID
MYSQL_LOGIN_FIELD #username 从username字段获得账户名称,带@后缀
MYSQL_HOME_FIELD #concat('/mailbox/',homedir)合并出用户的宿主目录路径
MYSQL_NAME_FIELD #name 从name 字段获得账户名称,不带@后缀
MYSQL_MAILDIR_FIELD #concat('/mailbox/',maildir)合并出用户的邮件存储路径
2.设置启动脚本
[root@mail authlib]# cd /usr/local/src/courier-authlib-0.62.4/
[root@mail courier-authlib-0.62.4]# cp courier-authlib.sysvinit /etc/init.d/courier-authlib
[root@mail courier-authlib-0.62.4]# chmod 755 /etc/rc.d/init.d/courier-authlib
[root@mail courier-authlib-0.62.4]# chkconfig courier-authlib on
[root@mail courier-authlib-0.62.4]# chkconfig --add courier-authlib
[root@mail courier-authlib-0.62.4]# service courier-authlib start
修改Cyrus sasl 设置
[root@mail courier-authlib-0.62.4]# vim /usr/lib/sasl2/smtpd.conf
pwcheck_method:authdaemond
authdaemond_path:/usr/local/courier-authlib/var/spool/authdaemon/socket
3.修改Dovecot配置
[root@mail courier-authlib-0.62.4]# vim /etc/dovecot.conf
修改如下:
mail_location = maildir:/mailbox/%d/%n/Maildir
####################
3auth default {
mechanisms = plain
passdb sql {
args = /etc/dovecot-mysql.conf
}
userdb sql {
args = /etc/dovecot-mysql.conf
}
4.建立数据查询配置文件
[root@mail courier-authlib-0.62.4]# vim /etc/dovecot-mysql.conf
将下面的这些内容添加到配置文件中:
driver = mysql
connect = host=localhost dbname=extmail user=extmail password=extmail
default_pass_scheme = CRYPT #数据库中存储的密码串的加密算法
password_query = SELECT username AS user,password AS password FROM mailbox WHERE username = ‘%u’ #查询用户密码的语句
user_query = SELECT maildir, uidnumber AS uid, gidnumber AS gid FROM mailbox WHERE username = ‘%u’ #查询用户身份语句
[root@mail courier-authlib-0.62.4]# vim /etc/postfix/main.cf
home_mailbox = Maildir/
九.建立虚拟用户
1.建立邮箱目录并调整权限
[root@mail ~]# mkdir -p /mailbox/extmail.org/postmaster/Maldir
[root@mail ~]# cd /mailbox/extmail.org/postmaster/Maildir
[root@mail Maildir]# chown -R postfix:postfix /mailbox
[root@mail ~]# dovecot #启动服务虚拟用户测试
2.虚拟用户测试
确认authlib服务
[root@mail ~]# /usr/local/courier-authlib/sbin/authtest -s login
[email protected] extmail
Authentication succeeded. #成功提示信息
(其实这时候如果验证不通过,后面的虚拟用户也可以建立)
Home Directory: /mailbox/extmail.org/postmaster
Maildir: /mailbox/extmail.org/postmaster/Maildir/
Quota: (none)
Encrypted Password: $1$phz1mRrj$3ok6BjeaoJYWDBsEPZb5C0
Cleartext Password: extmail
Options: (none)
十.ExtMail平台
1.先安装三个依赖包
[root@mail ~]# tar -zxvf Unix-Syslog-1.1.tar.gz -C /usr/local/src/
[root@mail ~]# cd /usr/local/src/Unix-Syslog-1.1/
[root@mail Unix-Syslog-1.1]# perl Makefile.PL
[root@mail Unix-Syslog-1.1]# make
[root@mail Unix-Syslog-1.1]# make install
[root@mail ~]# tar -zxvf DBI-1.616.tar.gz -C /usr/local/src/
[root@mail ~]# cd /usr/local/src/DBI-1.616/
[root@mail DBI-1.616]# perl Makefile.PL
[root@mail DBI-1.616]# make
[root@mail DBI-1.616]# make install
[root@mail ~]# tar -zxvf DBD-mysql-4.020.tar.gz -C /usr/local/src/
[root@mail ~]# cd /usr/local/src/DBD-mysql-4.020/
[root@mail DBD-mysql-4.020]# perl Makefile.PL
[root@mail DBD-mysql-4.020]# make
[root@mail DBD-mysql-4.020]# make install
2.安装extmail
[root@mail ~]# tar -zxvf extmail-1.0.5.tar.gz -C /usr/local/apache/htdocs/
[root@mail ~]# cd /usr/local/apache/htdocs/
[root@mail htdocs]# mv extmail-1.0.5 extmail
[root@mail extmail]# chown -R postfix:postfix cgi
[root@mail extmail]# cp webmail.cf.default webmail.cf
3.修改主配置文件
[root@mail extmail]# vim webmail.cf
SYS_CONFIG = /usr/local/apache2/htdocs/extmail/ #程序根目录
SYS_LANGDIR = /usr/local/apache2/htdocs/extmail/lang #语言包文件目录
SYS_TEMPLDIR = /usr/local/apache2/htdocs/extmail/html #系统模版目录
SYS_MAILDIR_BASE = /mailbox #邮件存储目录
SYS_MYSQL_USER = extmail #访问mysql数据库的用户
SYS_MYSQL_PASS = extmail #访问mysql数据库的用户的密码
SYS_MYSQL_DB = extmail #使用数据库的名称
SYS_MYSQL_HOST = localhost #数据库服务器地址
SYS_MYSQL_SOCKET = /tmp/mysql.sock #数据库套接文件位置
4.修改apache服务,添加虚拟主机
[root@mail ~]# vim /etc/httpd/httpd.conf
将下面的内容添加到配置文件中:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName mail.wisefund.com
DocumentRoot /usr/local/apache2/htdocs/extmail/html/
ScriptAlias /extmail/cgi/ "/usr/local/apache2/htdocs/extmail/cgi/"
Alias /extmail "/usr/local/apache2/htdocs/extmail/html/"
</VirtualHost>
User postfix 找到 User 该用户为postfix
Group postfix 找到 Group 该组为postfix
这里由于前面我们并没有启用Suexec 所以我们没有在虚拟主机中添加 SuexecUerGroup postfix postfix
重启http服务
[root@mail ~]# /usr/local/apache2/bin/apachectl restart
十一.安装Extman
1.先安装四个依赖包
[root@mail ~]# tar -zxvf GD-2.46.tar.gz -C /usr/local/src/
[root@mail ~]# cd /usr/local/src/GD-2.46/
[root@mail GD-2.46]# perl Makefile.PL
[root@mail GD-2.46]# make
[root@mail GD-2.46]# make install
[root@mail ~]# tar -zxvf File-Tail-0.99.3.tar.gz -C /usr/local/src/
[root@mail ~]# cd /usr/local/src/File-Tail-0.99.3
[root@mail File-Tail-0.99.3]# perl Makefile.PL
[root@mail File-Tail-0.99.3]# make
[root@mail File-Tail-0.99.3]# make install
[root@mail ~]# rpm -ivh rrdtool-1.2.23-3.el5.i386.rpm
[root@mail ~]# rpm -ivh rrdtool-perl-1.2.23-3.el5.i386.rpm
2.安装extman
[root@mail ~]# tar -zxvf extman-0.2.5.tar.gz -C /usr/local/apache/htdocs/
[root@mail ~]# cd /usr/local/apache/htdocs/
[root@mail htdocs]# mv extman-0.2.5 extman
[root@mail htdocs]# cd extman/
[root@mail extman]# chown -R postfix:postfix cgi
[root@mail extman]# mkdir /tmp/extman
[root@mail extman]# chown -R postfix:postfix /tmp/extman
3.调整apache主配文件,添加extman相关目录别名
在apache的主配置文件中Extmail的虚拟主机部分,添加如下两行:
ScriptAlias /extman/cgi /var/www/extsuite/extman/cgi
Alias /extman /var/www/extsuite/extman/html
[root@mail ~]# vim /etc/httpd/conf/httpd.conf
重启http服务
[root@mail ~]# /usr/local/apache2/bin/apachectl restart
4.在客服端访问测试
User1给user2发信:
登陆user2查看是否收到邮件
十二.设置邮件系统的图形化日志信息
[root@mail ~]# ln -sf
/usr/local/apache/htdocs/extman/addon/mailgraph_ext/mailgraph-init /usr/sbin
[root@mail ~]# ln -sf
/usr/local/apache/htdocs/extman/addon/mailgraph_ext/qmonitor-init /usr/sbin
[root@mail ~]# cp -a
/usr/local/apache/htdocs/extman/addon/mailgraph_ext /usr/local
[root@mail ~]# mailgraph-init start
[root@mail ~]# qmonitor start
[root@mail ~]# echo "usr/sbin/mailgraph-init start">> /etc/rc.d/rc.local
[root@mail ~]# echo "usr/sbin/qmonitor-init start">> /etc/rc.d/rc.local
十三.垃圾邮件过滤
1.根据客户端的主机名/地址过滤邮件
[root@mail ~]# vim /etc/postfix/main.cf
smtpd_client_restrictions = check_client_access hash:/etc/postfix/access
[root@mail ~]# vim /etc/postfix/access
192.168.4 REJECT
192.168.4.1 OK
bbc.com REJECT
[root@mail ~]# postmap /etc/postfix/access
2.根据客户机HELO 信息中的主机名地址过滤邮件
[root@mail ~]# vim /etc/postfix/main.cf
添加下面的两行内容
smtpd_helo_required = yes
smtpd_helo_restrictions = reject_invalid_hostname
[root@mail ~]# postfix reload
3.根据发件人的地址过滤邮件
[root@mail ~]# vim /etc/postfix/main.cf
在配置文件中添加下面内容
smtpd_sender_login_maps =mysql:/etc/postfix/mysql_virtual_sender_maps.cf,mysql:/etc/postfix/mysql_virtual_alias_maps.cf
smtpd_sender_restrictions=permit_mynetworks,reject_sender_login-mismatch,reject_non_fqdn_sender,reject_unknown_sender_domain,check_sender_accesshash:/etc/postfix/sender_access
[root@mail ~]# vim /etc/postfix/sendder_access
添加到文件中
marketing@ REJECT
fake.aptech.com REJECT
[root@mail ~]# postmap /etc/postfix/sender_access
4.根据收件人的地址过滤邮件
[root@mail ~]# vim /etc/postfix/main.cf
添加的内容
smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination,reject_non_fqdn_recipient,reject_unknown_recipient_domain
重启postfix
[root@mail ~]# service postfix restart
5.基于邮件内容的过滤
(1)安装并配置MailScanner 扫描调度工具
[root@mail ~]# tar -zxvf MailScanner-4.84.3-1.rpm.tar.gz -C /usr/local/src/
[root@mail ~]# cd /usr/local/src/MailScanner-4.84.3-1/
[root@mail MailScanner-4.84.3-1]# ./install.sh
(2)修改配置文件MailScanner
[root@mail MailScanner-4.84.3-1]# vim /etc/MailScanner/MailScanner.conf
Run As User = postfix
Run As Group = postfix
Incoming Queue Dir = /var/spool/postfix/hold
Outgoing Queue Dir = /var/spool/postfix/incoming
MTA =postfix
Required SpamAssassin Score =7
High SpamAssassin Score = 10
Spam Actions = deliver header “X-Spam-Status: Yes”
在文件中找到这些内容并修改成为上面内容。
(3)配置Postfix 支持调用MailScanner:
[root@mail ~]# vim /etc/postfix/main.cf
header_checks = regexp: /etc/postfix/header_checks #启用这行内容
[root@mail ~]# vim /etc/postfix/header_checks
/^Received:/ HOLD #在420的位置添加这行内容
(4)调整邮件过滤队列的目录属主、属组,并启动MailScanner 服务程序:
[root@mail ~]# chown -R postfix.postfix /var/spool/MailScanner/incoming
[root@mail ~]# chown -R postfix.postfix /var/spool/MailScanner/quarantine
[root@mail ~]# service MailScanner start
[root@mail ~]# chkconfig MailScanner on
(5)安装并配置SpamAssassin 垃圾邮件过滤器
[root@mail ~]# cd /mnt/cdrom/Server/
[root@mail Server]# yum install spamassassin-3.2.5-1.el5.i386.rpm
[root@mail ~]# service spamassassin start
[root@mail ~]# chkconfig spamassassin on
(6)安装并配置F-Port 病毒查杀软件
安装F-Port 软件包安装过程中出现提示是按回车键接受默认设置
[root@mail ~]# tar -zxvf fp-Linux-i686-ws.tar.gz -C /opt/
[root@mail ~]# cd /opt/f-prot/
[root@mail f-prot]# ./install-f-prot.pl
升级F-Port 病毒库(服务器要能够访问Internet 互联网)
[root@localhost f-prot]# /opt/f-prot/fpupdate
[root@localhost f-prot]# crontab -e #计划任务
[root@localhost f-prot]# service crond restart
[root@localhost f-prot]# chkconfig crond on
十四.Extman后台管理设置
下面是邮件日志分析图