首先依然是架设dns服务器
15 27 28 37 38 改为any
声明区域
产生并编辑区域文件
指明dns指向
安装必备的软件包
yum install httpd php php-mysql mysql mysql-server mysql-devel openssl-devel dovecot perl-DBD-MySQL tcl tcl-devel libart_lgpl libart_lgpl-devel libtool-ltdl libtool-ltdl-devel expect
下面开始配置
首先关闭sendmail
启动mysql并给以密码
启动身份验证服务
下面采用源码安装postfix
首先给postfix创建账号和组
将所需安装包拷到系统里
解压安装
[root@localhost postfix-2.8.2]# make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl -DUSE_TLS ' 'AUXLIBS=-L/usr/lib/mysql -lmysqlclient -lz -lm -L/usr/lib/sasl2 -lsasl2 -lssl -lcrypto'
Make
Make install 后面有需要选择出了临时目录 其他按照默认
生成别名二进制文件 newaliases
/postfix start
说明postfix可以启动了
给postfix 添加系统自启动
为postfix开启基于cyrus-sasl的认证功能
首先查询一下看postfix支持哪些验证:
在配置文件中加入下面的代码: vim /etc/postfix/main.cf
readme_directory = no
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject_invalid_hostname,reject_non_fqdn_hostname,reject_unknown_sender_domain,reject_non_fqdn_sender,reject_non_fqdn_recipient,reject_unknown_recipient_domain,reject_unauth_pipelining,reject_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_security_options = noanonymous
smtpd_banner = Welcome to our $myhostname ESMTP,Warning: Version not Available!
~
编辑此文件/usr/lib/sasl2/smtpd.conf
增加
pwcheck_method: saslauthd
mech_list: PLAIN LOGIN
首先切换到[root@localhost init.d]# cd /usr/lib/sasl2/ 将Sendmail.conf 拷一份到smtpd.conf
再加上上面那句话
重启saslauthd
再查可看到已具有验证功能
安装Courier authentication library
切换过去安装
./configure --prefix=/usr/local/courier-authlib --sysconfdir=/etc --with-authmysql --with-mysql-libs=/usr/lib/mysql --with-mysql-includes=/usr/include/mysql --with-redhat --with-authmysqlrc=/etc/authmysqlrc --with-authdaemonrc=/etc/authdaemonrc --with-ltdl-lib=/usr/lib --with-ltdl-include=/usr/include
Make
Make install
安装完成后修改 文件权限 以便下面的操作拥有权限
修改/etc/authdaemonrc 文件
authmodulelist="authmysql"
authmodulelistorig="authmysql"
daemons=10
编辑/etc/authmysqlrc 为以下内容,其中2525,2525 为postfix 用户的UID和GID。
MYSQL_SERVER localhost
MYSQL_PORT 3306 (指定mysql监听的端口,这里使用默认的3306)
MYSQL_USERNAME extmail (这时为后文要用的数据库的所有者的用户名)
MYSQL_PASSWORD extmail (密码)
MYSQL_SOCKET /var/lib/mysql/mysql.sock
MYSQL_DATABASE extmail
MYSQL_USER_TABLE mailbox
MYSQL_CRYPT_PWFIELD password
MYSQL_UID_FIELD '2525'
MYSQL_GID_FIELD '2525'
MYSQL_LOGIN_FIELD username
MYSQL_HOME_FIELD concat('/var/mailbox/',homedir)
MYSQL_NAME_FIELD name
MYSQL_MAILDIR_FIELD concat('/var/mailbox/',maildir)
# 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
结果
新建虚拟用户邮箱所在的目录,并将其权限赋予postfix用户:
#mkdir �C-pv /var/mailbox
#chown �CR postfix /var/mailbox
接下来重新配置SMTP 认证,编辑 /usr/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,添加如下内容:
########################Virtual Mailbox Settings########################
virtual_mailbox_base = /var/mailbox
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_alias_domains =
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_uid_maps = static:2525
virtual_gid_maps = static:2525
virtual_transport = virtual
maildrop_destination_recipient_limit = 1
maildrop_destination_concurrency_limit = 1
##########################QUOTA Settings########################
message_size_limit = 14336000
virtual_mailbox_limit = 20971520
virtual_create_maildirsize = yes
virtual_mailbox_extended = yes
virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_mailbox_limit_maps.cf
virtual_mailbox_limit_override = yes
virtual_maildir_limit_message = Sorry, the user's maildir has overdrawn his diskspace quota, please Tidy your mailbox and try again later.
virtual_overquota_bounce = yes
2、使用extman源码目录下docs目录中的extmail.sql和init.sql建立数据库:
# cd extman-1.1/docs
-------------------------------------------------------------------------------------------------------------
# mysql -u root -p <extmail.sql
# mysql -u root -p <init.sql
数据库导入后的结果
# cp mysql* /etc/postfix/
3、授予用户extmail访问extmail数据库的权限
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; 让设置的内容生效
service postfix restart
配置dovecot
编辑/etc/dovecot.conf
修改下面内容
auth default {
mechanisms = plain
passdb sql {
args = /etc/dovecot-mysql.conf
}
userdb sql {
args = /etc/dovecot-mysql.conf
}
……
建立并编辑连接数据库的文件
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'
接下来启动dovecot服务:
# service dovecot start
# chkconfig dovecot on
安装Extmail-1.2
1、安装
# tar zxvf extmail-1.2.tar.gz
# mkdir -pv /var/www/extsuite
# mv extmail-1.2 /var/www/extsuite/extmail
# cp /var/www/extsuite/extmail/webmail.cf.default /var/www/extsuite/extmail/webmail.cf
2、修改主配置文件
#vim /var/www/extsuite/extmail/webmail.cf
3、apache相关配置
修改主配置文档建立虚拟主机
修改 cgi执行文件属主为apache运行身份用户:
[root@mail extmail]# chown -R postfix.postfix /var/www/extsuite/extmail/cgi/
[root@mail extmail]# service httpd restart
# vim /etc/httpd/httpd.conf
User postfix
Group postfix
安装extman
[root@mail ~]# mv extman-1.1 /var/www/extsuite/extman
[root@mail extman]# cp /var/www/extsuite/extman/webman.cf.default /var/www/extsuite/extman/webman.cf
[root@mail extman]# vim /var/www/extsuite/extman/webman.cf
12 SYS_MAILDIR_BASE = /var/mailbox
21 SYS_CAPTCHA_ON = 0
:wq
[root@mail extman]# chown -R postfix.postfix /var/www/extsuite/extman/cgi/
[root@mail extman]# vim /etc/httpd/conf/httpd.conf
加入997 、998行
992 <VirtualHost 192.168.100.123:80>
993 ServerName mail.yeah.net
994 DocumentRoot /var/www/extsuite/extmail/html/
995 ScriptAlias /extmail/cgi /var/www/extsuite/extmail/cgi
996 Alias /extmail /var/www/extsuite/extmail/html
997 ScriptAlias /extman/cgi /var/www/extsuite/extman/cgi
998 Alias /extman /var/www/extsuite/extman/html
999 </VirtualHost>
[root@mail extman]# mkdir -pv /tmp/extman
[root@mail extman]# chown postfix.postfix /tmp/extman
4、依赖关系的解决
extmail将会用到perl的Unix::syslogd功能,您可以去http://search.cpan.org搜索下载原码包
进行安装。
[root@mail ~]# tar zxvf Unix-Syslog-1.1.tar.gz
[root@mail ~]# cd Unix-Syslog-1.1
[root@mail Unix-Syslog-1.1]# perl Makefile.PL【编译】
[root@mail Unix-Syslog-1.1]# make install【安装】
[root@mail Unix-Syslog-1.1]# service httpd restart
测试结果