Mail服务器(Postfix+Dovecot+Extmail+Extman基于虚拟账号)
实验拓扑
LAMP(Linux+Apache+MySQL+PHP)环境搭建
首先需要搭建LAMP环境
安装Apache
[[email protected] apr-1.4.6]# tar -zxvf apr-util-1.5.1.tar.gz -C /usr/local/src/
[[email protected] apr-1.4.6]# cd /usr/local/src/apr-1.4.6/
[[email protected] apr-1.4.6]# ./configure --prefix=/usr/local/apr
[[email protected] apr-1.4.6]# make
[[email protected] apr-1.4.6]# make install
[[email protected] src]# cd apr-util-1.5.1/
[[email protected] apr-util-1.5.1]# ./configure --with-apr=/usr/local/apr/bin/apr-1-config
[[email protected] apr-util-1.5.1]# make
[[email protected] apr-util-1.5.1]# make install
[[email protected] cdrom]# cd /mnt/cdrom/Server/
[[email protected] Server]# rpm -ivh /mnt/cdrom/Server/pcre-devel-6.6-2.el5_1.7.i386.rpm
安装http
[[email protected] ~]# tar -jxvf httpd-2.4.4.tar.bz2 -C /usr/local/src/
[[email protected] ~]# cd /usr/local/src/httpd-2.4.4/
[[email protected] httpd-2.4.4]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-rewrite --with-apr=/usr/local/apr/bin/apr-1-config --with-apr-util=/usr/local/apr/bin/apu-1-config --with-pcre -with-z --enable-mpms-shared=all
[[email protected] httpd-2.4.4]# make
[[email protected] httpd-2.4.4]# make install
[[email protected] ~]# cd /etc/init.d/
[[email protected] init.d]# chmod a+x httpd
[[email protected]l init.d]# ln -s /usr/local/apache/include/ /usr/include/apche
[[email protected] init.d]# vim /etc/man.config
安装mysql
[[email protected] ~]# groupadd mysql
[[email protected] ~]# useradd -r -g mysql mysql
[[email protected] src]# cd /usr/local/
[[email protected] local]# ln -s /usr/local/src/mysql-5.5.15-linux2.6-i686/ mysql
[[email protected] mysql]# chown -R mysql .
[[email protected] mysql]# chgrp -R mysql .
[[email protected] mysql]# scripts/mysql_install_db --user=mysql
[[email protected] mysql]# chown -R root .
[[email protected] mysql]# chown -R mysql data
[[email protected] mysql]# cp support-files/my-medium.cnf /etc/my.cnf
[[email protected] mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[[email protected] mysql]# service mysqld start
Starting MySQL..... [ OK ]
[[email protected] mysql]# chkconfig --add mysqld
配置mysql环境变量
[[email protected] mysql]# vim /etc/profile
[[email protected] mysql]# . /etc/profile
创建mysql.conf文件并添加库文件路径
[[email protected] mysql]# vim /etc/ld.so.conf.d/mysql.conf
/usr/local/mysql/lib
[[email protected] mysql]# ldconfig
处理头文件
[[email protected] mysql]# ln -s include /usr/include/mysql
给mysql数据库添加密码
安装php
[[email protected] php-5.4.13]# tar -jxvf php-5.4.13.tar.bz2 -C /usr/local/src/
[[email protected] php-5.4.13]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --enable-xml --with-png-dir --with-png --with-jpeg-dir --with-zlib --enable-mbstring --with-freetype-dir
[[email protected] php]# make
[[email protected] php]# make install
编辑/etc/profile
库文件处理
[[email protected] php]# ldconfig
处理头文件
[[email protected] php]# ln -s /usr/local/php/include/ /usr/include/php
编辑apache的配置文件支持php模块
下面进行exymail的搭建
本次主要来搭建北京地区extmail
关闭开发平台的sendmail功能,因为要搭建extmail。
更改主机名和dns指向
关闭sendmail并设为开机关闭
上传搭建extmail所需要的软件包
postfix-2.8.2.tar.gz
courier-authlib-0.63.0.tar.bz2
Unix-Syslog-0.100.tar.gz
extmail-1.2.tar.gz
extman-1.1.tar.gz
打开saslauth服务设为开机启动
安装其他软件包
Yum install mysql-devel
安装postfix
[[email protected] ~]# tar -zxvf postfix-2.8.2.tar.gz -C /usr/local/src/
[[email protected] ~]# cd /usr/local/src/postfix-2.8.2/
[[email protected] postfix-2.8.2]# group -g 2525 postfix
-bash: group: command not found
[[email protected] postfix-2.8.2]# groupadd -g 2525 postfix
[[email protected] postfix-2.8.2]# useradd -g postfix -u 2525 -s /sbin/nologin -M postfix
[[email protected] postfix-2.8.2]# groupadd -g 2526 postdrop
[[email protected] postfix-2.8.2]# useradd -g postdrop -u 2526 -s /bin/false -M postdro
Mysql的路径一定要正确
[[email protected] postfix-2.8.2]# make && make install
install_root: [/] /
tempdir: [/usr/local/src/ postfix-2.6.5] /tmp
config_directory: [/etc/postfix]
daemon_directory: [/usr/libexec/postfix]
command_directory: [/usr/sbin]
queue_directory: [/var/spool/postfix]
sendmail_path: [/usr/sbin/sendmail]
newaliases_path: [/usr/bin/newaliases]
mailq_path: [/usr/bin/mailq]
mail_owner: [postfix]
setgid_group: [postdrop]
html_directory: [no] /var/www/postfix_html
manpages: [/usr/local/man]
readme_directory: [no]
执行/usr/bin/newaliases生成新的别名文件,提高postfix的效率
[[email protected] postfix-2.8.2]# /usr/bin/newaliases
2.进行一些基本配置,测试启动postfix并进行发信
#vi /etc/postfix/main.cf
为了管理postfix服务的启动关闭,创建脚本,复制postfix的rpm包的控制脚本
[[email protected] ~]# cd /tmp/
[[email protected] tmp]# mkdir abc
[[email protected] tmp]# cd abc/
[[email protected] abc]# cp /mnt/cdrom/Server/postfix-2.3.3-2.1.el5_2.i386.rpm ./
[[email protected] abc]# rpm2cpio postfix-2.3.3-2.1.el5_2.i386.rpm |cpio -id
编辑postfix配置文件
[[email protected] init.d]# vim /etc/postfix/main.cf
配置邮件服务器的中继
发送邮件测试
为postfix开启基于rycus-sasl认证功能.
vim /etc/postfix/main.cf
添加认证功能
四、安装Courier authentication library
[[email protected] ~]# tar jxvf courier-authlib-0.63.0.tar.bz2 -C /usr/local/src/
[[email protected] ~]# cd /usr/local/src/courier-authlib-0.63.0/
[[email protected] courier-authlib-0.63.0]# ./configure \
> --prefix=/usr/local/courier-authlib \
> --sysconfdir=/etc \
> --with-authmysql \
> --with-mysql-libs=/usr/local/mysql/lib \
> --with-mysql-includes=/usr/local/mysql/include \
> --with-redhat \
> --with-authmysqlrc=/etc/authmysqlrc \
> --with-authdaemonrc=/etc/authdaemonrc \
> --with-ltdl-lib=/usr/lib \
> --with-ltdl-include=/usr/include
[[email protected] courier-authlib-0.63.0]# make
[[email protected] courier-authlib-0.63.0]# make install
[[email protected] courier-authlib-0.63.0]# chmod 755 /usr/local/courier-authlib/var/spool/authdaemon
[[email protected] courier-authlib-0.63.0]# cp /etc/authdaemonrc.dist /etc/authdaemonrc
[[email protected] courier-authlib-0.63.0]# cp /etc/authmysqlrc.dist /etc/authmysqlrc
[[email protected] etc]# vim /etc/authdaemonrc
[[email protected] etc]# vim /etc/authmysqlrc
[[email protected] etc]# cd /usr/local/src/courier-authlib-0.63.0/
[[email protected] courier-authlib-0.63.0]# cp courier-authlib.sysvinit /etc/init.d
# cp courier-authlib.sysvinit /etc/init.d/courier-authlib
# chmod 755 /etc/init.d/courier-authlib
# chkconfig --add courier-authlib
# chkconfig --level 2345 courier-authlib on
#echo "/usr/local/courier-authlib/lib/courier-authlib" >> /etc/ld.so.conf.d/courier-authlib.conf
# ldconfig -v
启动服务
[[email protected] etc]# service courier-authlib start
Starting Courier authentication services: authdaemond
新建虚拟用户邮箱所在的目录,并将其权限赋予postfix用户:
#mkdir -pv /var/mailbox
#chown –R postfix /var/mailbox
接下来重新配置SMTP 认证,编辑 /usr/local/lib/sasl2/smtpd.conf ,确保其为以下内容:
pwcheck_method: authdaemond
log_level: 3
mech_list:PLAIN LOGIN
authdaemond_path:/usr/local/courier-authlib/var/spool/authdaemon/socket
五、让postfix支持虚拟域和虚拟用户
1、编辑/etc/postfix/main.cf,添加如下内容:
2、使用extman源码目录下docs目录中的extmail.sql和init.sql建立数据库:
[[email protected] ~]# tar -zxvf extman-1.1.tar.gz
[[email protected] ~]# mv extman-1.1 /var/www/extsuite/extman
由于mysql版本的原因。导入数据库之前我们需要对extmail.sql进行更改,extmail.sql中所包含的的text的行把后面的default ‘ ’删掉,把TYPE=MyISAMCOMMENT=’ExtMail - Virtual Mailboxes‘行删除,把87行改成can_signup varchar(255).
[[email protected] docs]# mysql -u root -p < extmail.sql
向mysql数据库导入初始化init.sql脚本
[[email protected] docs]# mysql -u root -p < init.sql
导入后查看数据库验证
六、配置dovecot
之前已经安装过
配置dovecot
[[email protected] Server]# vim /etc/dovecot.conf
创建dovcot和mysql连接时的配置文件
[[email protected] Server]# vim /etc/dovecot-mysql.conf
设为开机启动
[[email protected] Server]# chkconfig dovecot on
七、安装Extmail-1.2 (先安装httpd)
[[email protected] ~]# mkdir -pv /var/www/extsuite
[[email protected] ~]# tar -zxvf extmail-1.2.tar.gz
[[email protected] ~]# mv extmail-1.2 /var/www/extsuite/extmail
cp /var/www/extsuite/extmail/webmail.cf.default /var/www/extsuite/extmail/webmail.cf
编辑配置文件
apache相关配置
修改cgi 执行文件属于postfix运行身份用户
[[email protected] extmail]# chown -R postfix.postfix /var/www/extsuite/extmail/cgi/
4、依赖关系的解决
[[email protected] ~]# tar -zxvf Unix-Syslog-0.100.tar.gz -C /usr/local/src/
[[email protected] ~]# cd /usr/local/src/Unix-Syslog-0.100/
[[email protected] Unix-Syslog-0.100]# perl Makefile.PL
[[email protected] Unix-Syslog-0.100]# make
[[email protected] Unix-Syslog-0.100]# make install
重启httpd服务器
八、配置Extman-1.1
[[email protected] ~]# mv extman-1.1 /var/www/extsuite/extman
[[email protected] ~]# cp /var/www/extsuite/extman/webman.cf.default /var/www/extsuite/extman/webman.cf
[[email protected] ~]# vim /var/www/extsuite/extman/webman.cf
12 SYS_MAILDIR_BASE = /var/mailbox
21 SYS_CAPTCHA_ON = 0
127 SYS_MYSQL_USER = webman
128 SYS_MYSQL_PASS = webman
129 SYS_MYSQL_DB = extmail
130 SYS_MYSQL_HOST = localhost
131 SYS_MYSQL_SOCKET = /tmp/mysql.sock
在apache的主配置文件中extmail的虚拟主机部分。添加一下两行
创建运行时所需的临时目录,并修改权限
[[email protected] ~]# mkdir -pv /tmp/extman
mkdir: created directory `/tmp/extman'
[[email protected] ~]# chown postfix.postfix /tmp/extman
重启一下apache服务器
登录测试一下默认管理帐号为:[email protected] 密码为:extmail*123*
http://10.1.1.100
转载于:https://blog.51cto.com/muxiaohao/1314581