courier-authlib dovecot postfix postdrop extmail mysql
系统版本6.7
软件版本 httpd-2.2.15-47.el6.centos postfix-3.1.0 extman-1.1 extmail-1.2 mysql 5.6.30 dovecot-2.0.9-19.el6_7.2.x86_64
yum -y remove boost-*
yum -y remove mysql
yum -y install wget gcc gcc-c++ ncurses-devel cmake make perl
可以有dns需要的可自行配置,需要的可以找我,还得写配置
新建mysql组以及用户
groupadd mysql
useradd -M -s /sbin/nologin -r -g mysql mysql
好像得要有boost 源码编译mysql 14-61行 安装过的可直接忽略
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/mysql/data -DSYSCONFDIR=/usr/local/mysql/ -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_BOOST=/files/boost -DWITH_PARTITION_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DDOWNLOAD_BOOST=1 -DENABLED_LOCAL_INFILE=1 -DEXTRA_CHARSETS=all
安装完之后可能会报有四个选项错误,这是5.7的配置错误可以忽略
make && make install
mv /etc/my.cnf{,.bak}
cp support-files/my-default.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
mkdir -p /mysql/data
chown -R mysql:mysql /mysql/data
5.6
scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/mysql/data -u mysql
5.7
/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/mysql/data
问题
[[email protected] MySQL]# /etc/rc.d/init.d/mysql status
MySQL is not running, but lock file (/var/lock/subsys/mysql[FAILED]
解决方
查看日志
cat /mysql/data/xiong.err
160513 00:19:41 mysqld_safe mysqld from pid file /mysql/data/xiong.pid ended
chown -R mysql:mysql /usr/local/mysql/
touch /etc/profile.d/mysqld.sh
echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile.d/mysqld.sh
source /etc/profile.d/mysqld.sh
安装组工具包以及软件包
yum -y groupinstall "Development tools" "Desktop Platform Development" "Server Platform Development"
yum -y install httpd perl-DBD-MySQL courier-authlib dovecot
首先一定要加入emos源否则authlib软件会安装失败
vim /etc/yum.repo.d/emos.repo
[EMOS]
name=EMOS
baseurl=file:///mnt 此处Yum仓库按自己要想的来,都可以
enabled=1
gpgcheck=0
卸载postfix软件
yum -y remove postfix
删除系统用户postfix此步一定要操作否则extmail最后发送邮件会出现系统配置错误
groupdel postfix
groupadd -g 2000 postfix
useradd -g 2000 -u 2000 -s /sbin/nologin -M postfix
groupadd -g 2001 postdrop
userdel -r postdrop
useradd -g 2001 -u 2001 -s /sbin/nologin -M postdrop
因为删除了系统用户需要将postfix原先自带文件增加权限,否则启动时会失败
chown postfix -R /var/lib/postfix/
chown postfix -R /var/spool/postfix/
增加库文件否则make postfix 会失败
echo "/usr/local/mysql/lib" >> //etc/ld.so.conf.d/mysqld.conf
我的版本是postfix-3.1.0 ,系统版本64位的需要更改/usr/lib64,我的mysql是源码编的指定头文件跟库文件位置
make makefiles ‘CCARGS=-DHAS_MYSQL -I/usr/local/mysql/include -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl -DUSE_TLS‘ ‘AUXLIBS=-L/usr/local/mysql/lib -lmysqlclient -lz -lm -L/usr/lib64/sasl2 -lsasl2 -lssl -lcrypto‘
make -j 2 && make install
生成/etc/init.d/postfix脚本 下载位置 链接:http://pan.baidu.com/s/1hrSpPDM 密码:tieu
chmod +x /etc/init.d/postfix
chkconfig postfix --add
chkconfig postfix on
postconf "smtputf8_enable = no"
编辑authdaemonrc文件更改配置方式只为myql
vim /etc/authlib/authdaemonrc
Euthmodulelist="authuserdb authpam authpgsql authldap authmysql authcustom authpipe"
authmodulelist="authmysql"
Euthmodulelistorig="authuserdb authpam authpgsql authldap authmysql authcustom authpipe"
authmodulelistorig="authmysql"
#daemons=5
daemons=10 进程为10
连接mysql配置文件,用户跟密码按自己指定的来我的是默认的extmail
egrep -v "^#|^[[:space:]]|^$" /etc/authlib/authmysqlrc
MYSQL_SERVER localhost
MYSQL_USERNAME extmial
MYSQL_PASSWORD extmail
MYSQL_PORT 3306 端口号
MYSQL_OPT 0
MYSQL_DATABASE extmail
MYSQL_USER_TABLE mailbox 文件目录
MYSQL_CRYPT_PWFIELD password
MYSQL_UID_FIELD 2000 用户组ID号上头创建的用户
MYSQL_GID_FIELD 2000
MYSQL_LOGIN_FIELD username
MYSQL_HOME_FIELD concat(‘var/mailbox/‘,homedir) 连接目录
MYSQL_NAME_FIELD name
MYSQL_MAILDIR_FIELD concat(‘/var/mailbox/‘,maildir)
MYSQL_SOCKET /usr/local/mysql/mysql.sock 此处一定要注意指定自己的mysql.sock文件
配置完成之后记得启动用服务并将authlib加入开机启动项
service courier-authlib restart
chkconfig courier-authlib on
创建authlib指定的目录,上面指什么这里创建什么目录
mkdir -pv /var/mailbox
chown -R postfix /var/mailbox/
指定sasl2认证方式
vim /usr/lib64/sasl2/smtpd.conf
pwcheck_method: authdaemond
mech_list: PLAIN LOGIN
authdaemond_path:/var/spool/authdaemon/socket
这里修改为:sasl所支持的认证方式
vim /etc/postfix/main.cf
inet_interfaces = all 监听地址一定要改为all本地也行
############################CYRUS-SASL############################
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_sasl_application_name = smtpd
smtpd_banner = Welcome to our $myhostname ESMTP,Warning: Version not Available!
########################Virtual Mailbox Settings######################## 这里是extmil配置
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:2000
virtual_gid_maps = static:2000
virtual_transport = virtual
##########################QUOTA Settings######################## 配额可取消
message_size_limit = 14336000
virtual_mailbox_limit = 20971520
这里很关键、一定要注意双引号以及自动创建模式,否则导入extmail.sql文件会出错
vim /usr/local/mysql/my.cnf
sql_mode="NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES"
sql-mode="NO_AUTO_CREATE_USER"
[[email protected] docs]# service mysqld restart
改完一定要重启再导入extmail.sql
进入数据库中导入我的是5.6.30版本
source /tmp/extman-1.1/docs/extmail.sql; 创建用户并授权,mysql不熟这是百度的
GRANT ALL PRIVILEGES ON extmail.* TO [email protected] IDENTIFIED BY ‘extmail‘;
GRANT ALL PRIVILEGES ON extmail.* TO [email protected] IDENTIFIED BY ‘extmail‘;
将extman ,mysql_虚拟用户复制到postfix目录下、这文件都是main.cf定义的不要少复制、否则也会报错
[[email protected] docs]# cp /tmp/extman-1.1/docs/mysql_virtual_* /etc/postfix/
vim /etc/dovecot/conf.d/auth-sql.conf.ext
行前加入该行 mail_location = maildir:/var/mailbox/%d/%n/Maildir
vim /etc/dovecot/dovecot-sql.conf.ext 该文件需跟auth-sql.conf中定义一致
driver = mysql host注意一定s改成mysql.sock指定的不要直接复制否则会有错误
connect = host=/usr/local/mysql/mysql.sock 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‘
安装extmail
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
vim /var/www/extsuite/extmail/webmail.cf
SYS_USER_LANG = en_US
语言选项,可改作:
SYS_USER_LANG = zh_CN
SYS_MAILDIR_BASE = /home/domains
此处即为您在前文所设置的用户邮件的存放目录,可改作:
SYS_MAILDIR_BASE = /var/mailbox
SYS_MYSQL_USER = db_user
SYS_MYSQL_PASS = db_pass
以上两句句用来设置连接数据库服务器所使用用户名、密码和邮件服务器用到的数据库,这里修改为:
SYS_MYSQL_USER = extmail
SYS_MYSQL_PASS = extmail
vim /etc/httpd/conf/httpd.conf
User postfix
Group postfix
ServerAdmin adminmail.xiong.com
DocumentRoot /var/www/extsuite/extmail/html
ScriptAlias /extmail/cgi /var/www/extsuite/extmail/cgi
Alias /extmail /var/www/extsuite/extmail/html/
extmail将会用到perl的Unix::syslogd功能,您可以去http://search.cpan.org搜索下载原码包进行安装。
tar zxvf Unix-Syslog-0.100.tar.gz
cd Unix-Syslog-0.100
perl Makefile.PL
make
make install
启动apache服务
service httpd restart
安装extman 下载路径www.extmail.org
tar zxvf extman-1.1.tar.gz
[[email protected] tmp]# mv extman-1.1 /var/www/extsuite/extman
cd /var/www/extsuite/extman
[[email protected] extman]# cp webman.cf.default webman.cf
vim webman.cf
SYS_MAILDIR_BASE = /home/domains
此处即为您在前文所设置的用户邮件的存放目录,可改作:
SYS_MAILDIR_BASE = /var/mailbox
SYS_DEFAULT_UID = 1000
SYS_DEFAULT_GID = 1000
此两处后面设定的ID号需更改为前而创建的postfix用户和postfix组的id号,本文使用的是2525,因此,上述两项需要修改为:
SYS_DEFAULT_UID = 2525
SYS_DEFAULT_GID = 2525
SYS_MYSQL_USER = webman
SYS_MYSQL_PASS = webman
修改为:
SYS_MYSQL_USER = extmail
SYS_MYSQL_PASS = extmail
SYS_MYSQL_SOCKET = /var/lib/mysql/mysql.sock 修改为:SYS_MYSQL_SOCKET = /tmp/mysql.sock
[[email protected] extman]# vim /etc/httpd/conf/httpd.conf
添加到虚拟网站中
ScriptAlias /extman/cgi /var/www/extsuite/extman/cgi
Alias /extman /var/www/extsuite/extman/html
创建其运行时所需的临时目录,并修改其相应的权限:
#mkdir -pv /tmp/extman
#chown postfix.postfix /tmp/extman
vim /var/www/extsuite/extman/webman.cf
不启用验证码
SYS_CAPTCHA_ON = 1 为 SYS_CAPTCHA_ON = 0
最后图形日志没有开启,还得修改,这样就可以直接使用