|
我的LFS是用jhalfs自动编译的,同时编译安装了libxml2/libxslt/wget/sudo/lynx等,编译完成后,按照blfs中的方案设置了环境变量,安装了openssl和openssh。
就这些,现在开始安装Email服务器。参考了网上好多安装安装postfix/extmail的资料,大多是基于redhat的
0. 开始
- # export CFLAGS="-O5 -pipe"
- # export CXXFLAGS="-O5 -pipe"
复制代码 呵,优化一下,希望能运行快点。
1. MySQL-5.0.41(习惯用这个版本了)
- # groupadd -g 40 mysql &&
- useradd -c "MySQL Server" -d /dev/null -g mysql -s /bin/false \
- -u 40 mysql
复制代码- # C_EXTRA_FLAGS=-fno-strict-aliasing \
- ./configure --prefix=/usr \
- --sysconfdir=/etc \
- --libexecdir=/usr/sbin \
- --localstatedir=/srv/mysql \
- --enable-thread-safe-client \
- --enable-assembler \
- --enable-local-infile \
- --with-unix-socket-path=/var/run/mysql/mysql.sock \
- --without-debug \
- --without-bench \
- --without-readline \
- --with-berkeley-db \
- --with-openssl=/usr \
- --with-charset=utf8 \
- --with-extra-charsets=all &&
- make testdir=/tmp/mysql
复制代码 呵,blfs中抄来的,我比较懒,略微变了下
- # make testdir=/tmp/mysql install &&
- rm -rf /tmp/mysql &&
- cd /usr/lib &&
- ln -v -sf mysql/libmysqlclient{,_r}.so* .
复制代码- # install -v -m644 /usr/share/mysql/my-huge.cnf /etc/my.cnf
- # mysql_install_db --user=mysql &&
- chgrp -v mysql /srv/mysql{,/test,/mysql}
复制代码
到blfs-bootscripts-20090302目录中执行
2. 必须的一些软件包
- # cd jpeg-6b/
- # ./configure --prefix=/usr --enable-static --enable-shared &&
- make&&make install
复制代码- # cd libpng-1.2.35/
- # ./configure --prefix=/usr &&
- make
- make install &&
- install -v -m755 -d /usr/share/doc/libpng-1.2.35 &&
- install -v -m644 README libpng-1.2.35.txt \
- /usr/share/doc/libpng-1.2.35
复制代码- # cd freetype-2.3.8/
- # sed -i -r -e 's:.*(#.*BYTE.*) .*:\1:' \
- -e 's:.*(#.*SUBPIX.*) .*:\1:' \
- include/freetype/config/ftoption.h &&
- ./configure --prefix=/usr &&
- make && make install &&
- install -v -m755 -d /usr/share/doc/freetype-2.3.8 &&
- cp -v -R docs/* /usr/share/doc/freetype-2.3.8
复制代码- # wget http://downloads.sourceforge.net/expat/expat-2.0.1.tar.gz
- # tar xvf expat-2.0.1.tar.gz
- # cd expat-2.0.1/
- # ./configure --prefix=/usr &&
- make && make install &&
- install -v -m755 -d /usr/share/doc/expat-2.0.1 &&
- install -v -m644 doc/*.{html,png,css} /usr/share/doc/expat-2.0.1
复制代码- # cd pkg-config-0.23/
- # ./configure --prefix=/usr &&
- make && make install
复制代码- # cd fontconfig-2.6.0/
- # ./configure --prefix=/usr \
- --sysconfdir=/etc --localstatedir=/var \
- --disable-docs --without-add-fonts \
- --with-docdir=/usr/share/doc/fontconfig-2.6.0 &&
- make && make install
复制代码- # cd gd-2.0.35/
- # ./configure --prefix=/usr &&
- make && make install
复制代码
- root [ ~ ]# perl -MCPAN -e shell
- Terminal does not support AddHistory.
- cpan shell -- CPAN exploration and modules installation (v1.9205)
- ReadLine support available (maybe install Bundle::CPAN or Bundle::CPANxxl?)
- cpan[1]> install CPAN
- cpan[2]> reload cpan
- cpan[3]> install YAML
- cpan[4]> install Unix::Syslog
- cpan[5]> install GD
- cpan[6]> install DBI
- cpan[7]> install DBD::mysql
- cpan[8]> quit
复制代码
其它的支持包后面现用现装。
4. courier-authlib
4.1 courier-authlib需要gdbm-1.8.3的支持
- # cd gdbm-1.8.3
- # ./configure --prefix=/usr &&
- make
- # make BINOWN=root BINGRP=root install
- # make BINOWN=root BINGRP=root install-compat
复制代码
4.2 Tcl-8.5.6(Expect需要它)
- # cd unix &&
- ./configure --prefix=/usr \
- --enable-threads \
- --mandir=/usr/share/man &&
- make &&
- sed -i \
- -e "s@^\(TCL_SRC_DIR='\).*@\1/usr/include'@" \
- -e "/TCL_B/s@='\(-L\)\?.*unix@='\1/usr/lib@" \
- -e "/SEARCH/s/=.*/=''/" \
- tclConfig.sh
- # make install &&
- make install-private-headers &&
- ln -v -sf tclsh8.5 /usr/bin/tclsh
复制代码
4.3 Expect-5.43.0
如果不装它,在编译courier-authlib的时候会有提示修改不了用户密码。
注意这儿的补丁与blfs中的不同,否则你可能编译不了哦
- # patch -Np1 -i ../expect-5.43.0-tcl_8.5.5_fix-1.patch &&
- patch -Np1 -i ../expect-5.43.0-spawn-1.patch &&
- ./configure --prefix=/usr \
- --with-tcl=/usr/lib \
- --with-tclinclude=/usr/include \
- --enable-shared &&
- make
- # make install &&
- ln -sf ../libexpect5.43.a /usr/lib/expect5.43
复制代码
4.4 courier-authlib-0.62.2
- # cd courier-authlib-0.62.2/
- # ./configure --prefix=/usr \
- --sysconfdir=/etc \
- --localstatedir=/var \
- --with-db=gdbm \
- --with-authmysql=yes \
- --with-mysql-libs=/usr/lib/mysql \
- --with-mysql-includes=/usr/include/mysql \
- --without-stdheaderdir
- # make &&
- make install &&
- make install-configure
复制代码
配置其自动启动
- # cat > /etc/rc.d/init.d/authdaemond <<EOF
- #!/bin/sh
- # Begin \$rc_base/init.d/authdaemond
- # Based on sysklogd script from LFS-3.1 and earlier.
- # Written by Mikko Yue - mikkoyue@hotmail.com
- . /etc/sysconfig/rc
- . \$rc_functions
- case "\$1" in
- start)
- /usr/sbin/authdaemond start
- evaluate_retval
- ;;
- stop)
- boot_mesg "Stopping authdaemond daemon..."
- /usr/sbin/authdaemond stop
- evaluate_retval
- ;;
- restart)
- boot_mesg "Restarting authdaemond daemon..."
- /usr/sbin/authdaemond restart
- evaluate_retval
- ;;
- *)
- echo "Usage: \$0 {start|stop|restart}"
- exit 1
- ;;
- esac
- # End \$rc_base/init.d/authdaemond
- EOF
复制代码
- # chmod +x /etc/rc.d/init.d/authdaemond &&
- ln -s ../init.d/authdaemond /etc/rc.d/rc0.d/K71authdaemond &&
- ln -s ../init.d/authdaemond /etc/rc.d/rc1.d/K71authdaemond &&
- ln -s ../init.d/authdaemond /etc/rc.d/rc3.d/S21authdaemond &&
- ln -s ../init.d/authdaemond /etc/rc.d/rc5.d/K21authdaemond &&
- ln -s ../init.d/authdaemond /etc/rc.d/rc6.d/K21authdaemond
复制代码
修改目录权限,如果该目录权限不正确修改,maildrop及postfix等将无法正确获取用户的信息及密码认证
- # chmod 755 /var/spool/authdaemon
复制代码
配置- # mv /etc/authlib/authmysqlrc{,.old} && cat > /etc/authlib/authmysqlrc <<EOF
- MYSQL_SERVER localhost
- MYSQL_USERNAME extmail
- MYSQL_PASSWORD extmail
- MYSQL_SOCKET /var/run/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
复制代码
启动服务
- # /etc/rc.d/init.d/authdaemond start
复制代码
5. 安装配置cyrus-sasl
- # cd cyrus-sasl-2.1.22
- # ./configure --prefix=/usr \
- --sysconfdir=/etc \
- --enable-plain \
- --enable-cram \
- --enable-digest \
- --enable-login \
- --enable-sql \
- --disable-anon \
- --disable-ntlm \
- --disable-gssapi \
- --disable-krb4 \
- --disable-otp \
- --disable-srp \
- --disable-srp-setpass \
- --with-authdaemond=/var/spool/authdaemon/socket \
- --with-mysql=/usr
- # make && make install
复制代码
配置
- # cat >> /usr/lib/sasl2/smtpd.conf <<EOF
- pwcheck_method: authdaemond
- log_level: 3
- mech_list: PLAIN LOGIN
- authdaemond_path:/var/spool/authdaemon/socket
- EOF
- # ln -s /usr/lib/sasl2/smtpd.conf /etc
复制代码
6. Postfix-2.5.1
- # groupadd -g 32 postfix &&
- groupadd -g 33 postdrop &&
- useradd -c "Postfix Daemon User" -d /dev/null -g postfix \
- -G postdrop -s /bin/false -u 32 postfix &&
- chown -v postfix:postfix /var/mail
复制代码- # cd postfix-2.5.1
- # make makefiles \
- CCARGS='-DUSE_TLS -DUSE_SASL_AUTH -DUSE_CYRUS_SASL \
- -DDEF_DAEMON_DIR="/usr/lib/postfix" \
- -DDEF_MANPAGE_DIR="/usr/share/man" \
- -DDEF_HTML_DIR="/usr/share/doc/postfix-2.5.1/html" \
- -DDEF_README_DIR="/usr/share/doc/postfix-2.5.1/README" \
- -I/usr/include/openssl -I/usr/include/sasl \
- -DHAS_MYSQL -I/usr/include/mysql \
- -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl' \
- AUXLIBS='-L/usr/lib -lssl -lcrypto -lsasl2 -L/usr/lib/mysql -lmysqlclient -lz -lm'
- # make && sh postfix-install -non-interactive
复制代码
配置运行,顺序执行如下命令
- # ln -s /etc/postfix/aliases /etc/aliases
- # echo 'root: admin@example.com'>>/etc/postfix/aliases
- # /usr/bin/newaliases
- # mv /etc/postfix/main.cf /etc/postfix/main.cf.old
- # postconf -n > /etc/postfix/main.cf
- # cat >> /etc/postfix/main.cf <<EOF
- # hostname
- mynetworks = 127.0.0.1
- # 修改下面的域名为你的域名
- myhostname = mail.extmail.org
- # 修改下面的域名为你的
- mydomain = extmai.com
- myorigin = \$mydomain
- mydestination = \$mynetworks \$myhostname
- # banner
- mail_name = Postfix - by extmail.org
- smtpd_banner = \$myhostname ESMTP \$mail_name
- # response immediately
- smtpd_error_sleep_time = 0s
- unknown_local_recipient_reject_code = 450
- # 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 > /etc/postfix/mysql_virtual_alias_maps.cf <<EOF
- user = extmail
- password = extmail
- hosts = localhost
- dbname = extmail
- table = alias
- select_field = goto
- where_field = address
- EOF
- # cat > /etc/postfix/mysql_virtual_domains_maps.cf <<EOF
- user = extmail
- password = extmail
- hosts = localhost
- dbname = extmail
- table = domain
- select_field = description
- where_field = domain
- #additional_conditions = and backupmx ='0' and active ='1'
- EOF
- # cat > /etc/postfix/mysql_virtual_mailbox_maps.cf <<EOF
- user = extmail
- password = extmail
- hosts = localhost
- dbname = extmail
- table = mailbox
- select_field = maildir
- where_field = username
- #additional_conditions = and active = '1'
- EOF
- # cat >> /etc/postfix/main.cf <<EOF
- # smtpd related config
- smtpd_recipient_restrictions = \
- permit_mynetworks, \
- permit_sasl_authenticated, \
- reject_non_fqdn_hostname, \
- reject_non_fqdn_sender, \
- reject_non_fqdn_recipient, \
- reject_unauth_destination, \
- reject_unauth_pipelining, \
- reject_invalid_hostname,
- # SMTP AUTH config here
- broken_sasl_auth_clients = yes
- smtpd_sasl_auth_enable = yes
- smtpd_sasl_local_domain = \$myhostname
- smtpd_sasl_security_options = noanonymous
- EOF
复制代码
到blfs-bootscripts目录下运行
7. 安装配置maildrop
据说需要pcre,如果不装会有什么情况我没测试,就装上了
- # cd pcre-7.6
- # patch -Np1 -i ../pcre-7.6-abi_breakage-1.patch &&
- patch -Np1 -i ../pcre-7.6-security_fix-1.patch &&
- ./configure --prefix=/usr \
- --docdir=/usr/share/doc/pcre-7.6 \
- --enable-utf8 \
- --enable-pcregrep-libz \
- --enable-pcregrep-libbz2 &&
- make && make install &&
- mv -v /usr/lib/libpcre.so.* /lib/ &&
- ln -v -sf ../../lib/libpcre.so.0 /usr/lib/libpcre.so
复制代码- # groupadd -g 1000 vgroup &&
- useradd -g 1000 -u 1000 -s /bin/false vuser
- # cd maildrop-2.0.4
- # ./configure --prefix=/usr \
- --enable-sendmail=/usr/sbin/sendmail \
- --enable-trusted-users='root vuser' \
- --enable-syslog=1 \
- --enable-maildirquota \
- --enable-maildrop-uid=1000 \
- --enable-maildrop-gid=1000 \
- --with-trashquota \
- --with-dirsync
- # make && make install
复制代码
运行命令“maildrop -v”如果出现的信息中有一行是“Courier Authentication Library extension enabled.”则表示安装成功。
配置main.cf和master.cf使postfix调用maildrop
- # echo "maildrop_destination_recipient_limit = 1" >> /etc/postfix/main.cf
复制代码
# vi /etc/postfix/master.cf
把maildrop unix - n n - - pipe注释符号“#”去掉
#flags=DRhu user=vmail argv=/usr/local/bin/maildrop -d ${recipient}这行
改为flags=DRhu user=vuser argv=/usr/bin/maildrop -w 90 -d ${user}@${nexthop} ${recipient} ${user} ${extension} {nexthop}
此处要注意argv=后边的maildrop要加上路径,否则会出现
temporary failure. Command output: pipe: fatal: pipe_command: execvp maildrop: No such file or directory
注意maildrop unix这行前边不能有空格,要不会出现以下错误提示
warning: connect to transport maildrop: No such file or directory
Oct 31 23:21:24 localhost postfix/error[2235]: BE0AE27DAF6: to=<jjq002@abc.com>,relay=none,delay=1443,delays=1443/0.24/0/0.02,dsn=4.3.0, status=deferred (mail transport unavailable)
注意flags=Drhu这一行前边有两个空格,要不会出现以下错(fatal: /etc/postfix/master.cf: line 100: bad transport type: user=vuser)。
8. apache(httpd-2.2.6)
- # groupadd -g 25 apache &&
- useradd -c "Apache Server" -d /dev/null -g apache \
- -s /bin/false -u 25 apache
- # ./configure --prefix=/usr/local/apache \
- --enable-ssl --with-ssl=/usr \
- --enable-dav --enable-cgi \
- --enable-rewrite --enable-so \
- --with-mpm=worker
- # make && make install
- # sed -i -e "s/User daemon/User apache/" \
- -e "s/Group daemon/Group apache/" \
- /usr/local/apache/conf/httpd.conf
- # cp /usr/local/apache/bin/apachectl{,-ssl}
- # cp /usr/local/apache/conf/http{,s}d.conf
- # sed -e "s:$HTTPD -k $ARGV:$HTTPD -f /usr/local/apache/conf/httpsd.conf -k $ARGV:" \
- -i /usr/local/apache/bin/apachectl-ssl
- # sed -e "s/Listen 80/Listen 8080/" \
- -e "s/User apache/User vuser/" \
- -e "s/Group apache/Group vgroup/" \
- -e "s:/usr/local/apache/htdocs:/srv/webmail:" \
- -e "s/DirectoryIndex index.html/DirectoryIndex index.html index.cgi/" \
- -e "s:#Include conf/extra/httpd-ssl.conf:Include conf/extra/httpd-ssl.conf:" \
- -i /usr/local/apache/conf/httpsd.conf
- # cp /usr/local/apache/bin/apachectl-ssl /etc/rc.d/init.d/apache-https
复制代码
进入blfs-bootscript目录
- # make install-apache
- # sed -e "s:/usr/sbin:/usr/local/apache/bin:g" \
- -i /etc/rc.d/init.d/apache
- # cp /etc/rc.d/init.d/apache{,-https}
- # sed -e "s:apachectl:apachectl-ssl:g" \
- -i /etc/rc.d/init.d/apache-https
- # ln -s ../init.d/apachectl-ssl /etc/rc.d/rc0.d/K73apachectl-ssl &&
- ln -s ../init.d/apachectl-ssl /etc/rc.d/rc1.d/K73apachectl-ssl &&
- ln -s ../init.d/apachectl-ssl /etc/rc.d/rc3.d/S23apachectl-ssl &&
- ln -s ../init.d/apachectl-ssl /etc/rc.d/rc5.d/K23apachectl-ssl &&
- ln -s ../init.d/apachectl-ssl /etc/rc.d/rc6.d/K23apachectl-ssl
复制代码- # cd /usr/local/apache/conf
- wget http://www.openssl.org/contrib/ssl.ca-0.1.tar.gz
- tar xvf ssl.ca-0.1.tar.gz
- cd ssl.ca-0.1
- ./new-root-ca.sh
- No Root CA key round. Generating one
- Generating RSA private key, 1024 bit long modulus
- ...++++++
- ...........................................................++++++
- e is 65537 (0x10001)
- Enter pass phrase for ca.key:
- Verifying - Enter pass phrase for ca.key: <输入一个密码>
- Self-sign the root CA...
- Enter pass phrase for ca.key: <输入一个密码>
- You are about to be asked to enter information that will be incorporated
- into your certificate request.
- What you are about to enter is what is called a Distinguished Name or a DN.
- There are quite a few fields but you can leave some blank
- For some fields there will be a default value,
- If you enter '.', the field will be left blank.
- -----
- Country Name (2 letter code) [MY]:CN
- State or Province Name (full name) [Perak]:Beijing
- Locality Name (eg, city) [Sitiawan]:Beijing
- Organization Name (eg, company) [My Directory Sdn Bhd]:Home
- Organizational Unit Name (eg, section) [Certification Services Division]:Mail
- Common Name (eg, MD Root CA) []:
- Email Address []:mikkoyue@gmail.com
- 这样就生成了ca.key和ca.crt两个文件,下面还要为我们的服务器生成一个证书:
- # ./new-server-cert.sh server
- Fill in certificate data
- You are about to be asked to enter information that will be incorporated
- into your certificate request.
- What you are about to enter is what is called a Distinguished Name or a DN.
- There are quite a few fields but you can leave some blank
- For some fields there will be a default value,
- If you enter '.', the field will be left blank.
- -----
- Country Name (2 letter code) [MY]:CN
- State or Province Name (full name) [Perak]:Beijing
- Locality Name (eg, city) [Sitiawan]:Beijing
- Organization Name (eg, company) [My Directory Sdn Bhd]:Home
- Organizational Unit Name (eg, section) [Secure Web Server]:Mail
- Common Name (eg, www.domain.com) []:mail.mikkoyue.net
- Email Address []:mikkoyue@mikkoyue.net
- You may now run ./sign-server-cert.sh to get it signed
- # ./sign-server-cert.sh server
- CA signing: server.csr -> server.crt:
- Using configuration from ca.config
- Enter pass phrase for ./ca.key:
- Check that the request matches the signature
- Signature ok
- The Subject's Distinguished Name is as follows
- countryName :PRINTABLE:'CN'
- stateOrProvinceName :PRINTABLE:'Beijing'
- localityName :PRINTABLE:'Beijing'
- organizationName :PRINTABLE:'Home'
- organizationalUnitName:PRINTABLE:'Mail'
- commonName :PRINTABLE:'mail.mikkoyue.net'
- emailAddress :IA5STRING:'mikkoyue@mikkoyue.net'
- Certificate is to be certified until Apr 10 06:32:51 2010 GMT (365 days)
- Sign the certificate? [y/n]:y
- 1 out of 1 certificate requests certified, commit? [y/n]y
- Write out database with 1 new entries
- Data Base Updated
- CA verifying: server.crt <-> CA cert
- server.crt: OK
- # cp server.crt server.key ../
- # chmod 400 ../server.key
复制代码
9. extmail-1.0.8
- # mkdir -p /srv/webmail
- # vi conf/extra/httpd-ssl.conf
复制代码
修改 conf/extra/httpd-ssl.conf文件中的设置并添加如下一些信息
- DocumentRoot "/srv/webmail/extmail/html/"
- ScriptAlias /extmail/cgi/ /srv/webmail/extmail/cgi/
- Alias /extmail/ /srv/webmail/extmail/html/
- ScriptAlias /extman/cgi/ /srv/webmail/extman/cgi/
- Alias /extman/ /srv/webmail/extman/html/
- ServerName mail.mikkoyue.net:443
复制代码- # cd /srv/webmail
- # tar xvf /usr/src/extmail-1.0.8.tar.gz
- # mv extmail{-1.0.8,}
- # chown -R vuser:vgroup /srv/webmail/extmail/cgi
- # cd extmail/
- # cp webmail.cf{.default,}
- # sed -e "s:/var/www/extsuite:/srv/webmail:g" \
- -i webmail.cf
- # vi webmail.cf
复制代码
编辑webmail.cf修改如下:
- SYS_USER_LANG = zh_CN
- SYS_USER_CHARSET = gb2312
- SYS_MFILTER_ON = 1
- SYS_NETDISK_ON = 1
- SYS_MYSQL_USER = extmail
- SYS_MYSQL_PASS = extmail
- SYS_MYSQL_DB = extmail
- SYS_MYSQL_SOCKET = /var/run/mysql/mysql.sock
- SYS_G_ABOOK_TYPE = file
- SYS_G_ABOOK_FILE_CHARSET = gb2312
复制代码- # cd /srv/webmail
- # tar xvf /usr/src/extman-1.0.0.tar.gz
- # mv extman{-1.0.0,}
- # chown -R vuser:vgroup /srv/webmail/extman/cgi
- # cd extman
- # sed -e "s:/var/www/extsuite:/srv/webmail:g" -i webman.cf
复制代码
编辑webman.cf,修改如下信息:
- SYS_CHARSET = gb2312
- SYS_LANG = zh_CN
- SYS_MYSQL_SOCKET = /var/run/mysql/mysql.sock
复制代码
10. 数据库初始化及后续设置
- # mysql -u root -p < /srv/webmail/extman/docs/extmail.sql
- # mysql -u root -p < /srv/webmail/extman/docs/init.sql
复制代码- # mkdir /tmp/extman
- # chown -R vuser:vgroup /tmp/extman
- # echo "mkdir -p /tmp/extman" >> /etc/rc.d/rc.local
- # echo "chown -R vuser:vgroup /tmp/extman" >> /etc/rc.d/rc.local
- # chmod +x /etc/rc.d/rc.local
- # ln -s ../rc.local /etc/rc.d/rcsysinit.d/S91rc.local
- # cd /srv/webmail/extman/tools
- # ./maildirmake.pl /home/domains/extmail.org/postmaster/Maildir
- # chown -R vuser:vgroup /home/domains
复制代码
测试执行echo "test"|maildrop -V 10 -d postmaster@extmail.org
如果显示如下信息,则成功
- # echo "test"|maildrop -V 10 -d postmaster@extmail.org
- maildrop: authlib: groupid=1000
- maildrop: authlib: userid=1000
- maildrop: authlib: logname=postmaster@extmail.org, home=/home/domains/extmail.org/postmaster, mail=/home/domains/extmail.org/postmaster/Maildir/
- maildrop: Changing to /home/domains/extmail.org/postmaster
- Message start at 0 bytes, envelope sender=postmaster@extmail.org
- maildrop: Attempting .mailfilter
- maildrop: Delivery complete.
复制代码
11. 配置courier-imap
- # tar xvf courier-imap-4.4.1.tar.bz2
- # cd courier-imap-4.4.1
- # ./configure --prefix=/usr \
- --sysconfdir=/etc \
- --localstatedir=/var \
- --enable-unicode \
- --disable-root-check \
- --with-trashquota \
- --without-ipv6 COURIERAUTHCONFIG='/usr/bin/courierauthconfig'
- # make && make install
- # cp /etc/imapd{.dist,}
- # cp /etc/pop3d{.dist,}
- # sed -e "s/POP3DSTART=no/POP3DSTART=yes/"
- -i /etc/pop3d
- # install -m 755 courier-imap.sysvinit /etc/rc.d/init.d/courier-imap
- # ln -s ../init.d/courier-imap /etc/rc.d/rc0.d/K72courier-imap &&
- ln -s ../init.d/courier-imap /etc/rc.d/rc1.d/K72courier-imap &&
- ln -s ../init.d/courier-imap /etc/rc.d/rc3.d/S22courier-imap &&
- ln -s ../init.d/courier-imap /etc/rc.d/rc5.d/K22courier-imap &&
- ln -s ../init.d/courier-imap /etc/rc.d/rc6.d/K22courier-imap
复制代码
如果要开启pops或者imap服务请编辑/etc下相应的配置文件
12. mailgraph_ext配置
- # wget http://www.infodrom.org/projects/cgilib/download/cgilib-0.7.tar.gz
- # tar xvf cgilib-0.7.tar.gz
- # cd cgilib-0.7/
- # ./configure --prefix=/usr --disable-libtool-lock
- # mv libtool{,.bak} && ln -s /usr/bin/libtool ./
- # make && make install
复制代码- # cd libart_lgpl-2.3.20/
- # ./configure --prefix=/usr &&
- make && make install
复制代码- # wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.2.3.tar.gz
- # tar xvf rrdtool-1.2.3.tar.gz
- # cd rrdtool-1.2.3/
- # ./configure --prefix=/usr --enable-perl-site-install &&
- make && make install
复制代码
别装太高版本的的rrdtool,否则一大堆支持库的需求让你烦死。
- # perl -MCPAN -e shell
- cpan>install File::Tail
- cpan>install Time::HiRes
- cpan>quit
复制代码- cp -r /srv/webmail/extman/addon/mailgraph_ext /usr/local/
- 为了一开机就能自动执行上述进程,将上述命令加到rc.local 里面:
- # echo "/usr/local/mailgraph_ext/mailgraph-init start" >> /etc/rc.d/rc.local
- # echo "/usr/local/mailgraph_ext/qmonitor-init start" >> /etc/rc.d/rc.local
复制代码
到这儿Email服务器已经可用了,管理员用户名是:root@extmail.org,密码:extmail*123*。连实验带写这个东西整整一下午加一夜,休息去了,等我睡醒了把防病毒和防垃圾邮件功能加上
13. 安装配置amavisd
- amavisd-new-2.6.1
- less INSTALL
复制代码
可以找到如下信息
- Prerequisites:
- ==============
- file(1) utility is required, the most recent version is heartly recommended
- (current version is 4.24 at the time of a release). There are a number of
- security and robustness problems with older versions.
- Archive::Zip (Archive-Zip-x.xx) (1.14 or later, currently 1.23)
- Compress::Zlib (Compress-Zlib-x.xx) (1.35 or later, currently 2.008)
- Convert::TNEF (Convert-TNEF-x.xx)
- Convert::UUlib (Convert-UUlib-x.xxx) (1.08 or later, stick to new versions!)
- MIME::Base64 (MIME-Base64-x.xx)
- MIME::Parser (MIME-Tools-x.xxxx) (latest version from CPAN - currently 5.425)
- Mail::Internet (MailTools-1.58 or later have workarounds for Perl 5.8.0 bugs)
- Net::Server (Net-Server-x.xx) (version 0.88 finally does setuid right)
- Digest::MD5 (Digest-MD5-x.xx) (2.22 or later)
- IO::Stringy (IO-stringy-x.xxx)
- Time::HiRes (Time-HiRes-x.xx) (use 1.49 or later, older can cause problems)
- Unix::Syslog (Unix-Syslog-x.xxx)
- BerkeleyDB with bdb library (preferably 4.4.20 or later)
- Mail::DKIM (Mail-DKIM-0.31 or later)
复制代码
执行perl -MCPAN -e shell后运行install命令把列表中的包全装上
添加用户和组
- groupadd amavis &&
- useradd -g amavis -s /bin/false -c "Clam AntiVirus" amavis
复制代码
建立amavis运行需要的目录
- mkdir -p /var/amavis/{tmp,var,db,home}
- chown -R amavis:amavis /var/amavis
- chmod -R 750 /var/amavis
复制代码
安装- install -m755 amavisd /usr/sbin/
复制代码
配置启动脚本- cat > /etc/rc.d/init.d/amavisd <<EOF
- #!/bin/sh
- # Begin \$rc_base/init.d/amavisd
- # Based on sysklogd script from LFS-3.1 and earlier.
- # Written by Mikko Yue - mikkoyue@hotmail.com
- . /etc/sysconfig/rc
- . \$rc_functions
- prog="/usr/sbin/amavisd"
- prog_base="\$(basename \${prog})"
- prog_config_file="/etc/amavisd.conf"
- # Source configuration.
- [ -e /etc/sysconfig/\${prog_base} ] && . /etc/sysconfig/\${prog_base}
- failure=0
- case "\$1" in
- start)
- boot_mesg "Starting amavisd daemon..."
- if [ -e /var/lock/subsys/\${prog_base} ]; then
- echo ""
- echo_failure
- else
- echo ""
- \${prog} -c \${prog_config_file} && touch /var/lock/subsys/\${prog_base}
- evaluate_retval
- fi
- ;;
- stop)
- boot_mesg -n "Stopping amavisd daemon..."
- if [ -e /var/lock/subsys/\${prog_base} ]; then
- \${prog} -c \${prog_config_file} stop
- echo ""
- evaluate_retval
- rm -f /var/lock/subsys/\${prog_base}
- else
- echo "amavisd not running"
- echo ""
- echo_failure
- fi
- ;;
- restart)
- \$0 stop
- sleep 2
- \$0 start
- ;;
- reload)
- boot_mesg -n "Reloading amavisd daemon..."
- \${prog} -c \${prog_config_file} reload
- echo ""
- evaluate_retval
- ;;
- *)
- echo "Usage: \$0 {start|stop|restart}"
- exit 1
- ;;
- esac
- # End \$rc_base/init.d/amavisd
- EOF
- chmod +x /etc/rc.d/init.d/amavisd &&
- ln -s ../init.d/amavisd /etc/rc.d/rc0.d/K73amavisd &&
- ln -s ../init.d/amavisd /etc/rc.d/rc1.d/K73amavisd &&
- ln -s ../init.d/amavisd /etc/rc.d/rc3.d/S23amavisd &&
- ln -s ../init.d/amavisd /etc/rc.d/rc5.d/K23amavisd &&
- ln -s ../init.d/amavisd /etc/rc.d/rc6.d/K23amavisd
复制代码
其它配置
- install -m644 amavisd.conf /etc/
复制代码
建立quarantine area此目录下是放标记为病毒或垃圾的邮件
- # install -d -m750 /var/virusmails
- # chown amavis:amavis /var/virusmails
复制代码
修改amavisd.conf中如下内容
- # vi /etc/amavisd.conf
- $max_servers = 10; # num of pre-forked children (2..15 is common), -m
- $daemon_user = 'amavis'; # (no default; customary: vscan or amavis), -u
- $daemon_group = 'amavis'; # (no default; customary: vscan or amavis), -g
- $MYHOME = '/var/amavis';
- $TEMPBASE = "$MYHOME/tmp";
- $db_home = "$MYHOME/db";
- $mydomain = 'mail.mikkoyue.net';
- $myhostname = 'mail.mikkoyue.net';
- @local_domains_maps = qw(.);
- $sa_tag2_level_deflt = 5.0;
- $sa_kill_level_deflt = 5.0;
复制代码 增加 三行:
- $sa_spam_modifies_subj = 0; # don't modify subject
- $remove_existing_x_scanned_headers= 1; # remove existing headers
- $remove_existing_spam_headers = 1;
复制代码
编辑/etc/postfix/master.cf增加内容
- # cat >> /etc//postfix/master.cf <<EOF
- 127.0.0.1:10025 inet n - n - - smtpd
- -o content_filter=
- -o local_recipient_maps=
- -o relay_recipient_maps=
- -o smtpd_restriction_classes=
- -o smtpd_client_restrictions=
- -o smtpd_helo_restrictions=
- -o smtpd_sender_restrictions=
- -o smtpd_recipient_restrictions=permit_mynetworks,reject
- -o mynetworks=127.0.0.0/8
- -o strict_rfc821_envelopes=yes
- -o smtpd_error_sleep_time=0
- -o smtpd_soft_error_limit=1001
- -o smtpd_hard_error_limit=1000
- -o receive_override_options=
- EOF
复制代码
编辑/etc/postfix/main.cf增加内容
- # cat >> /etc/postfix/main.cf <<EOF
- #Content-Filter
- content_filter = smtp:[127.0.0.1]:10024
- receive_override_options = no_address_mappings
- EOF
复制代码
14. 安装配置SpamAssassin
- perl -MCPAN -e shell
- cpan[1]> install Digest::SHA1
- cpan[2]> install HTML::Parser
- cpan[6]> install LWP
复制代码 |
|