本文介绍Postfix邮件系统的安装与配置. 如有疑问可以留言.
本文主要内容是poftfix+mysql 实现虚拟用户.
http://wiki.extmail.org/extmail_solution_for_linux_centos-5
平台:
Centos 5.6 64位所需软件:
Apache:2.2.15 Mysql:5.1.36 Php:5.2.13 Postfix:2.8.0 Courier-authlib:0.63 Cyrus-sasl:2.1.22 BerkeleyDB:4.5.20 Courier-IMAP:4.9.3 Maildrop:2.5.4 Extman:1.1 Extmail:1.2 Rrdtool:1.4.3 Slockd:0.99先安装 Apache,Mysql,Php
Mysql 虚拟用户使用.
Apache ,php ,Mysql extmail Web管理台需要.
Apache,Mysql,Php的安装这里不做介绍,它们的安装文档网上很多,本人blog也有安装文档.
这里只介绍下Apache,Mysql,Php的编译参数.
Apache编译参数: (关于suexec可以看下http://lamp.linux.gov.cn/Apache/ApacheMenu/suexec.html)
./configure --prefix=/usr/local/apache2.2.15 --with-mpm=worker --enable-so --enable-rewrite --enable-headers --enable-expires --enable-suexec --with-suexec-caller=nobody --with-suexec-docroot=/opt/www
#./configure --prefix=/usr/local/mysql --datadir=/opt/mydata --with-charset=utf8 --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-ssl --with-embedded-server --enable-local-infile --enable-assembler --with-plugins=innobase --with-plugins=partitionphp编译参数:
#./configure --prefix=/usr/local/php-5.2.13 --with-config-file-path=/usr/local/php-5.2.13 --with-apxs2=/usr/local/apache2.2.15/bin/apxs --with-bz2 --with-curl --with-curlwrappers --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local --with-zlib --enable-zend-multibyte --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql=/usr/local/mysql
/usr/local/src/tarbag/ \\源码包存放的位置 /usr/local/src/software/ \\源码包解压出来存放的位置以下安装建立在以上所需条件.所有安装为源码安装,源码包放在tarbag目录下,解压后放在software目录下:
#cd /usr/local/src/tarbag #wget http://sourceforge.net/projects/courier/files/authlib/0.63.0/courier-authlib-0.63.0.tar.bz2/download #tar jvxf courier-authlib-0.63.tar.bz2 -C ../software/ 安装之前添加postfix和maildrop相关的用户&用户组 #groupadd postfix -g 1000 #groupadd postdrop -g 1002 #useradd postfix -u 1000 -g postfix -G postdrop #groupadd vmail -g 1001 #useradd vmail -u 1001 -g 1001 #./configure --prefix=/usr/local/courier-authlib --with-mailuser=vmail --with-mailgroup=vmail --sysconfdir=/etc --without-authpam --without-authldap --without-authpwd --without-authshadow --without-authvchkpw --without-authpgsql --with-authmysql --with-mysql-libs=/usr/local/mysql/lib/mysql --with-mysql-includes=/usr/local/mysql/include/mysql --with-redhat --with-authmysqlrc=/etc/authmysqlrc --with-authdaemonrc=/etc/authdaemonrc CFLAGS="-march=x86-64 -O2 -fexpensive-optimizations" CXXFLAGS="-march=x86-64 -O2 -fexpensive-optimizations" #make #make install1.如果courier-authlib安装到非标准位置(例如安装到/usr/local下),一定记得在./configure时增加--without-stdheaderdir,这样以后在编译Courier-IMAP和maildrop的时候,不用特别指定courier-authlib的库文件位置
2.投递过程出现如下错误:
May 30 16:08:27 hsf postfix/pipe[25422]: D822E210104: to=<[email protected]>, relay=maildrop, delay=1248, status=deferred (temporary failure. Command output: ERR: authdaemon: s_connect() failed: Permission denied /usr/local/bin/maildrop: Temporary authentication failure. )说明编译authlib时没有指定maildrop的用户和组,加上--with-mailuser和--with-mailgroup 指定用户和组后重编译安装.
增加"/usr/local/courier-authlib/lib/courier-authlib"到"/etc/ld.so.conf",并执行ldconfig命令。 #echo "/usr/local/courier-authlib/lib/courier-authlib" >> /etc/ld.so.conf #ldconfig -v #cp /etc/authdaemonrc.dist /etc/authdaemonrc #vi /etc/authdaemonrc authmodulelist="authmysql" authmodulelistorig="authmysql" daemons=5 authdaemonvar=/usr/local/courier-authlib/var/spool/authdaemon DEBUG_LOGIN=0 DEFAULTOPTIONS="" LOGGEROPTS="" #vi /etc/authmysqlrc MYSQL_SERVER localhost MYSQL_USERNAME extmail MYSQL_PASSWORD extmail MYSQL_SOCKET /tmp/mysql.sock MYSQL_PORT 3306 MYSQL_OPT 0 MYSQL_DATABASE extmail MYSQL_USER_TABLE mailbox MYSQL_CRYPT_PWFIELD password MYSQL_UID_FIELD '1001' MYSQL_GID_FIELD '1001' MYSQL_LOGIN_FIELD username MYSQL_HOME_FIELD concat('/opt/mailbox/',homedir) MYSQL_NAME_FIELD name MYSQL_MAILDIR_FIELD concat('/opt/mailbox/',maildir)启动courier-authlib
#/usr/local/courier-authlib/sbin/authdaemond start安装 cyrus-sasl:
安装 cyrun-sasl 先把系统自带的给卸载了.
#rpm -e `rpm -qa | grep sasl`如果卸载不掉 加上 --nodeps --allmatches选项强制卸载
下载地址:
ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/
#wget ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/cyrus-sasl-2.1.22.tar.gz 安装时最新版本2.1.22 #tar zxvf cyrus-sasl-2.1.22.tar.gz -C ../software/ #cd ../software/cyrus-sasl-2.1.22/ #./configure --prefix=/usr/local/sasl2 --with-mysql=/usr/local/mysql --disable-sample --disable-saslauthd --disable-pwcheck --disable-cram --disable-digest --disable-krb4 --disable-gssapi --disable-anon --enable-plain --enable-login --enable-sql --disable-ntlm --disable-otp --disable-srp --disable-srp-setpass --with-authdaemond=/usr/local/courier-authlib/var/spool/authdaemon/socket --with-mysql-includes=/usr/local/mysql/include/ --with-mysql-libs=/usr/local/mysql/lib/mysql #make #make install #ln -s /usr/local/sasl2/lib/sasl2 /usr/lib/ //这步一定要做..以下步骤做了以后Postfix还是找不到正确的sasl 所以会报验证错误的信息. 添加以下两行: /usr/local/sasl2/lib/sasl2 /usr/local/sasl2/lib 到"/etc/ld.so.conf",并执行ldconfig命令. #vi /usr/local/sasl2/lib/sasl2/smtpd.conf //这个文件是自己创建的 pwcheck_method: authdaemond log_level: 3 mech_list: PLAIN LOGIN authdaemond_path:/usr/local/courier-authlib/var/spool/authdaemon/socket //这个目录与编译时候--with-authdaemond 选项目录相同注意,这个文件的编辑不要多写一个空格,否则会出现smtp验证不过的问题
创建运行时需要的目录并调试启动
# mkdir -pv /var/state/saslauthd # /usr/local/sasl2/sbin/saslauthd -a shadow pam -d如果没有报错.crtl+c结束掉进程 .
# /usr/local/sasl2/sbin/saslauthd -a shadow pam # /usr/local/sasl2/sbin/testsaslauthd -u root -p root用户密码开机自动启动
# echo "/usr/local/sasl2/sbin/saslauthd -a shadow pam">>/etc/rc.local
#tar zxvf db-4.5.20.tar.gz #cd db-4.5.20/build_unix #../dist/configure --prefix=/usr/local/BerkeleyDB #make #make install修改相应的头文件指向
# mv /usr/include/db4 /usr/inculde/db4.OFF # rm /usr/include/db_cxx.h # rm /usr/include/db.h # rm /usr/include/db_185.h # ln -sv /usr/local/BerkeleyDB/include /usr/include/db4 # ln -sv /usr/local/BerkeleyDB/include/db.h /usr/include/db.h # ln -sv /usr/local/BerkeleyDB/include/db_cxx.h /usr/include/db_cxx.h配置库文件搜索路径
# echo "/usr/local/BerkeleyDB/lib" >> /etc/ld.so.conf # ldconfig –v安装postfix
关闭redhat 系统自带的sendmail
#chkconfig --level 2345 sendmail off下载地址:
http://www.postfix.org
#wget ftp://ftp.cuhk.edu.hk/pub/packages/mail-server/postfix/official/postfix-2.8.0.tar.gz下载VDA补丁,使postfix支持磁盘限额
#wget http://vda.sourceforge.net/VDA/postfix-vda-2.8.0.patchpostfix版本:2.8.0,VDA也要下载相应版本补丁.
#tar xvzf postfix-2.8.0.tar.gz -C ../software #mv postfix-vda-2.8.0.patch ../software/postfix-2.8.0/ #cd ../software/postfix-2.8.0/ #make clean #make tidy #patch -p1 < postfix-vda-2.8.0.patch #make -f Makefile.init Makefiles 'CCARGS=-DHAS_MYSQL -I/usr/local/mysql/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/local/sasl2/include/sasl' 'AUXLIBS=-L/usr/local/mysql/lib/mysql -lmysqlclient -lz -lm -L/usr/local/sasl2/lib -lsasl2 -L/usr/local/BerkeleyDB/lib' #make #make install 执行“make install”命令后,期间会需要设置如下一些安装参数,一般都使用默认设置(按回车),如果有特殊需要,直接在后面输入自己的设置,回车即可。 install_root: [/] //指定系统的根目录 tempdir: [/usr/local/src/software/postfix-2.8.0/] //指定postfix-install脚本使用的临时文件目录 config_directory: [/etc/postfix] //设置Postfix的配置文件目录 daemon_directory: [/usr/libexec/postfix] command_directory: [/usr/sbin] //设置Postfix命令的存放目录 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] manpage_directory: [/usr/local/man] readme_directory: [no]下面是我的配置目录:
配置文件目录:/etc/postfix/
服务程序目录:/usr/local/postfix/libexec/
邮件队列目录:/var/spool/postfix/
邮件管理程序目录:/usr/local/postfix/sbin/
日志文件目录: /var/log/maillog
#mv /etc/aliases /etc/aliases.old #ln -s /etc/postfix/aliases /etc/aliases最后 :
生成别名二进制文件,这个步骤如果忽略,会造成postfix效率极低:
#/usr/bin/newaliases
如果编译时候没有加-L/usr/local/BerkeleyDB/lib newaliases会去找系统自带的4.3.29的库.会报错.
检验postfix是否支持sasl认证,如果输出为以下结果,则支持:
#/usr/local/postfix/sbin/postconf -a cyrus dovecot #/usr/local/postfix/sbin/postconf -m | grep mysql mysql没有的话需重新编译 postfix 。如果postconf -a 没有 cyrus 的话注意看下 postfix 编译的关于 cyrus-sasl 的参数有没正确 . 再看下 cyrus-sasl 安装好了没有 .
下面添加生成Mysql验证的一些配置文件:
#touch /etc/postfix/mysql_virtual_alias_maps.cf #touch /etc/postfix/mysql_virtual_domains_maps.cf #touch /etc/postfix/mysql_virtual_mailbox_maps.cf #touch /etc/postfix/mysql_virtual_limit_maps.cf
#vi /etc/postfix/main.cf queue_directory = /var/spool/postfix command_directory = /usr/local/postfix/sbin daemon_directory = /usr/local/postfix/libexec myhostname = mail.hsf.com mydomain = hsf.com inet_interfaces = all mydestination = unknown_local_recipient_reject_code = 550 mynetworks = 168.100.189.0/28, 127.0.0.0/8, 10.9.0.0/24, 10.0.0.0/24 alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases 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 newaliases_path = /usr/bin/newaliases mailq_path = /usr/bin/mailq setgid_group = postdrop html_directory = no manpage_directory = /usr/local/postfix/man sample_directory = /etc/postfix readme_directory = no ##====================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, permit smtpd_sasl_auth_enable = yes smtpd_sasl_local_domain = $myhostname smtpd_sasl_security_options = noanonymous smtpd_sasl_application_name = smtpd smtpd_banner = $myhostname ESMTP $mail_name ($mail_version) #================ Virtual Mailbox Settings =====================# virtual_mailbox_base = /opt/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:1001 virtual_gid_maps = static:1001 virtual_transport = maildrop maildrop_destination_recipient_limit = 1 maildrop_destination_concurrency_limit = 1 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
编辑前面生成的一些Mysql相关的cf配置文件:
#vi /etc/postfix/mysql_virtual_alias_maps.cf user = extmail password = extmail hosts = localhost dbname = extmail table = alias select_field = goto where_field = address additional_conditions = AND active = '1' ================================= #vi /etc/postfix/mysql_virtual_domains_maps.cf user = extmail password = extmail hosts = localhost dbname = extmail table = domain select_field = description where_field = domain additional_conditions = AND active = '1' ================================= #vi /etc/postfix/mysql_virtual_mailbox_maps.cf user = extmail password = extmail hosts = localhost dbname = extmail table = mailbox select_field = maildir where_field = username additional_conditions = AND active = '1' ================================= #vi /etc/postfix/mysql_virtual_limit_maps.cf user = extmail password = extmail hosts = localhost dbname = extmail table = mailbox select_field = quota where_field = username additional_conditions = AND active = '1' 启动和停止postfix服务: #/usr/local/postfix/sbin/postfix start #/usr/local/postfix/sbin/postfix stop安装Courier-IMAP
下载地址:
http://prdownloads.sourceforge.net/courier
目前最新版4.9.3
#wget http://sourceforge.net/projects/courier/files/imap/4.9.3/courier-imap-4.9.3.tar.bz2/download #tar jvxf courier-imap-4.9.3.tar.bz2 -C ../software/ #cd ../software/courier-imap-4.9.3/ #./configure --prefix=/usr/local/courier-imap --with-redhat --enable-unicode --disable-root-check --with-trashquota --without-ipv6 CPPFLAGS='-I/usr/local/courier-authlib/include' COURIERAUTHCONFIG='/usr/local/courier-authlib/bin/courierauthconfig' #####CPPFLAGS='-I/usr/local/courier-authlib/include' 如果编译courier-authlib没有安装在默认路径,必须指定这个,如果之前编译courier-authlib加了--without-stdheaderdir,就不需要指定了. 没有加COURIERAUTHCONFIG='/usr/local/courier-authlib/bin/courierauthconfig'会出现: checking for courierauthconfig... no configure: WARNING: === Courier authentication library not found. configure: WARNING: === You need to download and install configure: WARNING: === http://www.courier-mta.org/download.php#authlib first. configure: WARNING: === If courier-authlib is installed in a non-default configure: WARNING: === directory, set the COURIERAUTHCONFIG environment configure: WARNING: === variable to the full path to the courierauthconfig configure: WARNING: === binary and rerun this configure script. configure: WARNING: configure: error: courierauthconfig not found 解决方法 #export COURIERAUTHCONFIG=/usr/local/courier-authlib/bin/courierauthconfig 再执行configure.命令 #make #make install 建立配置文件 #cd /usr/local/courier-imap/etc #ls *.dist | awk -F"." '{print "cp "$0" "$1""}' | sh 打开pop3,imapd支持,修改MAILPATH #vi /usr/local/courier-imap/etc/pop3d POP3DSTART=YES MAILDIRPATH=/opt/mailbox #vi /usr/local/courier-imap/etc/imapd IMAPDSTART=YES MAILPATH=/opt/mailbox 加入开机启动 #cp courier-imap.sysvinit /etc/init.d/imapd #chmod 755 /etc/init.d/imapd #chkconfig --add imapd #chkconfig --level 2345 imapd on #service imapd start 检测: #netstat -tnl |egrep "110|143"安装maildrop
下载地址:http://sourceforge.net/projects/courier/files/maildrop/
目前最新版本:2.5.4
http://sourceforge.net/projects/courier/files/maildrop/2.5.4/maildrop-2.5.4.tar.bz2/download
将courier-authlib的头文件及库文件链接至/usr目录(编译maildrop时会到此目录下找此些相关的文件):
# ln -sv /usr/local/courier-authlib/bin/courierauthconfig /usr/bin # ln -sv /usr/local/courier-authlib/include/* /usr/include1、 maildrop 需要 pcre 的支持,因此,接下来将首先安装 pcre
#tar zxvf pcre-7.9.tar.gz -C ../software/ # cd ../software/pcre-7.9/ # ./configure # make # make check # make install # tar jxvf maildrop-2.5.4.tar.bz2 -C ../software/ #cd ../software/maildrop-2.5.4/ # cd maildrop-2.5.4 # ./configure --enable-sendmail=/usr/sbin/sendmail --enable-trusted-users='root vmail' --enable-syslog=1 --enable-maildirquota --enable-maildrop-uid=1001 --enable-maildrop-gid=1001 --with-trashquota --with-dirsync # make # make install
检查安装结果,请确保有"Courier Authentication Library extension enabled."一句出现:
# maildrop -v maildrop 2.5.4 Copyright 1998-2005 Double Precision, Inc. ///注意看下这个版本是不是2.5.4是否是现在安装的.如果不是的话可能就是系统自带的.要把系统自带的卸载了再安装一遍.或者把/usr/local/bin/maildrop删了.再安装一遍也可以 . GDBM extensions enabled. Courier Authentication Library extension enabled. Maildir quota extension enabled. This program is distributed under the terms of the GNU General Public License. See COPYING for additional information.
2、新建其配置文件/etc/maildroprc文件,首先指定maildrop的日志记录位置:
# vi /etc/maildroprc 添加: logfile "/var/log/maildrop.log" # touch /var/log/maildrop.log # chown vmail.vmail /var/log/maildrop.log3 、配置 Postfix
编辑master.cf
# vi /etc/postfix/master.cf 启用如下两行 maildrop unix - n n - - pipe flags=DRhu user=vmail argv=/usr/local/bin/maildrop -d ${recipient} //注意:定义transport的时候,即如上两行中的第二行,其参数行必须以空格开头,否则会出错。
编辑main.cf
# vi /etc/postfix/main.cf virtual_transport = maildrop virtual_uid_maps = static:1001 virtual_gid_maps = static:10014 、编辑 /etc/authmysqlrc
# vi /etc/authmysqrc MYSQL_UID_FIELD '1001' MYSQL_GID_FIELD '1001'5 、编辑 /etc/httpd/httpd.conf ,修改运行用户 :
如果启用了suexec的功能,则将虚拟主机中指定的
SuexecUserGroup vmail vmail
如果没有使用上面的功能,则修改User和Group指令后的用户为vmail
将前文中的如下项
User postfix Group postfix修改为:
User vmail Group vmail6 、将用户邮件所在的目录/opt/mailbox和 extman 的临时目录 /tmp/extman 的属主和属组指定为 vmail
#mkdir /tmp/extman #chown -R vmail.vmail /opt/mailbox #chown -R vmail.vmail /tmp/extman
#tar zxvf extman-1.1.tar.gz -C ../software/ #mv ../software/extman-1.1/ /opt/www/extman #cd /opt/www/extman/ #chown -R vmail.vmail /opt/www/extman #mv webman.cf.default webman.cf
#vi webman.cf SYS_CONFIG = /opt/www/extman/ SYS_LANGDIR = /opt/www/extman/lang SYS_TEMPLDIR = /opt/www/extman/html SYS_MAILDIR_BASE = /opt/mailbox SYS_SHOW_WARN = 0 SYS_SESS_DIR = /tmp/extman/ SYS_CAPTCHA_ON = 1 SYS_CAPTCHA_KEY = r3s9b6a7 SYS_CAPTCHA_LEN = 6 SYS_PURGE_DATA = 0 SYS_PSIZE = 20 SYS_APP_TYPE = ExtMan SYS_TEMPLATE_NAME = default SYS_DEFAULT_EXPIRE = 1y SYS_GROUPMAIL_SENDER = [email protected] SYS_DEFAULT_SERVICES = webmail,smtpd,smtp,pop3,netdisk SYS_ISP_MODE = no SYS_DOMAIN_HASHDIR = yes SYS_DOMAIN_HASHDIR_DEPTH = 2x2 SYS_USER_HASHDIR = yes SYS_USER_HASHDIR_DEPTH = 2x2 SYS_MIN_UID = 500 SYS_MIN_GID = 100 SYS_DEFAULT_UID = 1001 SYS_DEFAULT_GID = 1001 SYS_QUOTA_MULTIPLIER = 1048576 SYS_QUOTA_TYPE = courier SYS_DEFAULT_MAXQUOTA = 500 SYS_DEFAULT_MAXALIAS = 100 SYS_DEFAULT_MAXUSERS = 100 SYS_DEFAULT_MAXNDQUOTA = 500 SYS_USER_DEFAULT_QUOTA = 5 SYS_USER_DEFAULT_NDQUOTA = 5 SYS_USER_DEFAULT_EXPIRE = 1y SYS_BACKEND_TYPE = mysql SYS_CRYPT_TYPE = md5crypt SYS_MYSQL_USER = extmail SYS_MYSQL_PASS = extmail SYS_MYSQL_DB = extmail SYS_MYSQL_HOST = localhost SYS_MYSQL_SOCKET = /tmp/mysql.sock SYS_MYSQL_TABLE = manager SYS_MYSQL_ATTR_USERNAME = username SYS_MYSQL_ATTR_PASSWD = password SYS_LDAP_BASE = dc=extmail.org SYS_LDAP_RDN = cn=Manager,dc=extmail.org SYS_LDAP_PASS = secret SYS_LDAP_HOST = localhost SYS_LDAP_ATTR_USERNAME = mail SYS_LDAP_ATTR_PASSWD = userPassword SYS_RRD_DATADIR = /var/lib SYS_RRD_TMPDIR = /tmp/viewlog SYS_RRD_QUEUE_ON = yes SYS_CMDSERVER_SOCK = /tmp/cmdserver.sock SYS_CMDSERVER_MAXCONN = 5 SYS_CMDSERVER_PID = /var/run/cmdserver.pid SYS_CMDSERVER_LOG = /var/log/cmdserver.log SYS_CMDSERVER_AUTHCODE = your_auth_code_here SYS_IGNORE_SERVER_LIST = web
#cd /usr/local/src/tarbag/ #tar zxvf extmail-1.2.tar.gz -C /opt/www/ #cd /opt/www/ #mv extmail-1.2/ extmail #chown vmail.vmail -R extmail/ #cd extmail/ #mv webmail.cf.default webmail.cf修改extmail配置文件
#vi webmail.cf SYS_CONFIG = /opt/www/extmail/ SYS_LANGDIR = /opt/www/extmail/lang SYS_TEMPLDIR = /opt/www/extmail/html SYS_HTTP_CACHE = 0 SYS_SMTP_HOST = 127.0.0.1 SYS_SMTP_PORT = 25 SYS_SMTP_TIMEOUT = 5 SYS_SPAM_REPORT_ON = 0 SYS_SPAM_REPORT_TYPE = dspam SYS_SHOW_WARN = 0 SYS_IP_SECURITY_ON = 1 SYS_PERMIT_NOQUOTA = 1 SYS_SESS_DIR = /tmp SYS_UPLOAD_TMPDIR = /tmp SYS_LOG_ON = 1 SYS_LOG_TYPE = syslog SYS_LOG_FILE = /var/log/extmail.log SYS_SESS_TIMEOUT = 0 SYS_SESS_COOKIE_ONLY = 1 SYS_USER_PSIZE = 10 SYS_USER_SCREEN = auto SYS_USER_LANG = en_US SYS_APP_TYPE = WebMail SYS_USER_TEMPLATE = default SYS_USER_CHARSET = utf-8 SYS_USER_TRYLOCAL = 1 SYS_USER_TIMEZONE = +0800 SYS_USER_CCSENT = 1 SYS_USER_SHOW_HTML = 1 SYS_USER_COMPOSE_HTML = 1 SYS_USER_CONV_LINK =1 SYS_USER_ADDR2ABOOK = 1 SYS_MESSAGE_SIZE_LIMIT = 5242880 SYS_MIN_PASS_LEN = 2 SYS_MFILTER_ON = 1 SYS_NETDISK_ON = 1 SYS_SHOW_SIGNUP = 1 SYS_DEBUG_ON = 1 SYS_AUTH_TYPE = mysql SYS_MAILDIR_BASE = /opt/mailbox SYS_AUTH_SCHEMA = virtual SYS_CRYPT_TYPE = md5crypt SYS_MYSQL_USER = extmail SYS_MYSQL_PASS = extmail SYS_MYSQL_DB = extmail SYS_MYSQL_HOST = localhost SYS_MYSQL_SOCKET = /tmp/mysql.sock SYS_MYSQL_TABLE = mailbox SYS_MYSQL_ATTR_USERNAME = username SYS_MYSQL_ATTR_DOMAIN = domain SYS_MYSQL_ATTR_PASSWD = password SYS_MYSQL_ATTR_CLEARPW = clearpwd SYS_MYSQL_ATTR_QUOTA = quota SYS_MYSQL_ATTR_NDQUOTA = netdiskquota SYS_MYSQL_ATTR_HOME = homedir SYS_MYSQL_ATTR_MAILDIR = maildir SYS_MYSQL_ATTR_DISABLEWEBMAIL = disablewebmail SYS_MYSQL_ATTR_DISABLENETDISK = disablenetdisk SYS_MYSQL_ATTR_DISABLEPWDCHANGE = disablepwdchange SYS_MYSQL_ATTR_ACTIVE = active SYS_MYSQL_ATTR_PWD_QUESTION = question SYS_MYSQL_ATTR_PWD_ANSWER = answer SYS_LDAP_BASE = o=extmailAccount,dc=example.com SYS_LDAP_RDN = cn=Manager,dc=example.com SYS_LDAP_PASS = secret SYS_LDAP_HOST = localhost SYS_LDAP_ATTR_USERNAME = mail SYS_LDAP_ATTR_DOMAIN = virtualDomain SYS_LDAP_ATTR_PASSWD = userPassword SYS_LDAP_ATTR_CLEARPW = clearPassword SYS_LDAP_ATTR_QUOTA = mailQuota SYS_LDAP_ATTR_NDQUOTA = netdiskQuota SYS_LDAP_ATTR_HOME = homeDirectory SYS_LDAP_ATTR_MAILDIR = mailMessageStore SYS_LDAP_ATTR_DISABLEWEBMAIL = disablewebmail SYS_LDAP_ATTR_DISABLENETDISK = disablenetdisk SYS_LDAP_ATTR_DISABLEPWDCHANGE = disablePasswdChange SYS_LDAP_ATTR_ACTIVE = active SYS_LDAP_ATTR_PWD_QUESTION = question SYS_LDAP_ATTR_PWD_ANSWER = answer SYS_AUTHLIB_SOCKET = /var/spool/authdaemon/socket SYS_G_ABOOK_TYPE = file SYS_G_ABOOK_LDAP_HOST = localhost SYS_G_ABOOK_LDAP_BASE = ou=AddressBook,dc=example.com SYS_G_ABOOK_LDAP_ROOTDN = cn=Manager,dc=example.com SYS_G_ABOOK_LDAP_ROOTPW = secret SYS_G_ABOOK_LDAP_FILTER = objectClass=OfficePerson SYS_G_ABOOK_FILE_PATH = /opt/www/extmail/globabook.cf SYS_G_ABOOK_FILE_LOCK = 1 SYS_G_ABOOK_FILE_CONVERT = 0 SYS_G_ABOOK_FILE_CHARSET = utf-8
#vi /usr/local/apache2.2.15/conf/extra/httpd-vhosts.conf <VirtualHost *:80> ServerAdmin [email protected] ServerName 10.0.0.20 ServerAlias mail.hsf.com DocumentRoot /opt/www/extmail/html ScriptAlias /extmail/cgi /opt/www/extmail/cgi Alias /extmail /opt/www/extmail/html ScriptAlias /extman/cgi /opt/www/extman/cgi Alias /extman /opt/www/extman/html SuexecUserGroup vmail vmail <Directory /opt/www> Authtype basic Options execcgi Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> </VirtualHost> #/usr/local/apache2.2.15/bin/apachectl -t #/usr/local/apache2.2.15/bin/apachectl -k restart
#cd /usr/local/src/tarbag #tar zxvf slockd-0.99.tar.gz -C ../software/ #cd ../software/slockd/ #mv slockd/ /usr/local/ #/usr/local/slockd/slockd-init start #cd /var/run/ #mkdir extmail #/opt/www/extman/daemon/cmdserver -v -d #cd /opt/www/extman/addon #cp -r mailgraph_ext/ /usr/local/ #/usr/local/mailgraph_ext/mailgraph-init start 如果报这个错:Can’t locate RRDs.pm in @INC 解决办法: # cp -rp /usr/local/rrdtool/lib/perl/5.8.8/x86_64-linux-thread-multi/* /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/ 如果报这个错:Can't locate File/Tail.pm in @INC 解决方法为: #cpan cpan>install File::Tail cpan>quit导入数据库
#cd /opt/www/extman/docs # /usr/local/mysql/bin/mysql -u root -p < extmail.sql Enter password: # /usr/local/mysql/bin/mysql -u root -p < init.sql Enter password: # /usr/local/mysql/bin/mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.1.36-log Source distribution Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | aclocal | | extmail | | mysql | | test | +--------------------+ 5 rows in set (0.04 sec) mysql> use extmail; Database changed mysql> show tables; +-------------------+ | Tables_in_extmail | +-------------------+ | alias | | domain | | domain_manager | | mailbox | | manager | +-------------------+ 5 rows in set (0.01 sec) mysql> grant all privileges on extmail.* to extmail@'localhost' identified by 'extmail'; Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)extman默认管理帐号为:[email protected] 密码为:extmail*123*
#/usr/local/apache2.2.15/bin/apachectl -k restart启动后访问extman如果验证码出不来是一个perl的GD库没有装
#cd /usr/local/src/tarbag/ #tar zxvf GD-2.35.tar.gz -C ../software #perl Makefile.PL #make #make install图形日志没有显示 .是因为rrdtool没有装
#cd /usr/local/src/tarbag/ #tar xvf rrdtool-1.4.3.tar.gz -C ../software/ #cd ../software/rrdtool-1.4.3/ #./configure --prefix=/usr/local/rrdtool #make #make install
Can't locate DBI.pm in @INC 错误,用yum 安装下perl-DBI.x86_64 模块就好. Can't locate DBD/mysql.pm 错误,用yum 安装下perl-DBD-MySQL.x86_64 模块. 如果yum无法安装可以去下载DBD-mysql-3.0007 源码包.编译方法如下: perl Makefile.PL --libs="-L/usr/local/mysql/lib/mysql/ -lmysqlclient -lz" --cflags=-I/usr/local/mysql/include/mysql/ make make install Unix::Syslog not found,. 错误,安装Unix-Syslog模块.
Aug 7 22:26:22 mail postfix/smtpd[16829]: warning: xsasl_cyrus_server_get_mechanism_list: no applicable SASL mechanisms Aug 7 22:26:22 mail postfix/smtpd[16829]: fatal: no SASL authentication mechanisms Aug 7 22:26:23 mail postfix/master[16825]: warning: process /usr/libexec/postfix/smtpd pid 16829 exit status 1 Aug 7 22:26:23 mail postfix/master[16825]: warning: /usr/libexec/postfix/smtpd: bad command startup -- throttling Aug 7 22:28:06 mail postfix/smtpd[16830]: warning: xsasl_cyrus_server_get_mechanism_list: no applicable SASL mechanisms Aug 7 22:28:06 mail postfix/smtpd[16830]: fatal: no SASL authentication mechanisms Aug 7 22:28:07 mail postfix/master[16825]: warning: process /usr/libexec/postfix/smtpd pid 16830 exit status 1
Sep 2 19:00:27 localhost postfix/smtpd[913]: fatal: no SASL authentication mechanisms Sep 2 19:00:28 localhost postfix/master[26948]: warning: process /usr/local/postfix/libexec/smtpd pid 913 exit status 1 Sep 2 19:00:28 localhost postfix/master[26948]: warning: /usr/local/postfix/libexec/smtpd: bad command startup -- throttling Sep 2 19:10:28 localhost postfix/smtpd[6083]: connect from localhost.localdomain[127.0.0.1] Sep 2 19:10:28 localhost postfix/smtpd[6083]: warning: xsasl_cyrus_server_get_mechanism_list: no applicable SASL mechanisms
# ln -s /usr/local/lib/sasl2 /usr/lib/问题二:
Sep 24 18:05:05 extmail postfix/smtpd[4510]: warning: SASL authentication failure: cannot connect to Courier authdaemond: Permission denied Sep 24 18:05:05 extmail postfix/smtpd[4510]: warning: extmail[127.0.0.1]: SASL login authentication failed: generic failure
#cat /etc/rc.local /usr/local/apache2.2.14/bin/apachectl -k start /usr/local/sasl2/sbin/saslauthd -a shadow pam /usr/local/postfix/sbin/postfix start /opt/www/extman/daemon/cmdserver -d /usr/local/slockd/slockd-init start /usr/local/mailgraph_ext/mailgraph-init start /usr/local/courier-authlib/sbin/authdaemond start /opt/www/extmail/dispatch-init start service imapd start service mysqld start