lql.be::wiki  Index  Search  Changes  RSS  Login

qmail メールサーバ 構築

qmail メールサーバ 構築

概要

開発が中止してしまい、基本的にアップデートがされない qmail ですが 機能的には、まだまだ 使いやすい部分もあり、一部では人気らしい。

qmail インストール

暫定更新、また詳細は追加します。

1. qmailのコンパイル時に必要になるのでインストール

# yum install groff

2. qmail インストール

# mkdir /var/qmail
# groupadd nofiles
# useradd -g nofiles -d /var/qmail/alias -s /bin/false alias
# useradd -g nofiles -d /var/qmail -s /bin/false qmaild
# useradd -g nofiles -d /var/qmail -s /bin/false qmaill
# useradd -g nofiles -d /var/qmail -s /bin/false qmailp
# groupadd qmail
# useradd -g qmail -d /var/qmail -s /bin/false qmailq
# useradd -g qmail -d /var/qmail -s /bin/false qmailr
# useradd -g qmail -d /var/qmail -s /bin/false qmails

# cd /usr/local/src/

# wget ftp://ftp.eu.uu.net/pub/unix/mail/qmail/qmail-1.03.tar.gz
# wget http://qmail.org/moni.csi.hu/pub/glibc-2.3.1/qmail-1.03.errno.patch
# wget http://cyberam.dip.jp/linux_server/mail/qmail-date-localtime.patch
# tar zxvf qmail-1.03.tar.gz
# patch -d qmail-1.03 < qmail-1.03.errno.patch
# patch -d qmail-1.03 < qmail-date-localtime.patch
# cd qmail-1.03
# make setup check
# ./config-fast qmail.example.com

qmailインストール後、一度ソースを削除する

# cd ..
# rm -rf qmail-1.03

3. smtp-auth対応のqmailを作成する

# tar zxvf qmail-1.03.tar.gz
# patch -d qmail-1.03 < qmail-1.03.errno.patch
# patch -d qmail-1.03 < qmail-date-localtime.patch
# wget http://members.elysium.pl/brush/qmail-smtpd-auth/dist/qmail-smtpd-auth-0.31.tar.gz
# wget http://www.sera.desuyo.net/smtp-auth/qmail-smtpd-auth-0.30-iwm.patch
# tar zxvf qmail-smtpd-auth-0.31.tar.gz
# cd qmail-smtpd-auth-0.31
# cp base64.* ../qmail-1.03
# cp auth.patch ../
# cd ..
# patch -d qmail-1.03 < auth.patch
# patch -d qmail-1.03 < qmail-smtpd-auth-0.30-iwm.patch
# cd qmail-1.03
# make
# cp qmail-smtpd /var/qmail/bin/qmail-smtpd-auth
# chown root.qmail /var/qmail/bin/qmail-smtpd-auth

4. tcpserver インストール

# cd /usr/local/src
# wget http://www.emaillab.org/djb/tools/ucspi-tcp/ucspi-tcp-0.88.tar.gz
# wget http://qmail.org/moni.csi.hu/pub/glibc-2.3.1/ucspi-tcp-0.88.errno.patch
# wget http://qmail.org/moni.csi.hu/pub/glibc-2.3.1/ucspi-tcp-0.88.a_record.patch
# wget http://qmail.org/moni.csi.hu/pub/glibc-2.3.1/ucspi-tcp-0.88.nobase.patch
# tar zxvf ucspi-tcp-0.88.tar.gz
# patch -d ucspi-tcp-0.88 < ucspi-tcp-0.88.a_record.patch
# patch -d ucspi-tcp-0.88 < ucspi-tcp-0.88.errno.patch
# patch -d ucspi-tcp-0.88 < ucspi-tcp-0.88.nobase.patch
# cd ucspi-tcp-0.88
# make
# make setup check
# ./install
# ./instcheck

5. mysql インスール

# yum install mysql mysql-server mysql-devel
# /etc/init.d/mysqld start
# mysql -uroot
> create database vpopmail;
> GRANT select,insert,update,delete,create,drop ON vpopmail.* TO vpopmail@localhost IDENTIFIED BY 'vpopmail';
> FLUSH PRIVILEGES;
> quit

6. vpopmail インストール

# cd /usr/local/src
# groupadd vchkpw
# useradd -g vchkpw -s /bin/false -M vpopmail
# mkdir /home/vpopmail
# chown vpopmail:vchkpw /home/vpopmail
# mkdir /home/vpopmail/etc
# chown vpopmail:vchkpw /home/vpopmail/etc

# wget http://downloads.sourceforge.net/project/vpopmail/vpopmail-stable/5.4.27/vpopmail-5.4.27.tar.bz2?use_mirror=jaist
# tar jxvf vpopmail-5.4.27.tar.bz2
# cd vpopmail-5.4.27
# ./configure --disable-roaming-users --enable-ip-alias-domains=y --enable-auth-module=mysql --enable-incdir=/usr/include/mysql --enable-sqlincdir=/usr/include/mysql --enable-libdir=/usr/lib/mysql --enable-sqllibdir=/usr/lib/mysql --enable-logging=v --enable-log-name=vpopmail
# make
# make install-strip
# echo "qmail.example.com" > /home/vpopmail/etc/defaultdomain
## 'localhost|0|vpopmailuser|vpoppasswd|database_name'
# echo 'localhost|0|vpopmail|vpopmail|vpopmail' > /home/vpopmail/etc/vpopmail.mysql
# vi /home/vpopmail/etc/tcp.smtp
127.:allow,RELAYCLIENT=""
# tcprules /home/vpopmail/etc/tcp.smtp.cdb /home/vpopmail/etc/tcp.smtp.tmp < /home/vpopmail/etc/tcp.smtp
# chown vpopmail.vchkpw /home/vpopmail/etc/tcp.smtp*
# chown vpopmail.vchkpw /home/vpopmail/etc/vpopmail.mysql
# chmod 640 /home/vpopmail/etc/vpopmail.mysql

7. qmailadmin インストール

# cd /usr/local/src/
# wget http://www.inter7.com/devel/autorespond-2.0.5.tar.gz
# wget http://www.inter7.com/devel/ezmlm-0.53-idx-0.41.tar.gz
# wget http://downloads.sourceforge.net/project/qmailadmin/qmailadmin-stable/1.2.12/qmailadmin-1.2.12.tar.gz?use_mirror=jaist
# tar zxvf autorespond-2.0.5.tar.gz
# cd autorespond-2.0.5
# make
# make install
# cd ..
# tar zxvf ezmlm-0.53-idx-0.41.tar.gz
# cd ezmlm-0.53-idx-0.41
# make
# make setup
# cd ..
# tar zxvf qmailadmin-1.2.12.tar.gz
# cd qmailadmin-1.2.12
# ./configure --enable-cgibindir=/var/www/cgi-bin/qmail --enable-cgipath=/cgi-bin/qmail/qmailadmin --enable-imageurl=/qmail/images --enable-modify-quota
# make clean
# make
# make install-strip

8. apache の設定変更

# cp /etc/httpd/conf/httpd.conf{,.org}

下記内容を追加

# vi /etc/httpd/conf/httpd.conf
ScriptAlias /cgi-bin/qmail/ "/var/www/cgi-bin/"
# /etc/init.d/httpd restart

9. 起動スクリプト 作成

# vi /var/qmail/rc
-----------------------------------------------------------------
#!/bin/sh

# Using splogger to send the log through syslog.
# Using qmail-local to deliver messages to ~/Mailbox by default.

exec env - PATH="/var/qmail/bin:$PATH" \
qmail-start ./Maildir/ splogger qmail
-----------------------------------------------------------------
# chmod 755 /var/qmail/rc
# vi /etc/init.d/qmail
-----------------------------------------------------------------
#!/bin/sh
#
# qmail: /var/qmail
PATH=/var/qmail/bin:/usr/local/bin:/bin:/usr/bin:/home/vpopmail/bin

[ -f /var/qmail/rc ] || exit 0

case "$1" in
  start)
        echo -n "Starting qmaild: "
        # For qmail-smtpd
        #-u [qmaildのUID] -g [nofilesのGID]
        tcpserver -H -R -l qmail.example.com -v -x /home/vpopmail/etc/tcp.smtp.cdb -u 501 -g 500 0 smtp qmail-smtpd 2>&1 | splogger smtpd &
        # For qmail-smtpd-auth
        tcpserver -vHR -l0 -x /home/vpopmail/etc/tcp.smtp.cdb -u vpopmail -g vchkpw 0 587 qmail-smtpd-auth qmail.example.com vchkpw true 2>&1 | splogger smtp-auth &
        # For POP3d
        tcpserver -H -R -l mail.example.com -v 0 pop3 qmail-popup qmail.example.com vchkpw qmail-pop3d Maildir 2>&1 | splogger pop3d &
        /var/qmail/rc &
        echo
        touch /var/lock/subsys/qmaild
        ;;
  stop)
        echo -n "Shutting down qmail: "
        kill $(/sbin/pidof tcpserver)
        kill $(/sbin/pidof qmail-send)
        echo
        rm -f /var/lock/subsys/qmaild
        ;;
  restart)
        $0 stop
        $0 start
        ;;
  *)
        echo "Usage: $0 {start|stop|restart}"
        exit 1
esac

exit 0
-----------------------------------------------------------------
# chmod 755 /etc/rc.d/init.d/qmail
# /etc/init.d/qmail start
Last modified:2010/12/08 17:17:32
Keyword(s):
References:[linux]