啥也没写
分类: LINUX
2009-10-27 20:09:52
安装php 组件:
yum -y install php-mcrypt
yum -y install php-mhash
yum -y install libmcrypt
yum -y install libmcrypt-devel
yum -y install libmhash
yum -y install libmhash-devel
安装AMP:
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@Centos5 ~]#mkdir extmail
[root@Centos5 ~]#cd extmail
到 www.extmail.org下载软件extman extmail slockd
导入extman 后台数据库
[root@Centos5 extmail]# tar zxf extman-1.1.0.tar.gz
[root@localhost ~]# cd extman-1.0.0/docs/
[root@Centos5 docs]# mysql –u root -p < extmail.sql
Enter password:
[root@localhost docs]# mysql -uroot -p < init.sql
Enter password
安装 authlib
[root@Centos5 extmail]#cd ../..
[root@Centos5 extmail]# yum -y install postgresql-devel expect libtool-ltdl-devel
[root@Centos5 extmail]#rpm –ivh courier-authlib-0.62.4-1.i386.rpm
[root@Centos5 extmail]#rpm –ivh courier-authlib-devel-0.62.4-1.i386.rpm
[root@Centos5 extmail]#rpm –ivh courier-authlib-mysql-0.62.4-1.i386.rpm
配置authlibdaemon
[root@Centos5 extmail]#cd /etc/authlib
[root@Centos5 extmail]#mv authdaemonrc authdaemonrc.backup
[root@Centos5 extmail]#vi authdaemonrc
输入下面内容:
authmodulelist="authmysql"
authmodulelistorig="authmysql"
daemons=10
authdaemonvar=/var/spool/authdaemon
DEBUG_LOGIN=2
DEFAULTOPTIONS="wbnodsn=1"
LOGGEROPTS=""
配置 authmysqlrc
[root@Centos5 extmail]#mv authmysqlrc authmysqlrc.backup
[root@Centos5 extmail]#vi authmysqlrc
输入下面内容:
MYSQL_SERVER localhost
MYSQL_USERNAME extmail
MYSQL_PASSWORD extmail
MYSQL_PORT 3306
MYSQL_SOCKET /var/lib/mysql/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)'
## “ \ ” 这个符号是连接符号,不是换行符, 1 行写不下,所以用这个符号连接下面一行,linux 下可以识别这个符号。
启动authlib
[root@Centos5 extmail]#service courier-authlib start
[root@Centos5 extmail]#chmod 777 /var/spool/authdaemon
安装courier-imap
[root@Centos5 extmail]#yum –y install fam-devel openldap-servers
(需要这些组件,这里提醒下,最好不要用yum 删除软件包,因为它会把关联的包一起删除,很危险)
安装courier-imap 包
[root@Centos5 extmail]#rpm –ivh courier-imap-4.5.1-1.i386.rpm
启动
[root@Centos5 extmail]#service courier-imap start
安装 cyrus-sasl
[root@Centos5 extmail]#rpm -e --nodeps cyrus-sasl-devel cyrus-sasl-plain cyrus-sasl cyrus-sasl-lib (先要卸载掉原来的包,重新安装)
[root@Centos5 extmail]#rpm -ihv cyrus-sasl-lib-2.1.22-15.i386.rpm
[root@Centos5 extmail]#rpm -ihv cyrus-sasl-2.1.22-15.i386.rpm
[root@Centos5 extmail]#rpm -ihv cyrus-sasl-plain-2.1.22-15.i386.rpm
[root@Centos5 extmail]#rpm -ivh cyrus-sasl-devel-2.1.22-15.i386.rpm
配置sasl2
vi /usr/lib/sasl2/smtpd.conf
输入下面内容:
pwcheck_method:authdaemond
log_level:3
mech_list:PLAIN LOGIN
authdaemond_path:/var/spool/authdaemon/socket
安装postfix
[root@Centos5 extmail]#rpm –ivh postfix-2.6.1-1.rhel5.i386.rpm
切换系统默认的MTA
[root@Centos5 extmail]#alternatives --config mta (选择2,postfix)
[root@Centos5 extmail]#rpm –e sendmail
[root@Centos5 extmail]#cd /usr/sbin/
[root@Centos5 extmail]#mv sendmail sendmail.bak
[root@Centos5 extmail]#newaliases
[root@Centos5 extmail]#ln -s sendmail.postfix sendmail
配置Postfix:
[root@Centos5 extmail]# cd /etc/postfix/
[root@Centos5 postfix]# mv main.cf main.cf.bk
[root@Centos5 postfix]# vi 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 = Centos5.com
mydomain = bitauto.com
mydestination = $myhostname
smtpd_banner = Centos5.com 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.c
f
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_hostnam
E
上面的:
myhostname = Centos5.com (hostname 要符合FQDN 的格式,就是你至少要有一个点比如name.name不然的话就会出错)
mydomain = bitauto.com
mydomain 改成自己公司对应的根域名, myhostname 可以任意,符合域名格式就可以。
复制 extman/docs 目录下所有 .cf 文件到/etc/postfix
[root@Centos5 extmail]# cp extman-1.0.0/docs/mysql_virtual_*.cf /etc/postfix/
因为配置文件的用户、密码与刚开始导入extmail 数据库时一样,所以不用修改。
启动postfix
[root@Centos5 extmail]# service postfix start
安装maildrop
安装关联组件
[root@Centos5 extmail]# yum -y install pcre-devel
[root@Centos5 extmail]#rpm –ivh maildrop-2.2.0-1.i386.rpm \
>maildrop-debuginfo-2.2.0-1.i386.rpm \
>maildrop-devel-2.2.0-1.i386.rpm \
>maildrop-man-2.2.0-1.i386.rpm
添加虚似用户及创建目录
[root@Centos5 extmail]#groupadd -g 1000 vgroup
[root@Centos5 extmail]#useradd -g 1000 –u 1000 –s /sbin/nologin –d /dev/null vuser
配置master.cf 文件
[root@Centos5 extmail]#vi /etc/postfix/master.cf
在最后面加入下面内容:
maildrop unix - n n - - pipe
flags=DRhu user=vuser argv=/usr/bin/maildrop -d ${user}@${nexthop} ${recipient} ${user} ${extension} ${nexthop} #flags前面有两个空格
创建邮件存储目录
[root@Centos5 extmail]#mkdir -p /home/data/domains/extmail.org/postmaster
[root@Centos5 extmail]#maildirmake /home/data/domains/extmail.org/postmaster/Maildir
[root@Centos5 extmail]#chown -R vuser:vgroup /home/data/domains/
####### 上面的extmail.org 默认extmail 使用这个域名,之后你可以通过extman 修改掉。
测试maildrop
[root@Centos5 extmail]# echo "test" | maildrop -V 10 -d postmaster@extmail.org
maildrop: authlib: groupid=1000
maildrop: authlib: userid=1000
maildrop: authlib: logname=postmaster@extmail.org, home=/home/data/domains/extmail.org/postmaster, mail=/home/data/domains/extmail.org/postmaster/Maildir/
maildrop: Changing to /home/data/domains/extmail.org/postmaster
Message start at 0 bytes, envelope sender=postmaster@extmail.org
maildrop: Attempting .mailfilter
maildrop: Delivery complete.
出现上以信息说明authlib,maildrop 工作正常
测试pop3
[root@Centos5 extmail]# telnet localhost 110
Trying 127.0.0.1...
Connected to localhost.
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
2 6
3 6
. ############# 这里退出是用符号 点 。
retr 1
+OK 6 octets follow.
test
.
quit
+OK Bye-bye.
Connection closed by foreign host.
测试postfix
[root@Centos5 extmail]# perl -MMIME::Base64 -e 'print encode_base64("postmaster\@extmail.org");'
cG9zdG1hc3RlckBleHRtYWlsLm9yZw==
[root@Centos5 extmail]# perl -MMIME::Base64 -e 'print encode_base64("extmail");'
ZXh0bWFpbA==
[root@Centos5 extmail]# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 Centos5.com ESMTP Mail System
helo demo
250 Centos5.com
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.
安装extman/extmail
A、配置apache
修改/etc/httpd/conf/httpd.conf,设置虚拟账户为vuser:group 将下面的选项改为:
user vuser
group vgroup
[root@Centos5 extmail]# cd /etc/httpd/conf.d/
[root@Centos5 extmail]# vi extmail.conf
输入下面的内容:
Alias /extman/cgi/ /var/www/extsuite/extman/cgi/
Alias /extman /var/www/extsuite/extman/html/
SetHandler cgi-script
Options +ExecCGI
# config for ExtMail
Alias /extmail/cgi/ /var/www/extsuite/extmail/cgi/
Alias /extmail /var/www/extsuite/extmail/html/
SetHandler cgi-script
Options +ExecCGI
[root@Centos5 extmail]# mkdir /var/www/extsuite
[root@Centos5 extmail]#tar zxf extmail-1.0.5.tar.gz
[root@Centos5 extmail]# cp –r extmail-1.1.0 /var/www/extsuite/extmail
[root@Centos5 extmail]# cp –r extman-1.0.0 /var/www/extsuite/extmail
配置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 = extmail
SYS_MYSQL_PASS = extmail
配置extman 参数
[root@localhost extmail]# cd /var/www/extsuite/extman/
修改webman.cf 下面的选项为邮件目录:
SYS_MAILDIR_BASE = /home/data/domains
创建session 目录
[root@localhost extman]# mkdir /tmp/{extman,extmail}
[root@localhost extman]# chown vuser:vgroup /tmp/ext*
配置后台日志分析工具
[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
启动后台进程
[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
Starting mail statistics grapher: mailgraph_ext
访问extmail/extman
打开浏览器,输入 注意:your_ip_address 为你实际的ip
第一个测试用户为:postmaster 密码:extmail 域:extmail
打开浏览器,输入
用户为:root@extmail.org 密码为:extmail*123*
注意:进入系统后要修改密码及找回密码的提示问题、答案。
安装slockd
slockd 是一个基于策略的垃圾邮件软件,很多用户反映使用后,反垃圾效果非常明显,但是有部分用户由于对该软件的使用,特性不了解,而产生了很多麻烦。
所在在此建议,如果你对该软件不了解,或者系统里的垃圾邮件少,可以暂时不安装。
[root@Centos5 extmail]# tar zxvf slockd-0.99.tar.gz
[root@Centos5 extmail]# cp -r slockd /usr/local/slockd
[root@Centos5 extmail]#cd /usr/local/slockd/
将下面的内容加入/etc/rc.local
[root@Centos5 extmail]#/usr/local/slockd/slockd-init start
[root@Centos5 slockd]#vi /etc/postfix/main.cf 修改为
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination,reject_unauth_pipelining,reject_invalid_hostname,check_policy_service inet:127.0.0.1:10030
重载postfix 配置文件
[root@localhost slockd]# service postfix reload
这里注意下,apache 改变运行id 后,php session 功能将会出现问题,因为session 的存储目录权限没有跟着改变为新的,所以phpmyadmin 等就会提示错误。
只要执行下面的命令即可解决问题。
[root@localhost slockd]# chown -R vuser:vgroup /var/lib/php/session/