Linux,Unix,BSD

qmail + vpopmail + MySQL 설치기 정리

채윤아빠 2007. 11. 13. 00:12
728x90
반응형

0. MySQL 설치
이글 참조 : FreeBSD 6.x에서 MySQL 5.0.x 설치기

1. ucspi-tcp 패키지 설치
# cd /usr/ports/sysutils/ucspi-tcp
# make install clean

2. daemontool 패키지 설치
# cd /usr/ports/sysutils/daemontools
# make install clean
# vi /etc/rc.conf

svscan_enable="YES"          추가



3. qmail 패키지 설치
# cd /usr/ports/mail/qmail && make install clean

4. sendmail 죽이기
/etc/rc.sendmail 파일을 다른 곳으로 옮겨 재실행시 실행되지 않도록 하기
/etc/rc.conf 파일 수정
 

sendmail_enable="NONE"

# mv /usr/sbin/sendmail /usr/sbin/sendmail.old
# ln -s /var/qmail/bin/sendmail /usr/sbin/sendmail
# ln -s /var/qmail/bin/sendmail /usr/lib/sendmail

5. autorespond 패키지 설치
# cd /usr/ports/mail/autorespond && make install clean

6. 큐메일 로그 디렉토리 생성
# mkdir /var/log/qmail
# cd /var/log/qmail
# mkdir qmail-send qmail-smtpd qmail-pop3d
# chown -R qmaill:wheel /var/log/qmail
# chmod -R 750 /var/log/qmail

7. qmail 기본 도메인 설정
# /var/qmail/configure/config-fast test.kr

8. supervise 디렉토리 설정
# mkdir /var/qmail/supervise
# cd /var/qmail/supervise
# mkdir -p qmail-smtpd/log qmail-send/log qmail-pop3d/log
# chmod +t qmail-smtpd qmail-send qmail-pop3d

9. 도메인 설멍에 필요한 파일 생성

10. supervise 스크립트 생성
# vi /var/qmail/rc

#!/bin/sh

exec env - PATH="/var/qmail/bin:$PATH" \
     qmail-start "`cat /var/qmail/control/defaultdelivery`"

# vi /var/qmail/supervise/qmail-send/run

#!/bin/sh
exec /var/qmail/rc

# vi /var/qmail/supervise/qmail-send/log/run

#!/bin/sh
PATH=/var/qmail/bin:/usr/local/bin:/usr/bin:/bin
export PATH
exec setuidgid qmaill multilog t s100000 n20 /var/log/qmail/qmail-send 2>&1

# vi /var/qmail/supervise/qmail-pop3d/run

#!/bin/sh
PATH=/var/qmail/bin:/usr/local/bin:/usr/bin:/bin
export PATH
exec tcpserver -H -R -v -c100 0 110 qmail-popup test.kr \
/usr/local/vpopmail/bin/vchkpw qmail-pop3d Maildir 2>&1

# vi /var/qmail/supervise/qmail-pop3d/log/run

#!/bin/sh
PATH=/var/qmail/bin:/usr/local/bin:/usr/bin:/bin
export PATH
exec setuidgid qmaill multilog t s100000 n20 /var/log/qmail/qmail-pop3d 2>&1


# vi /var/qmail/supervise/qmail-smtpd/run

#!/bin/sh
QMAILDUID=`id -u vpopmail`
NOFILESGID=`id -g vpopmail`
MAXSMTPD=`cat /var/qmail/control/concurrencyincoming`
LOCAL=`head -1 /var/qmail/control/me`
if [ -z "$QMAILDUID" -o -z "$NOFILESGID" -o -z "$MAXSMTPD" -o -z "$LOCAL" ]; then
     echo QMAILDUID, NOFILESGID, MAXSMTPD, or LOCAL is unset in
     echo /var/qmail/supervise/qmail-smtpd/run
     exit 1
fi
if [ ! -f /var/qmail/control/rcpthosts ]; then
     echo "No /var/qmail/control/rcpthosts!"
     echo "Refusing to start SMTP listener because it'll create an open relay"
     exit 1
fi
exec /usr/local/bin/softlimit -m 30000000 \
/usr/local/bin/tcpserver -v -R -l "$LOCAL" -x /usr/local/vpopmail/etc/tcp.smtp.cdb -c "$MAXSMTPD" \
     -u "$QMAILDUID" -g "$NOFILESGID" 0 smtp \
     /var/qmail/bin/qmail-smtpd test.kr \
     /usr/local/vpopmail/bin/vchkpw /usr/bin/true 2>&1

# echo "20" > /var/qmail/control/concurrencyincoming
# vi /var/qmail/supervise/qmail-smtpd/log/run

#!/bin/sh
PATH=/var/qmail/bin:/usr/local/bin:/usr/bin:/bin
export PATH
exec setuidgid qmaill multilog t s100000 n20 /var/log/qmail/qmail-smtpd 2>&1

# chmod 755 /var/qmail/rc
# chmod 755 /var/qmail/supervise/qmail-send/run
# chmod 755 /var/qmail/supervise/qmail-send/log/run
# chmod 755 /var/qmail/supervise/qmail-smtpd/run
# chmod 755 /var/qmail/supervise/qmail-smtpd/log/run
# chmod 755 /var/qmail/supervise/qmail-pop3d/run
# chmod 755 /var/qmail/supervise/qmail-pop3d/log/run

# ln -s /var/qmail/supervise/qmail-send /var/service/
# ln -s /var/qmail/supervise/qmail-smtpd /var/service/

11. vpopmail 패키지 설치
# cd /usr/ports/mail/vpopmail
# make WITH_MYSQL=yes QMAIL_PREFIX=/var/qmail install clean

12. vpopmail 환경설정
# cd /usr/local/vpopmail/etc
# echo "test.kr" > defaultdomain
# chown vpopmail defaultdomain      
# chgrp vchkpw defaultdomain
# cp vpopmail.mysql-dist vpopmail.mysql
# vi vpopmail.mysql

localhost|0|exam_user|exam_password|EXAM_DB

# chmod 640 vpopmail.mysql
# vi tcp.smtp
# chmod 640 tcp.smtp
# ../bin/clearopensmtp  # tcp.smtp.cdb 파일 생성
# ../bin/vadddomain test.kr
Please enter password for postmaster:
enter password again:

# ../bin/vadduser testmaster@test.kr 1234

# ln -s /var/qmail/supervise/qmail-pop3d /var/service/



* qmail 및 vpopmail 데몬이 제대로 실행되었는지 확인 : ps -ax
   qmail-send / qmail-popup / tcp-server / qmail-lspwan ... 등의 데몬이 동작중인지 확인
* 제대로 동작중이지 않은 경우, /var/log 에 있는 각종 로그를 분석하여 문제 해결.