商务合作加Q:411239339

extmail搭建

浏览:188次阅读
没有评论

共计 4462 个字符,预计需要花费 12 分钟才能阅读完成。

#!/bin/bash
mkdir /root/rpm
cd /root/rpm
wget http://www3.extmail.org/EMOS_1.5_x86_64.iso
yum install createrepo -y

# 加载 EMOS-1.5 的光盘, 请把 emos 的光盘放到光驱中
mkdir /mnt/EMOS
mount -o loop /root/rpm/EMOS_1.6_x86_64.iso /mnt/EMOS
cd /mnt
createrepo .
# 创建客户端 yum 的定义文件
cd /etc/yum.repos.d
mkdir backup
mv *.repo ./backup
cat >> EMOS.repo <<EOF
[EMOS]
name=EMOS
baseurl=file:///mnt/
enabled=1
gpgcheck=0
EOF

# 重新获取最新的仓库信息
yum clean all
yum list
# 安装 postfix
yum install postfix -y
rpm -e sendmail
# 配置 postfix
postconf -n > /etc/postfix/main2.cf
mv /etc/postfix/main.cf /etc/postfix/main.cf.old
mv /etc/postfix/main2.cf /etc/postfix/main.cf

# 编辑 main.cf
cat >> /tmp/tmp.file <<EOF
mynetworks = 127.0.0.1
myhostname = mail.hifyl.com
mydestination = $mynetworks $myhostname

# banner
mail_name = Postfix - by extmail.org
smtpd_banner = $myhostname ESMTP $mail_name

# response immediately
smtpd_error_sleep_time = 0s

# Message and return code control
message_size_limit = 5242880
mailbox_size_limit = 5242880
show_user_unknown_table_name = no

# Queue lifetime control
bounce_queue_lifetime = 1d
maximal_queue_lifetime = 1d
EOF

cat /tmp/tmp.file >> /etc/postfix/main.cf
# 设置 postfix 开机自启
chkconfig postfix on
# 安装以下软件包
yum install courier-authlib -y
yum install courier-authlib-mysql -y

echo "" > /etc/authlib/authmysqlrc
cat >> /etc/authlib/authmysqlrc <<EOF
MYSQL_SERVER            localhost
MYSQL_SOCKET            /var/lib/mysql/mysql.sock
MYSQL_PORT              3306
MYSQL_OPT               0
MYSQL_DATABASE          extmail
MYSQL_USER_TABLE        mailbox
MYSQL_CRYPT_PWFIELD     password
MYSQL_UID_FIELD         uidnumber
MYSQL_GID_FIELD         gidnumber
MYSQL_LOGIN_FIELD       username
MYSQL_HOME_FIELD        homedir
MYSQL_NAME_FIELD        name
MYSQL_MAILDIR_FIELD     maildir
MYSQL_QUOTA_FIELD       quota
MYSQL_SELECT_CLAUSE     SELECT username,password,"",uidnumber,gidnumber,\
                        CONCAT('/home/domains/',homedir),               \
                        CONCAT('/home/domains/',maildir),               \
                        quota,                                          \
                        name                                            \
                        FROM mailbox                                    \
                        WHERE username = '$(local_part)@$(domain)'
EOF

sed -i '/^authmodulelist/ c authmodulelist="authmysql"' /etc/authlib/authdaemonrc
sed -i '/^authmodulelistorig/ c authmodulelistorig="authmysql"' /etc/authlib/authdaemonrc
# 启动 courier-authlib
service courier-authlib start
# 修改 authdaemon socket 目录权限
chmod 755 /var/spool/authdaemon/
# 安装 maildrop
yum install maildrop -y
echo "maildrop   unix        -       n        n        -        -        pipe" >> /etc/postfix/master.cf
echo "maildrop_destination_recipient_limit = 1" >> /etc/postfix/main.cf
# 编辑 httpd.conf 文件
yum install httpd -y
echo "NameVirtualHost *:80" >>/etc/httpd/conf/httpd.conf
echo "Include conf/vhost_*.conf" >>/etc/httpd/conf/httpd.conf

cat >> /etc/httpd/conf/vhost_extmail.conf <<EOF
# VirtualHost for ExtMail Solution
<VirtualHost *:80>
ServerName mail.extmail.org
DocumentRoot /var/www/extsuite/extmail/html/

ScriptAlias /extmail/cgi/ /var/www/extsuite/extmail/cgi/
Alias /extmail /var/www/extsuite/extmail/html/

ScriptAlias /extman/cgi/ /var/www/extsuite/extman/cgi/
Alias /extman /var/www/extsuite/extman/html/

# Suexec config
SuexecUserGroup vuser vgroup
</VirtualHost>
EOF

# 设置 apache 开机启动
chkconfig httpd on

# 安装 ExtMail
yum install extsuite-webmail -y

# 编辑 webmail.cf
cd /var/www/extsuite/extmail
cp webmail.cf.default webmail.cf

sed -i '/^SYS_MYSQL_USER/ c SYS_MYSQL_USER = extmail' webmail.cf
sed -i '/^SYS_MYSQL_PASS/ c SYS_MYSQL_PASS = extmail' webmail.cf
# 更新 cgi 目录权限 由于 SuEXEC 的需要,必须将 extmail 的 cgi 目录修改成 vuser:vgroup 权限
groupadd vgroup
useradd vuser
chown -R vuser:vgroup /var/www/extsuite/extmail/cgi/

# yum 安装 ExtMan
yum install extsuite-webman -y

# 更新 cgi 目录权限 由于 SuEXEC 的需要,必须将 extman 的 cgi 目录修改成 vuser:vgroup 权限
chown -R vuser:vgroup /var/www/extsuite/extman/cgi/

# 链接基本库到 Extmail
mkdir /tmp/extman
chown -R vuser:vgroup /tmp/extman
# 数据库初始化
yum install mysql mysql-server -y
service mysqld start
chkconfig mysqld on
# 导入 mysql 数据库结构及初始化数据,root 密码默认为空
mysql -u root -p < /var/www/extsuite/extman/docs/extmail.sql
mysql -u root -p < /var/www/extsuite/extman/docs/init.sql
# 设置虚拟域和虚拟用户的配置文件
cd /var/www/extsuite/extman/docs
cp mysql_virtual_alias_maps.cf /etc/postfix/
cp mysql_virtual_domains_maps.cf /etc/postfix/
cp mysql_virtual_mailbox_maps.cf /etc/postfix/
cp mysql_virtual_sender_maps.cf /etc/postfix/

# 配置 main.cf
> /tmp/tmp.file
cat >> /tmp/tmp.file <<EOF
# extmail config here
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_transport = maildrop:
EOF

cat /tmp/tmp.file >> /etc/postfix/main.cf
yum install postfix -y
service postfix restart

# 建立刚才导入 mysql 的 postmaster@extmail.org 帐户的 Maildir,请输入如下命令
cd /var/www/extsuite/extman/tools
./maildirmake.pl /home/domains/extmail.org/postmaster/Maildir
chown -R vuser:vgroup /home/domains/extmail.org

正文完
扫码赞助
post-qrcode
 0
果子
版权声明:本站原创文章,由 果子 于2014-01-25发表,共计4462字。
转载说明:除特殊说明外本站文章皆由果较瘦原创发布,转载请注明出处。