部分軟體簡介:
1、AMP ---apache(web服務) 、mysql(資料庫)、php(非必需) 的簡稱
2、postfix --mta 郵件系統核心
3、courier-authlib--一個為courier-imap,maildrop,sasl2 提供用戶信息的後台進程序
4、courier-imap --提供pop3,pop3s,imap,imaps 服務的程序
5、amavisd-new --提供內容過濾
6、clamav -- 著名的殺毒軟體
7、extmail --一個著名的webmail程序
8、extman --與extmail集成的後台管理程序
安裝環境:
centos 5.4
域名機器名:mail.uucun.lan
域名:uucun.lan
1、安裝AMP
[root@localhost ~]# yum -y install httpd httpd-devel mysql mysql-devel mysql-server php php-xml php-cli php-pdo php-mbstring php-mcrypt php-gd php-common php-devel php-mysql
修改啟動配置並啟動
[root@localhost ~]# chkconfig --level 345 mysqld on
[root@localhost ~]# chkconfig --level 345 httpd on
[root@localhost ~]# service mysqld start
[root@localhost ~]# service httpd start
2、導入extman 後台資料庫
[root@localhost ~]# tar zxf extman-0.2.5b1.tar.gz
[root@localhost ~]# cd extman-0.2.5b1/docs/
[root@localhost docs]# mysql -uroot -p <extmail.sql
Enter password:
[root@localhost docs]# mysql -uroot -p <init.sql
Enter password:
如何使用了phpmyadmin改了root 密碼,記得輸入密碼,如果密碼為空,請按回車.
3、安裝authlib
A、安裝依懶的包
[root@localhost ~]# yum -y install postgresql-devel expect libtool-ltdl-devel
B、安裝生成的rpm
[root@localhost i386]# rpm -ivh courier-authlib-0.62.0-1.i386.rpm
[root@localhost i386]# rpm -ivh courier-authlib-devel-0.62.0-1.i386.rpm
D、配置authmysqlrc
[root@localhost authlib]# mv authmysqlrc authmysqlrc.bak
[root@localhost authlib]# vim authmysqlrc
輸入下面的內容:
MYSQL_SERVER localhost
MYSQL_USERNAME root #這裡需要輸入對extmail資料庫有操作許可權的mysql用戶名
MYSQL_PASSWORD uusql#2010 #這裡需要輸入對extmail資料庫有操作許可權的mysql密碼
MYSQL_PORT 0
MYSQL_SOCKET /tmp/mysql.sock
MYSQL_OPT 0
MYSQL_DATABASE extmail
MYSQL_SELECT_CLAUSE SELECT username,password,"",uidnumber,gidnumber,
CONCAT('/home/data/domains/',homedir),
CONCAT('/home/data/domains/',maildir),
quota,
name
FROM mailbox
WHERE username = '$(local_part)@$(domain)'
E、啟動authlib
[root@localhost ~]# service courier-authlib start
Starting Courier authentication services: authdaemond
[root@localhost ~]# chmod 777 /var/spool/authdaemon/
4、安裝courier-imap
5、安裝cyrus-sasl
A、安裝SRPM
[root@localhost i386]# rpm -e --nodeps cyrus-sasl-devel cyrus-sasl-plain cyrus-sasl cyrus-sasl-lib (如果這些包存在)
[root@localhost i386]# rpm -ihv cyrus-sasl-lib-2.1.22-5.el5.i386.rpm
[root@localhost i386]# rpm -ihv cyrus-sasl-2.1.22-5.el5.i386.rpm
[root@localhost i386]# rpm -ihv cyrus-sasl-plain-2.1.22-5.el5.i386.rpm
B、配置sasl2
創建/usr/lib/sasl2/smtpd.conf 文件,輸入下面的內容:
pwcheck_method:authdaemond
log_level:3
mech_list:PLAIN LOGIN
authdaemond_path:/var/spool/authdaemon/socket
6、安裝postfix
A、安裝軟體包
[root@localhost i386]# rpm -ivh postfix-2.5.4-2.rhel4.i386.rpm
B、切換mta
[root@localhost i386]# alternatives --config mta (選擇2,postfix)
[root@localhost i386]# rpm -e sendmail
[root@localhost i386]# cd /usr/sbin/
[root@localhost sbin]# mv sendmail sendmail.bak
[root@localhost sbin]# newaliases
[root@localhost sbin]# ln -s sendmail.postfix sendmail
C、配置postfix
[root@localhost ~]# cd /etc/postfix/
[root@localhost postfix]# mv main.cf main.cf.bak
[root@localhost postfix]# vim main.cf
輸入下面的內容:
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
unknown_local_recipient_reject_code = 550
debug_peer_level = 2
debugger_command =
PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = /usr/share/doc/postfix-2.5.2-documentation/html
manpage_directory = /usr/share/man
sample_directory = /etc/postfix
readme_directory = /usr/share/doc/postfix-2.5.2-documentation/readme
alias_database = hash:/etc/postfix/aliases
alias_maps = hash:/etc/postfix/aliases
myhostname = mail.uucun.lan
mydomain = uucun.lan
mydestination = $myhostname
smtpd_banner = uucun.lan ESMTP Mail System
message_size_limit = 14680064
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_mailbox_base = /home/data/domains
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_limit_maps.cf
virtual_transport = maildrop:
maildrop_destination_recipient_limit = 1
#sasl
smtpd_sasl_auth_enable = yes
smtpd_sasl2_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions =
permit_mynetworks,
permit_sasl_authenticated,
reject_unauth_destination,
reject_unauth_pipelining,
reject_invalid_hostname
複製extman/docs 目錄的cf 文件到/etc/postfix
[root@localhost postfix]# cp /root/extman-0.2.5b1/docs/mysql_virtual_* .
並修改這些配置文件的用戶名為root,密碼為uusql#2010
[root@localhost postfix]# service postfix start
7、安裝maildrop
A、創建安裝maildrop rpm
[root@localhost SPECS]# yum -y install pcre-devel
E、測試pop3
[root@localhost ~]# telnet localhost 110
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
OK Hello there.
user postmaster@extmail.org
OK Password required.
pass extmail
OK logged in.
list
OK POP3 clients that break here, they violate STD53.
1 6
.
retr 1
OK 6 octets follow.
F、測試postfix
[root@localhost ~]# perl -MMIME::Base64 -e 'print encode_base64("postmaster@extmail.org");'
cG9zdG1hc3RlckBleHRtYWlsLm9yZw==
[root@localhost ~]# perl -MMIME::Base64 -e 'print encode_base64("extmail");'
ZXh0bWFpbA==
[root@localhost ~]# service postfix restart (重啟一下)
[root@localhost ~]# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 uucun.lan ESMTP Mail System
ehlo test.com
250-mail.uucun.lan
250-PIPELINING
250-SIZE 14680064
250-VRFY
250-ETRN
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
auth login
334 VXNlcm5hbWU6
cG9zdG1hc3RlckBleHRtYWlsLm9yZw==
334 UGFzc3dvcmQ6
ZXh0bWFpbA==
235 2.7.0 Authentication successful
quit
221 2.0.0 Bye
Connection closed by foreign host
8、安裝amavisd-new殺毒軟體
編輯/etc/yum.repos.d/CentOS-Base.repo 加入下面的內容:
[dag]
name=Dag RPM Repostory for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
enabled=1
gpgkey=http://dag.wieers.com/packages/RPM-GPG-KEY.dag.txt
[root@localhost ~]# yum -y install clamav clamav-db clamd clamav-devel amavisd-new
編輯/etc/amavisd.conf,修改下面的內容
$mydomain = 'uucun.lan'; # a convenient default for other settings
把下面內容去掉註釋,並修改為下面
['ClamAV-clamd',
&ask_daemon, ["CONTSCAN {}n", "/tmp/clamd.socket"],
127.0.0.1:10025 inet n - n - - smtpd
-o content_filter=
-o local_recipient_maps=
-o relay_recipient_maps=
-o smtpd_restriction_classes=
-o smtpd_helo_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=permit_mynetworks,reject
-o mynetworks=127.0.0.0/8
-o strict_rfc821_envelopes=yes
-o smtpd_error_sleep_time=0
-o smtpd_soft_error_limit=1001
-o smtpd_hard_error_limit=1000
-o receive_override_options=no_header_body_checks
在/etc/postfix/main.cf 加入下面的內容
content_filter = smtp-amavis:[localhost]:10024
[root@localhost ~]# service postfix reload
9、安裝extman/extmail
A、配置apache
修改/etc/httpd/conf/httpd.conf,將下面的選項改為:
User vuser
Group vgroup
[root@localhost ~]# cd /etc/httpd/conf.d/
[root@localhost conf.d]# vim extmail.conf
輸入下面的內容:
Alias /extman/cgi/ /var/www/extsuite/extman/cgi/
Alias /extman /var/www/extsuite/extman/html/
<Location "/extman/cgi">
SetHandler cgi-script
Options ExecCGI
</Location>
# config for ExtMail
#Alias /cgi /var/www/extsuite/extmail/cgi/
#Alias / /var/www/extsuite/extmail/html/
<Location "/extmail/cgi">
SetHandler cgi-script
Options ExecCGI
</Location>
[root@localhost ~]# mkdir /var/www/extsuite
[root@localhost ~]# tar zxf extmail-1.0.5b1.tar.gz
[root@localhost ~]# cp -r extmail-1.0.5b1 /var/www/extsuite/extmail
[root@localhost ~]# cp -r extman-0.2.5b1 /var/www/extsuite/extman
B、配置extmail參數
[root@localhost ~]# cd /var/www/extsuite/extmail/
[root@localhost extmail]# cp webmail.cf.default webmail.cf
修改webmail.cf 下面的選項
SYS_SESS_DIR = /tmp/extmail
SYS_MAILDIR_BASE = /home/data/domains
SYS_MYSQL_USER = root
SYS_MYSQL_PASS = uusql#2010
C、配置extman參數
[root@localhost extmail]# cd /var/www/extsuite/extman/
修改webman.cf 下面的選項:
SYS_MAILDIR_BASE = /home/data/domains
D、創建session 目錄
[root@localhost extman]# mkdir /tmp/{extman,extmail}
[root@localhost extman]# chown vuser:vgroup /tmp/ext*
E、配置後台日誌分析工具
[root@localhost addon]# cd /var/www/extsuite/extman/addon/
[root@localhost addon]# cp -r mailgraph_ext /usr/local/
將下面的內容加入/etc/rc.local
/usr/local/mailgraph_ext/mailgraph-init start
/usr/local/mailgraph_ext/qmonitor-init start
安裝所依懶的軟體包
[root@localhost mailgraph_ext]# yum -y install rrdtool perl-rrdtool perl-GD perl-File-Tail
F、啟動後台進程
[root@localhost mailgraph_ext]# /usr/local/mailgraph_ext/qmonitor-init start
Starting queue statistics grapher: qmonitor
[root@localhost mailgraph_ext]# /usr/local/mailgraph_ext/mailgraph-init start
G、訪問extmail/extman
打開瀏覽器,輸入http://your_ip_address/extmail 注意:your_ip_address 為你實際的ip
第一個測試用戶為:postmaster 密碼:extmail 域:extmail
打開瀏覽器,輸入http://your_ip_address/extman
extman root 用戶為:root@extmail.org 密碼為:extmail*123*
注意:進入系統后要修改密碼及找回密碼的提示問題、答案.
本文出自 「雨尚學LINUX」 博客,請務必保留此出處http://pomelo.blog.51cto.com/426249/541969
[火星人 ] 搭建Linux下郵件伺服器(extmail postfix clamav)已經有318次圍觀