질문&답변
클라우드/리눅스에 관한 질문과 답변을 주고 받는 곳입니다.
리눅스 분류

qmail + vpopmail + courier-imap + 다람쥐 메일

작성자 정보

  • 박상철 작성
  • 작성일

컨텐츠 정보

본문

[레드햇 9 버전에서 테스트 됨]

* 개인적으로 /src_tmp 디렉토리에 소스파일을 저장합니다.
인덱스 페이지의 qmail 과 관련된 소스를 위의 디렉토리로 저장 합니다.

(1) sendmail 패키지가 설치되어 있는지 확인해 봅니다.
# rpm -qa | grep sendmail

(2) 설치되어 있다면 삭제 합니다.
# rpm -e sendmail-devel
# rpm -e sendmail-cf
# rpm -e sendmail
# rm -f /etc/mail/statistics.rpmsave
--------------------------------------------------------^-^

(3) ucspi-tcp-0.88.tar.gz 설치
:qmail은 standalone 방식으로 작동하지 않으며, inetd 나 tcpserver 와 같은
수퍼데몬 프로세서와 연동하여 실행이 됩니다.
보안과 속도를 염두에 두어 'tcpserver' 를 사용하는 것이 바람직 합니다.

# cd /src_tmp (소스파일이 있는곳으로 이동 한다.)
# tar xvfz ucspi-tcp-0.88.tar.gz
# cd ucspi-tcp-0.88
# vi conf-home
/usr/local ----------> /usr 로 수정한다.
# vi conf-cc
gcc -O2 --------> gcc -O2 -march=i686 -funroll-loops 로 수정한다.

(레드햇9 에서는 컴파일시 에러가 나므로 소스를 다음과 같이 수정 합니다.
# vi error.h
* 맨 윗줄에 다음 내용을 추가한다.
#include <errno.h> // wq 명령으로 저장한다.

# make
# make setup check
----------------------------------------------------^-^

(4) qmail-1.0.3.tar.gz 와 패치
*(qmail 설치시 패치를 해주어야 하는데 임은재님의 칵테일 패치를 사용하겠습니다.)

# cd /src_tmp
# tar xvfz qmail-1.03.tar.gz
# tar xvfz qmail-ej-cocktail-10.tar.gz
# cd qmail-1.03
# mkdir /var/qmail
# vi INSTALL.ids
:리눅스에 해당하는 계정과 그룹등록을 다음과 같이 수정하고 나머지 부분은 삭제한다. 직접생성해도 괜찮습니다.)

groupadd -f -g 81 nofiles
useradd -c "QMail Server" -g 81 -u 82 -s /bin/false -r -d /var/qmail/alias alias
useradd -c "QMail Server" -g 81 -u 81 -s /bin/false -r -d /var/qmail qmaild
useradd -c "QMail Server" -g 81 -u 86 -s /bin/false -r -d /var/qmail qmaill
useradd -c "QMail Server" -g 81 -u 87 -s /bin/false -r -d /var/qmail qmailp
groupadd -f -g 82 qmail
useradd -c "QMail Server" -g 82 -u 83 -s /bin/false -r -d /var/qmail qmailq
useradd -c "QMail Server" -g 82 -u 84 -s /bin/false -r -d /var/qmail qmailr
useradd -c "QMail Server" -g 82 -u 85 -s /bin/false -r -d /var/qmail qmails

:저장한후
# sh INSTALL.ids
# patch -p1 < ../qmail-ej-cocktail-10/qmail-ej-cocktail-10-no-starttls.patch
# chown root.qmail /var/qmail
# mkdir -p /etc/qmail/alias
# mkdir -p /etc/qmail/control
# mkdir -p /etc/qmail/users

# ln -sf /etc/qmail/alias /var/qmail
# ln -sf /etc/qmail/control /var/qmail
# ln -sf /etc/qmail/users /var/qmail
# ln -sf /usr/bin /var/qmail/bin
# ln -sf /usr/share/man /var/qmail/man

# vi conf-cc
gcc -O2--------> gcc -O2 -march=i686 -funroll-loops 로 수정후 저장한다.
* 레드햇 9 에서는 컴파일 에러가 나므로 다음과 같이 수정한다.
# vi error.h
* 맨 윗줄에 다음 내용을 추가한후 저장한다.
#include <errno.h>

# make
# make man
# make setup check

* 센드메일을 대체할 실행파일들을 심볼릭 링크를 건다.
# ln -s /var/qmail/bin/sendmail /usr/lib/sendmail
# ln -s /var/qmail/bin/sendmail /usr/sbin/sendmail
# ln -s /var/qmail/bin/qmail-qread /usr/bin/mailq

* qmail 의 기본 도메인을 설정 하는데, 네임서버 의 MX레코드 값이 정확해야 합니다.
# ./config
(오류 발생시의 원인은 하나의 서버에 메일서버를 같이 두고 있기때문이며,다음과 같이 직접 지정해 준다.)
# ./config-fast mail.baleye.net (MX 에 넣어준 값)

# echo './Maildir/' > /etc/qmail/dot-qmail
# chmod 511 /etc/qmail/dot-qmail
# chown root:root /etc/qmail/dot-qmail
------------------------------------------------^-^

(5) vpopmail-5.2.1.tar.gz 설치

# cd /src_tmp
# tar xvfz vpopmail-5.2.1.tar.gz
# cd vpopmail-5.2.1
# groupadd -f -g 110 vchkpw > /dev/null 2>&1 || :
# useradd -c vpop -g vchkpw -u 110 -s /bin/false -r -m -d /home/vpopmail vpopmail > /dev/null 2>&1 || :
# mkdir -p /home/vpopmail/etc
# chmod 777 /home/vpopmail/etc

* vpopmail 과 MySQL 을 연동시키기 위해 DB 와 테이블을 만듭니다.
APM 서버구축시 MySQL 서버는 rpm 으로 설치 했음을 상기 합니다.
# mysql -uroot -p
mysql> create database vpopmail;
mysql> use vpopmail;
mysql> grant create, insert, select, delete, update on vpopmail.* to vpopmail;
mysql> grant create, insert, select, delete, update on vpopmail.* to vpopmail@localhost;
mysql> SET password for 'vpopmail'@'%'=password('비밀번호');
mysql> SET password for 'vpopmail'@'localhost'=password('비밀번호');
mysql> flush privileges;
mysql> exit

# vi vmysql.h (26~30 행을 다음과 같이 변경 저장한다.)

/* Edit to match your set up */
#define MYSQL_UPDATE_SERVER "localhost"
#define MYSQL_UPDATE_USER "vpopmail"
#define MYSQL_UPDATE_PASSWD "비밀번호"

#define MYSQL_READ_SERVER "localhost"
#define MYSQL_READ_USER "vpopmail"
#define MYSQL_READ_PASSWD "비밀번호"
/* End of setup section*/

# ./configure --enable-default-domain=본인의도메인 --enable-roaming-users=y --enable-tcprules-prog=/usr/bin/tcprules --enable-relay-clear-minutes=15 --enable-mysql-logging=y --enable-logging=e --enable-sqlincdir=/usr/include/mysql --enable-sqllibdir=/usr/lib/mysql --enable-mysql=y --enable-mysql-replication=y --enable-valias=y --enable-many-domains=n
# make
# make install
# echo "127.0.0.1:allow,RELAYCLIENT=""" > /home/vpopmail/etc/tcp.smtp
# tcprules /home/vpopmail/etc/tcp.smtp.cdb
> /home/vpopmail/etc/tcp.smtp.tmp < /home/vpopmail/etc/tcp.smtp
# chown 110.110 /home/vpopmail/etc/tcp.smtp*
# ls /usr/lib/libmysqlclient.so.10
* (위의 파일은 MySQL 을 rpm 으로 설치하였다면 설치 되어 있음.
만약 없을시 /usr/local/mysql/lib/libmysqlclient.so.10 혹은
/usr/mysql/lib/mysql/libmysqlclient.so.10 파일을 /usr/lib/libmysqlclient.so.10 파일로 심볼릭 링크를 건다.)

# /home/vpopmail/bin/clearopensmtp
# echo "localhost" > /var/qmail/control/locals
# vi /etc/rc.d/init.d/qmail
-----------------------------------
#! /bin/bash

# This shell script takes care of starting and stopping Qmail.
#
# chkconfig:2345 80 30
# description: Qmail is a small, fast, secure Mail Transport Agent, which
# is the program that moves mail from one machine to another.
#
# processname: qmail-send

# Source function library.
. /etc/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

# If Qmail is not available stop now.
[ -f /usr/bin/qmail-send ] || exit 0

RETVAL=0
prog="Qmail"

start() {
echo -n $"Starting $prog: "
QMAILQUEUE="/var/qmail/bin/qmail-scanner-queue.pl"
export QMAILQUEUE
qmail-start "cat /etc/qmail/dot-qmail" splogger qmail &

# Here we start qmail-smtpd with AUTH, vpop support.
tcpserver -p -c 1024 -u 110 -g 110 -x /home/vpopmail/etc/tcp.smtp.cdb
-DRHl localhost 0.0.0.0 25 /usr/bin/tcp-env tcp-env /usr/bin/qmail-smtpd &

# Here we start qmail-pop3d with AUTH, vpop support.
tcpserver -c 1024 -u 110 -g 110 -DRHl localhost 0.0.0.0 110 /usr/bin/qmail-popup
hostname -f /home/vpopmail/bin/vchkpw /usr/bin/qmail-pop3d Maildir &

RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/qmail
return $RETVAL
}

stop() {
echo -n $"Shutting down $prog: "
killproc qmail-send
#killproc stunnel
killproc tcpserver
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/qmail
return $RETVAL
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
queue)
qmail-qstat
qmail-qread
;;
status)
status qmail-send
RETVAL=$?
;;
restart)
stop
start
RETVAL=$?
;;
condrestart)
if [ -f /var/lock/subsys/qmail ]; then
stop

start

RETVAL=$?
fi

;;

*)

echo $"Usage: $0 {start|stop|queue|status|restart|condrestart}"

exit 1

esac

exit $RETVAL
----------------------------- 저장한다.

# vi /etc/profile
: 마지막 행에 다음의 내용을 추가한다.

export PATH="$PATH:/home/vpopmail/bin"

# source /etc/profile
# crontab -e
:다음의 내용을 추가한다.
10,25,40,55 * * * * /home/vpopmail/bin/clearopensmtp 2>&1 > /dev/null
---------저장한다.
# chmod 755 /etc/rc.d/init.d/qmail
# chown 0.0 /etc/rc.d/init.d/qmail
# chkconfig --add qmail
# chkconfig --level 2345 qmail on
# vadddomain 본인의 기본 도메인 (패스워드 설정)
# vadduser 사용자계정@본인의 기본 도메인 (패스워드 설정)
# vconvert -e -c 본인의 기본 도메인
# echo "계정명@본인의 기본 도메인" > ~vpopmail/domains/기본 도메인/.qmail-root
# cp ~vpopmail/domains/기본도메인/.qmail-root
> ~vpopmail/domains/기본도메인/.qmail-mailer-daemon
# cp ~vpopmail/domains/기본도메인/.qmail-root
> ~vpopmail/domains/기본도메인/.qmail-postmaster
# /etc/rc.d/init.d/qmail start
# pstree | grep qmail

------------------------------------------------------------^-^

(6) courier-imap-2.1.1.tar.bz2
: imap 프로토콜 지원을 위해 레드햇9 에서는 다음의 패키지가 필요합니다.

# rpm -ivh tcl-8.3.5-88.i386.rpm
# rpm -ivh expect-5.38.0-88.i386.rpm

(주의) imap 의 컴파일시 디렉토리의 퍼미션 문제로 읽지 못합니다.그래서 라이브러리 디렉토리의 퍼미션을 변경하고 , 컴파일이 끝난후 원래의 퍼미션으로 되돌려 놓으시면 됩니다.

# chmod 777 -R /home/vpopmail/lib
# chmod 777 courier-imap-2.1.1.tar.bz2
# useradd eyeball (일반유저로 컴파일 하기 위해 계정을 하나 만든다.)
# passwd eyeball
# su eyeball
$ cd /src_tmp // 소스파일이 있는 디렉토리로 이동
$ tar xjfp courier-imap-2.1.1.tar.bz2
$ cd courier-imap-2.1.1

: 다음과 같이 환경 설정파일을 만든다.
$ vi setup.txt
CFLAGS="-DHAVE_OPEN_SMTP_RELAY"; export CFLAGS
env LIB="-L/usr/lib/mysql -lmysqlclient -lz"
./configure
--prefix=/usr
--datadir=/usr/share/courier-imap
--sysconfdir=/etc/courier-imap
--libexecdir=/usr/libexec/courier-imap
--localstatedir=/var
--mandir=/usr/share/man
--without-ipv6
--enable-unicode
--with-authvchkpw
--with-redhat
--without-authdaemon
--without-authmysql
--without-authldap
--without-authpgsql ------------>저장후 실행

$ sh setup.txt
$ make
$ make check
$ su root
# make install
# make install-configure
# cp -f courier-imap.sysvinit /etc/rc.d/init.d/courier-imap
# chown 0.0 /etc/rc.d/init.d/courier-imap
# chmod 755 /etc/rc.d/init.d/courier-imap
# chkconfig --add courier-imap
# chkconfig --level 2345 courier-imap on
# chmod 700 /home/vpopmail/lib
# chmod 600 /home/vpopmail/lib/libvpopmail.a
# chown -R 110.110 /home/vpopmail/lib

# vi /etc/courier-imap/imapd
: IMAPDSTART=NO 를YES 로 변경,저장한다.

# vi /usr/libexec/courier-imap/imapd.rc
: 46번 줄에서
-stderrlogger=/usr/libexec/courier-imap/courierlogger -user=vpopmail -group=vchkpw 로 수정후 저장한다.

# vi /usr/libexec/courier-imap/pop3d.rc
: 39번 줄에서
-stderrlogger=/usr/libexec/courier-imap/courierlogger -user=vpopmail -group=vchkpw 로 수정후 저장한다.

# chmod 755 /usr/libexec/courier-imap/imapd.rc
# chmod 755 /usr/libexec/courier-imap/pop3d.rc
# /etc/rc.d/init.d/courier-imap start

--------------------------------------------------------- ^-^

(7) qmail-scanner 설치 (스팸메일 필터링)

# rpm -Uvh perl-suidperl-5.8.0-88.i386.rpm
# rpm -Uvh unzip-5.50-7.i386.rpm
# rpm -Uvh perl-DB_File-1.804-88.i386.rpm

# cd /src_tmp
# tar xjfp maildrop-1.6.0.tar.bz2
# cd maildrop-1.6.0
# ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --mandir=/usr/share/man --enable-sendmail=/var/qmail/bin/sendmail --enable-maildrop-uid=root --enable-maildrop-gid=vchkpw --enable-maildirquota --enable-restrict-trusted=1 --enable-trusted-users='root qmaild vpopmail'
# make
# make install-strip
# make install-man

# cd /src_tmp
# tar xvfz HTML-Tagset-3.03.tar.gz
# cd HTML-Tagset-3.03
# perl Makefile.PL
# make
# make install

# cd ../
# tar xvfz HTML-Parser-3.31.tar.gz
# cd HTML-Parser-3.31
# perl Makefile.PL
# make
# make test
# make install

# cd ../
# tar xvfz Time-HiRes-1.50.tar.gz
# cd Time-HiRes-1.50
# perl Makefile.PL
# make
# make test
# make install

# cd ../
# tar xvfz Mail-SpamAssassin-2.55.tar.gz
# cd Mail-SpamAssassin-2.55
# perl Makefile.PL
# make && make install

# cp -f /usr/share/spamassassin/user_prefs.template /etc/mail/spamassassin/user_prefs

# www.yrex.com/spam/spamconfig.php/local.cf 로 접속하여 Lnguage Option 에서 korean 을 선택후 Generate the Configuration File
단추를 클릭하여 /etc/mail/spamassassin/ 디렉토리로 복사한다.

# echo 'OPTIONS="-d -L -x -u qmailq"' > /etc/sysconfig/spamd
# chmod 644 /etc/mail/spamassassin/*
# chmod 644 /etc/sysconfig/spamd

# cp -f spamd/redhat-rc-script.sh /etc/rc.d/init.d/spamd
# chown 0.0 /etc/rc.d/init.d/spamd
# chmod 755 /etc/rc.d/init.d/spamd
# chkconfig --add spamd
# chkconfig --level 2345 spamd on

# cd ../
# chown root /usr/bin/suidperl
# chmod 4711 /usr/bin/suidperl
# tar xvfz qmail-scanner-1.16.tgz
# cd qmail-scanner-1.16
# echo $LANG
# cp -r locale/en_GB locale/ko_KR.eucKR
# vi setup1.txt
./configure
--admin webmaster
--domain 기본도메인
--notify none
--scanners verbose_spamassassin --------:wq 저장

# vi setup2.txt
./configure
--admin webmaster
--domain 기본도메인
--notify none
--scanners verbose_spamassassin
--install ------------- :wq 저장

# sh setup1.txt
# sh setup2.txt
# cp -f quarantine-attachments.txt /var/spool/qmailscan
# chown qmailq.qmail /var/spool/qmailscan/quarantine-attachments.txt
# chmod 660 /var/spool/qmailscan/quarantine-attachments.txt
# chown qmailq.qmail /var/qmail/bin/qmail-scanner-queue.pl
# chmod 4755 /var/qmail/bin/qmail-scanner-queue.pl
# /var/qmail/bin/qmail-scanner-queue.pl -g ---->룰셋 적용 테스트
# echo '
> export QMAILQUEUE="/var/qmail/bin/qmail-scanner-queue.pl">> /etc/profile'
# source /etc/profile
# vi /etc/rc.d/init.d/qmail
: 28,29 번째줄의 주석을 푼다.
QMAILQUEUE="/var/qmail/bin/qmail-scanner-queue.pl"
export QMAILQUEUE------>:wq 저장
# /etc/rc.d/init.d/qmail restart

--------------------------------------------^-^

(8) qmailadmin 설치

: 먼저 'ezmlm' 과 'autorespond' 가 설치되어야 합니다.

# cd /src_tmp
# tar xvfz ezmlm-0.53.tar.gz
# tar xvfz ezmlm-idx-0.40.tar.gz

: idx 패치를 위해 파일을 이동 합니다.
# mv -f ezmlm-idx-0.40/* ezmlm-0.53
# cd ezmlm-0.53
# patch < idx.patch

: 컴파일 옵션 설정을 합니다.
# echo "/usr/bin/ezmlm
>
> Programs will be installed in this directory." > conf-bin

# echo "/usr/share/man
>
> Man pages will be installed in subdirectoies of this directory. An
> unformatted man page foo.1 will go into .../man1/foo.1; a formatted man
> page foo.0 will go into .../cat1/foo.0." > conf-man

: 레드햇9 에서는 다음 파일을 수정 합니다.
# vi error.h
맨 윗줄에 다음을 추가 합니다.
#include <errno.h> ---------> :wq 로 저장한다.

# make
# make man
# make setup

# cd ../
# tar xvfz autorespond-2.0.2.tar.gz
# cd autorespond-2.0.2
# vi Makefile
INSTALL_DIR=/usr/local/bin 을 INSTALL_DIR=/usr/bin 으로 수정 저장한다.
# make
# make install

# cd ../
# tar xvfz qmailadmin-1.0.6.tar.gz
# cd qmailadmin-1.0.6
# ./configure --enable-htmldir=/usr/local/apache/cgi-bin --enable-cgibindir=/usr/local/apache/cgi-bin --with-htmllibdir=/usr/share/qmailadmin --enable-cgipath=/cgi-bin/qmailadmin --enable-autoresponder-bin=/usr/bin --enable-ezmlmdir=/usr/bin/ezmlm

# make
# make install-strip

# chown 110.110 /usr/local/apache/cgi-bin/qmailadmin
# chmod 6755 /usr/local/apache/cgi-bin/qmailadmin

# cp -rf /usr/local/apache/cgi-bin/images /usr/local/apache/htdocs
# /etc/init.d/httpd restart

: 웹부라우저에서 접속은 '도메인(IP)/cgi-bin/qmailadmin' 으로 한다.

-----------------------------------------------------------^_^

(9) 다람쥐 메일의 설치 (MUA)

# cd /src_tmp
# tar xvfz squirrelmail-1.4.1.tar.gz
# mv squirrelmail-1.4.1/ /usr/local/apache/htdocs/webmail
# cd /usr/local/apache/htdocs
# chown nobody.nobody webmail/
# webmail/config/conf.pl

관련자료

댓글 0
등록된 댓글이 없습니다.

공지사항


뉴스광장


  • 현재 회원수 :  60,032 명
  • 현재 강좌수 :  35,773 개
  • 현재 접속자 :  136 명