서버관리

본문 바로가기

서버관리

서버관리

FreeBSD 메일서버 설정 - 미완성

페이지 정보

profile_image
작성자 관리자
댓글 0건 조회 768회 작성일 19-05-25 20:43

본문

1. 메일 서버 FreeBSD 5.4 Release 버전 설치
 
 - i386 버전 설치
 - 설치시 sshd 서비스 설정
  (일반사용자 추가하여 group에 wheel을 추가해야 root로 들어갈 수 있음)
 - LANG 환경변수를 ko_KR.eucKR 로 설정(.cshrc 또는 .profile 에 설정)
  csh) setenv LANG ko_KR.eucKR
  sh)  export LANG="ko_KR.eucKR"
 - 설치 후 ssh 로 로긴하여 /stand/sysinstall 실행
  Configure -> Distributions -> ports 설치
 - crontab -e 한 후 타임 서버 설정
  0 0 * * * ntpdate time.bora.net

2. ftp 서버 설정
$> cd /usr/ports/ftp/vsftpd
$> make install clean
$> vi /usr/local/etc/vsftpd.conf
 
// 다음 내용 입력
<< 내용 시작 >>
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_file=/var/log/vsftpd.log
chroot_list_enable=YES
chroot_local_user=YES
userlist_enable=YES
userlist_deny=YES
listen=NO
<< 내용 끝 >>
$> vi /usr/local/etc/vsftpd.chroot_list
// chroot 기능을 없앨 아이디 입력 후 저장(상위 디렉토리 접근 가능한 아이디 입력)
$> vi /usr/local/etc/vsftpd.user_list
// ftp 접속을 거절할 아이디 입력 후 저장
$> vi /etc/inetd.conf
// 다음 내용 입력
<< 내용 시작 >>
ftp stream tcp nowait root /usr/local/libexec/vsftpd vsftpd
ftp stream tcp6 nowait root /usr/local/libexec/vsftpd vsftpd
<< 내용 끝 >>
$> vi /etc/rc.conf
// 다음 내용 입력
<< 내용 시작 >>
inetd_enable="YES"
<< 내용 끝 >>
$> /etc/rc.d/inetd restart
 
3. mysql 설치
 
$> cd /usr/ports/databases/mysql41-server
$> make WITH_CHARSET=euckr WITH_COLLATION=euckr_korean_ci install clean
$> vi /etc/rc.conf
// 다음 내용 입력
<< 내용 시작 >>
mysql_enable="YES"
<< 내용 끝 >>
$> vi /usr/local/etc/rc.d/mysql-server.sh
 
// $bindir/mysqld_safe --datadir=$datadir --pid-file=$pid_file 라인을 찾아 --language=korean 추가
 
$> /usr/local/etc/rc.d/mysql-server.sh start
$> /usr/local/bin/mysql -u root
 
// mysql 암호 설정 후 quit

4. qmail, vpopmail 설치
$> cd /usr/ports/mail/qmail
$> make install
$> cd /usr/ports/mail/qmail/work/qmail-1.03
$> ./config-fast mail.onion.co.kr
$> cd /usr/ports/sysutils/ucspi-tcp
$> make install clean
$> cd /usr/ports/sysutils/daemontools
$> make install clean
// qmail 스크립트 작성
$> vi /var/qmail/rc
 
// 다음 내용 기록 후 저장
<< 내용 시작 >>
#!/bin/sh
exec env - PATH="/var/qmail/bin:$PATH" \
qmail-start ./Maildir/
<< 내용 끝 >>
 
$> chmod a+x /var/qmail/rc
 
$> mkdir -p /var/qmail/supervise/qmail-send/log
$> mkdir -p /var/qmail/supervise/qmail-smtpd/log
$> chmod +t /var/qmail/supervise/qmail-send
$> chmod +t /var/qmail/supervise/qmail-smtpd
 
$> vi /var/qmail/supervise/qmail-send/run
 
// 다음 내용 기록 후 저장
#!/bin/sh
exec /var/qmail/rc
 
$> vi /var/qmail/supervise/qmail-send/log/run
 
// 다음 내용 기록 후 저장
#!/bin/sh
exec /usr/local/bin/setuidgid qmaill \
    /usr/local/bin/multilog t /var/log/qmail
$> vi /var/qmail/supervise/qmail-smtpd/run
 
// 다음 내용 기록 후 저장
#!/bin/sh
Q_UID=`id -u vpopmail`
Q_GID=`id -g vpopmail`
exec /usr/local/bin/softlimit -m 6000000 \
    /usr/local/bin/tcpserver -vRHl 0 -x /usr/local/vpopmail/etc/tcp.smtp.cdb \
    -u $Q_UID -g $Q_GID 0 25 /var/qmail/bin/qmail-smtpd 2>&1
 
$> vi /var/qmail/supervise/qmail-smtpd/log/run
 
// 다음 내용 기록 후 저장
#!/bin/sh
exec /usr/local/bin/setuidgid qmaill \
    /usr/local/bin/multilog t /var/log/qmail/smtpd
 
$> 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
 
$> mkdir -p /var/log/qmail/smtpd
$> chown qmaill /var/log/qmail /var/log/qmail/smtpd
// sendmail 실행파일 링크
$> ln -s /var/qmail/bin/sendmail /usr/lib
$> rm /usr/sbin/sendmail
$> ln -s /var/qmail/bin/sendmail /usr/sbin
// vpopmail 컴파일
$> cd /usr/ports/mail/vpopmail
$> make WITH_MYSQL=on install clean
// qmail 패치 적용 후 재컴파일
// 패치 파일은 http://qmail.kldp.org 에서 다운로드 받음
// Reversed (or previously applied) patch detected!  Assume -R? 메세지가 나오는 경우 n 을 입력
$> cd /usr/ports/mail/qmail/work/qmail-1.03
$> patch -p1 < ../../files/cocktail+chkuser-0.6.mysql.patch
$> cd /usr/ports/mail/qmail
$> make deinstall
$> make install clean
$> vi /usr/local/vpopmail/etc/vpopmail.mysql
 
// localhost|3306|vpopmailuser|vpopmailpasswd|vpopmail 라인 수정 후 저장
 
$> /usr/local/bin/mysql -u root -p mysql
 
// vpopmail DB 생성, vpopmail 사용자 생성
$> crontab -e
 
// 다음 라인 입력 후 저장
*/30 * * * * /usr/local/vpopmail/bin/clearopensmtp
 
$> mkdir -p /var/qmail/supervise/vpop/log
$> chmod +t /var/qmail/supervise/vpop
 
$> vi /var/qmail/supervise/vpop/run
 
// 다음 내용 기록 후 저장
<< 내용 시작 >>
#!/bin/sh
VPOP_UID=`id -u vpopmail`
VPOP_GID=`id -g vpopmail`
 
exec /usr/local/bin/softlimit -m 10000000 \
    tcpserver -vRHl 0 -u $VPOP_UID -g $VPOP_GID 0 110 \
    /var/qmail/bin/qmail-popup onion.co.kr \
    /usr/local/vpopmail/bin/vchkpw /var/qmail/bin/qmail-pop3d Maildir 2>&1
<< 내용 끝 >>
 
$> chmod 755 /var/qmail/supervise/vpop/run
 
$> vi /var/qmail/supervise/vpop/log/run
 
// 다음 내용 기록 후 저장
<< 내용 시작 >>
#!/bin/sh
exec /usr/local/bin/setuidgid qmaill \
    /usr/local/bin/multilog t /var/log/qmail/vpop
<< 내용 끝 >>
 
$> chmod 755 /var/qmail/supervise/vpop/run
$> chmod 755 /var/qmail/supervise/vpop/log/run
 
$> mkdir -p /var/log/qmail/vpop
$> chown qmaill /var/log/qmail/vpop
 
 

 
 
 
 

<< 프로그램 다운로드 >>
- qmail-1.03 (http://qmail.kldp.org)
- cocktail patch (http://qmail.kldp.org)
- courier-imap (http://www.courier-mta.org/imap/)
- vpopmail (http://www.inter7.com/index.php?page=vpopmail)
- ucspi-tcp, daemontools (http://qmail.kldp.org/src/)
- ezmlm, ezmlm-idx (http://www.ezmlm.org)

// error.h 패치여부는 이미 했으므로 [n]을 선택
$> vi conf-spawn
 
// 1000 -> 500으로 수정
 
$> vi qmail-smtpd.c
 
// #include "readwrite.h" 라인 삭제
 
$> make
$> make setup check
 
$> vi /etc/rc.d/init.d/qmail
 
// 다음 내용 기록 후 저장
 
<< qmail 파일 시작 >>
#!/bin/sh
 
# For Red Hat chkconfig
# chkconfig: - 80 30
# descript-xion: the qmail MTA
 
PATH=/var/qmail/bin:/bin:/usr/bin:/usr/local/bin:/usr/local/sbin
export PATH
 
case "$1" in
  start)
    echo "Starting qmail"
  if [ -e /service/qmail-send ] ; then
  if svok /service/qmail-send ; then
  svc -u /service/qmail-send
  else
  echo qmail-send supervise not running
  fi
  else
  ln -s /var/qmail/supervise/qmail-send /service/
  fi
 
  if [ -e /service/qmail-smtpd ] ; then
  if svok /service/qmail-smtpd ; then
  svc -u /service/qmail-smtpd
  else
  echo qmail-smtpd supervise not running
  fi
  else
  ln -s /var/qmail/supervise/qmail-smtpd /service/
  fi
 
  if [ -e /service/vpop ] ; then
  if svok /service/vpop ; then
  svc -u /service/vpop
  else
  echo vpop supervise not running
  fi
  else
  ln -s /var/qmail/supervise/vpop /service/
  fi
 
    if [ -d /var/lock/subsys ]; then
      touch /var/lock/subsys/qmail
    fi
    ;;
  stop)
    echo "Stopping qmail..."
    echo "  qmail-smtpd"
    svc -dx /service/qmail-smtpd /service/qmail-smtpd/log
  rm -f /service/qmail-smtpd
    echo "  qmail-send"
    svc -dx /service/qmail-send /service/qmail-send/log
  rm -f /service/qmail-send
    echo "  vpop"
    svc -dx /service/vpop /service/vpop/log
  rm -f /service/vpop
    if [ -f /var/lock/subsys/qmail ]; then
      rm /var/lock/subsys/qmail
    fi
    ;;
  stat)
    svstat /service/qmail-send
    svstat /service/qmail-send/log
    svstat /service/qmail-smtpd
    svstat /service/qmail-smtpd/log
    svstat /service/vpop
    svstat /service/vpop/log
    qmail-qstat
    ;;
  doqueue|alrm|flush)
    echo "Flushing timeout table and sending ALRM signal to qmail-send."
    /var/qmail/bin/qmail-tcpok
    svc -a /service/qmail-send
    ;;
  queue)
    qmail-qstat
    qmail-qread
    ;;
  reload|hup)
    echo "Sending HUP signal to qmail-send."
    svc -h /service/qmail-send
    ;;
  pause)
    echo "Pausing qmail-send"
    svc -p /service/qmail-send
    echo "Pausing qmail-smtpd"
    svc -p /service/qmail-smtpd
    echo "Pausing vpop"
    svc -p /service/vpop
    ;;
  cont)
    echo "Continuing qmail-send"
    svc -c /service/qmail-send
    echo "Continuing qmail-smtpd"
    svc -c /service/qmail-smtpd
    echo "Continuing vpop"
    svc -c /service/vpop
    ;;
  restart)
    echo "Restarting qmail:"
    echo "* Stopping qmail-smtpd."
    svc -d /service/qmail-smtpd
    echo "* Sending qmail-send SIGTERM and restarting."
    svc -t /service/qmail-send
    echo "* Restarting qmail-smtpd."
    svc -u /service/qmail-smtpd
    echo "* Sending vpop SIGTERM and restarting."
    svc -t /service/vpop
    ;;
  cdb)
    tcprules /home/vpopmail/etc/tcp.smtp.cdb /home/vpopmail/etc/tcp.smtp.tmp < /home/vpopmail/etc/tcp.smtp
    chmod 644 /home/vpopmail/etc/tcp.smtp.cdb
    echo "Reloaded /home/vpopmail/etc/tcp.smtp."
    ;;
  help)
    cat <<HELP
  stop -- stops mail service (smtp connections refused, nothing goes out)
  start -- starts mail service (smtp connection accepted, mail can go out)
  pause -- temporarily stops mail service (connections accepted, nothing leaves)
  cont -- continues paused mail service
  stat -- displays status of mail service
    cdb -- rebuild the tcpserver cdb file for smtp
restart -- stops and restarts smtp, sends qmail-send a TERM & restarts it
doqueue -- schedules queued messages for immediate delivery
 reload -- sends qmail-send HUP, rereading locals and virtualdomains
  queue -- shows status of queue
  alrm -- same as doqueue
  flush -- same as doqueue
    hup -- same as reload
HELP
    ;;
  *)
    echo "Usage: $0 {start|stop|restart|doqueue|flush|reload|stat|pause|cont|cdb|queue|help}"
    exit 1
    ;;
esac
 
exit 0
<< qmail 파일 끝 >>
$> chmod +x /etc/rc.d/init.d/qmail
$> chkconfig --add qmail
$> ntsysv
 
// /home/vpopmail/bin/vadddomain, /home/vpopmail/bin/vadduser 를 이용한 도메인, 사용자 추가
 
$> /etc/init.d/qmail start
 
5. Anti-Virus, Anti-Spam 설정
 
<< 프로그램 다운로드 >>
- clamav (http://www.clamav.net)
- Digest-SHA1 (http://search.cpan.org)
- SpamAssassin (http://spamassassin.apache.org)
- maildrop (http://prdownloads.sourceforge.net/courier/)
- suidperl (perl-suidperl-5.8.5-9.1.i386.rpm)
- Time-HiRes (perl-Time-HiRes-1.55-3.i386.rpm)
- qmail-scanner (http://qmail-scanner.sourceforge.net)
- zlib-1.2.2.2-1, zlib-devel-1.2.2.2-1 패키지 업그레이드 - clamav 설치시 최신버전 필요
// clamav 설치
$> groupadd clamav
$> useradd -g clamav -s /bin/false -c "Clam AntiVirus" clamav
$> tar -zxvf clamav-0.85.1.tar.gz
$> cd clamav-0.85.1
$> ./configure
$> make
$> make install
$> cp contrib/init/RedHat/clamd /etc/init.d/
$> cd /etc/init.d/
$> chkconfig --level 2345 clamd on
$> vi /usr/local/etc/clamd.conf
 
// 8번째 줄 Example 을 주석 처리한 후 저장
 
$> vi /usr/local/etc/freshclam.conf
 
// 8번째 줄 Example 을 주석 처리한 후 저장
 
$> /etc/init.d/clamd start
$> touch /var/log/clam-update.log
$> chown clamav /var/log/clam-update.log
$> /usr/local/bin/freshclam -d -c 6 -l /var/log/clam-update.log
$> vi /etc/rc.local
 
// /usr/local/bin/freshclam -d -c 6 -l /var/log/clam-update.log 입력 후 저장
 
// SpamAssassin에서 사용되는 펄 모듈 설치
$> tar -zxvf Digest-SHA1-2.10.tar.gz
$> cd Digest-SHA1-2.10
$> perl Makefile.PL
$> make
$> make test
$> make install
 
// SpamAssassin 설치
$> tar -zxvf Mail-SpamAssassin-3.0.3.tar.gz
$> cd Mail-SpamAssassin-3.0.3
$> perl Makefile.PL
$> make
$> make test
$> make install
$> cp spamd/redhat-rc-script-x.sh /etc/rc.d/init.d/spamd
$> echo 'OPTIONS="-d -L -x -u qmailq"' > /etc/sysconfig/spamd
$> chmod 644 /etc/mail/spamassassin/*
$> chmod 644 /etc/sysconfig/spamd
$> chmod 700 /etc/rc.d/init.d/spamd
$> chkconfig --add spamd
$> chkconfig --level 345 spamd on
$> /etc/rc.d/init.d/spamd start
 
// maildrop 설치
$> tar -jxvf maildrop-1.8.1.tar.bz2
$> cd maildrop-1.8.1
$> ./configure \
    --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
 
// suidperl 설치
$> rpm -ivh perl-suidperl-5.8.5-9.1.i386.rpm
$> chmod 4711 /usr/bin/suidperl
 
// Time-HiRes 설치
$> rpm -ivh perl-Time-HiRes-1.55-3.i386.rpm
 
// qmail-scanner 설치
$> tar -zxvf qmail-scanner-1.25.tgz
$> cd qmail-scanner-1.25
$> cp -r locale/en_GB/ locale/ko_KR.eucKR
$> groupadd qscand
$> useradd -c "Qmail-Scanner Account" -g qscand  -s /bin/false qscand
$> ./configure --debug no --log-details syslog --unzip yes
$> ./configure --debug no --log-details syslog --install
$> cp -f quarantine-attachments.txt /var/spool/qmailscan/
$> vi /var/spool/qmailscan/quarantine-attachments.txt
// 다음 라인 추가
<< qmail-scanner 필터 설정 시작 >>
.*광고.* Virus-Subject: ANTI-SPAM(KOREAN-[광고]
.*W7GksO1d.* Virus-Subject: ANTI-SPAM(KOREAN-ENCODE_광고)
.*uau76MGm.* Virus-Subject: ANTI-SPAM(KOREAN-ENCODE_무삭제)
.*무삭제.* Virus-Subject: ANTI-SPAM(KOREAN-무삭제)
.*영어공부.* Virus-Subject: ANTI-SPAM(KOREAN-영어공부)
.*성인광고.* Virus-Subject: ANTI-SPAM(KOREAN-성인광고)
.*\[.*광.*고.*\].* Virus-Subject: ANTI-SPAM(KOREAN-광고)
.*\(.*광.*고.*\).* Virus-Subject: ANTI-SPAM(KOREAN-광고)
.*\<.*광.*고.*\>.* Virus-Subject: ANTI-SPAM(KOREAN-광고)
.*\[.*홍.*보.*\].* Virus-Subject: ANTI-SPAM(KOREAN-홍보)
.*\(.*홍.*보.*\).* Virus-Subject: ANTI-SPAM(KOREAN-홍보)
.*\<.*홍.*보.*\>.* Virus-Subject: ANTI-SPAM(KOREAN-홍보)
.*\[.*정.*보.*\].* Virus-Subject: ANTI-SPAM(KOREAN-정보)
.*\(.*정.*보.*\).* Virus-Subject: ANTI-SPAM(KOREAN-정보)
.*\<.*정.*보.*\>.* Virus-Subject: ANTI-SPAM(KOREAN-정보)
.*\[.*알.*림.*\].* Virus-Subject: ANTI-SPAM(KOREAN-알림)
.*성인.*동영상.* Virus-Subject: ANTI-SPAM(KOREAN-성인동영상)
.*디지털브레인.* Virus-Subject: ANTI-SPAM(KOREAN-디지털브레인)
.*廣.*告.*  Virus-Subject: ANTI-SPAM(KOREAN-광고)
.*【.*광.*고.*】.* Virus-Subject: ANTI-SPAM(KOREAN-광고)
NMK Mailer Virus-Mailer: ANTI-SPAM(Mailer-NMK)
peeeep~~~.scr  12288 MyLife-I/Worm
USA.scr  22528 MyLife-J/Worm
peeeeep.mpeg.scr 7168 MyLife-H/Worm
Sharika.chm  11295 BritneyPic-C/Worm
install.exe  0 Klez-H/Worm
readme.exe  0 Nimda/Worm
readme.exe  57344  Nimda-Virus/Trojan
.exe 0 Executable binary
.com 0 Non relocable MSDOS executable binary
.vbs 0 Visual Basic Script-x
.vba 0 Visual Basic Application
.shs 0 Shell automation code
.scr 0 Screen Saver
.bat 0 COMMAND.COM batch file
.btm 0 JP Software fast batch file
.reg 0 Windows Registry file
.msi 0 Windows Installer Package
.msc 0 Common Console Document
.chm 0 Compiled HTML help file
.inf 0 Setup Information file
.cpl 0 Control Panel library
.wsf 0 Windows Script-xing File
.vbe 0 VisualBasic Encoded
.js 0 JavaScript-x
.jse 0 JavaScript-x Encoded
.css 0 Cascading Style Sheets
.wsh 0 Windows Script-xing Host
.sct 0 Script-xlet File
.hta 0 HTML Application
.lnk 0 Windows Explorer links
.cmd 0 cmd.exe NT batch file
.pif 0 Windows Program Information Files win32/winever.worm
.ceo 0 win32/winever.worm
.ade 0 Access Project Extension
.mdb 0 Access Application
.adp 0 Access Project
.mde 0 Access MDE Database
.bas 0 Visual Basic Class Module
.msp 0 Windows Installer Patch
.mst 0 Visual Test Source File
.pcd 0 Photo CD Image
.crt 0 Security Certificate
.hlp 0 Windows Help File
.url 0 Internet Shortcut (Uniform Resource Locator)
.ins 0 Internet Communication Settings
.isp 0 Internet Communication Settings
.vb 0 Script-x Script-x File
.wsc 0 Windows Script-x Component
.shb 0 Shell Scrap object
<< qmail-scanner 필터 설정 끝 >>
$> chown qmailq.qmail /var/spool/qmailscan/quarantine-attachments.txt
$> chmod 660 /var/spool/qmailscan/quarantine-attachments.txt
$> chown qscand.qscand /var/qmail/bin/qmail-scanner-queue.pl
$> chmod 4755 /var/qmail/bin/qmail-scanner-queue.pl
$> vi /var/qmail/bin/qmail-scanner-queue.pl
// $V_FROM, $QUARANTINE_CC 메일 계정 확인 후 수정
// $spamc_subject='' 에 스팸 표시 헤더 지정
$> /var/qmail/bin/qmail-scanner-queue.pl -g
 
$> vi /var/qmail/supervise/qmail-smtpd/run
// 다음 라인 추가
<< QMAILQUEUE 환경변수 설정 시작 >>
QMAILQUEUE="/var/qmail/bin/qmail-scanner-queue.pl"
export QMAILQUEUE
<< QMAILQUEUE 환경변수 설정 끝 >>
 
$> /etc/rc.d/init.d/qmail restart
$> crontab -e
 
// 다음 라인을 추가 후 저장하여 스케쥴 등록
<< 스케쥴 라인 시작 >>
*/10 * * * * find /var/spool/qmailscan/quarantine/new/ -type f -exec rm -f {} \; >& /dev/null
<< 스케쥴 라인 끝 >>
 
// 다음 명령을 실행하여 qmail-scanner 테스트
$> contrib/test_installation.sh -doit

6. apache, php 설치
 
<< 프로그램 다운로드 >>
- httpd-2.0.54.tar.gz (http://www.apache.org)
- php-5.0.4.tar.gz (http://www.php.net)
- ZendOptimizer-2.5.10-linux-glibc21-i386.tar.gz (http://www.zend.com)
- libpng-devel, libjpeg-devel, freetype-devel, libidn-devel 패키지 추가 - php 컴파일에서 사용
// apache 설치
$> tar -zxvf httpd-2.0.54.tar.gz
$> cd httpd-2.0.54
$> ./configure --prefix=/usr/local/httpd --enable-modules=so --enable-so
$> make
$> make install
 
// php 설치
$> tar -zxvf php-5.0.4.tar.gz
$> cd php-5.0.4
$> vi configure
 $> ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/httpd/bin/apxs --with-libxml2 --with-zlib --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-gd --enable-soap --enable-sockets --with-ttf --with-expat --with-gmp --with-png-dir --with-jpeg-dir --with-freetype-dir --enable-gd-native-ttf --with-language=korean --with-charset=euc-kr --disable-debug --enable-ftp --disable-posix --disable-rpath --enable-magic-quotes --disable-dmalloc --enable-gd-native-ttf --enable-sysvsem --enable-sysvshm --enable-wddx --enable-versioning --enable-pic --enable-inline-optimization --enable-memory-limit --enable-mbstring --enable-mbregex --enable-mbstr-enc-trans --enable-track-vars=yes --enable-dl
$> make
$> make install
 
$> cp php.ini-dist /usr/local/php/lib/php.ini
$> vi /usr/local/httpd/conf/httpd.conf
 
// AddType 추가
<< 추가 시작 >>
AddType application/x-httpd-php .html .htm .php .inc
AddType application/x-httpd-php-source .phps
<< 추가 끝 >>
// sendmail 경로 설정
 
$> tar -zxvf ZendOptimizer-2.5.10-linux-glibc21-i386.tar.gz
$> cd ZendOptimizer-2.5.10-linux-glibc21-i386
$> ./install.sh
// Zend 설정
 
$> cp /usr/local/httpd/bin/apachectl /etc/rc.d/init.d/httpd
$> cd /etc/rc3.d
$> ln -s ../init.d/httpd S92httpd
$> cd /etc/rc5.d
$> ln -s ../init.d/httpd S92httpd

7. chroot 설치 ==> 성공하지 못함
// 초기 설정
$> cd ~virtual
$> chmod 755 .
$> chown root.root .
$> rm -f .[a-z]*
$> mkdir bin dev etc home lib root sbin tmp usr var
// bin 디렉토리 구성
$> cd /bin
$> cp -a cut ls rm touch date gettext mkdir rmdir true grep gtar gunzip more bash gzip sed mv cat echo sh vi ed egrep kill sort cp ln false pwd tar csh fgrep tcsh chmod chown chgrp hostname ~virtual/bin/.
// sbin 디렉토리 구성
$> cp -a /sbin/nologin ~virtual/sbin
// var 디렉토리 구성
$> mkdir ~virtual/var/log
$> mkdir -p ~virtual/var/lock/subsys
// etc 디렉토리 구성
$> mkdir -p ~virtual/usr/local/httpd/htdocs
$> cd /etc
$> cp -a group hosts localtime my.cnf nsswitch.conf passwd resolv.conf shadow ~virtual/etc/.
$> vi ~virtual/etc/passwd
// root, mysql, nobody 계정 제외한 라인 삭제
$> vi ~virtual/etc/shadow
// mysql, nobody 를 제외한 라인 삭제 후 저장
$> vi ~virtual/etc/group
// root, wheel, mysql, nobody 그룹 제외한 라인 삭제
$> vi ~virtual/etc/my.cnf
// 파일을 다음 내용으로 변경 후 저장
<< 변경 내용 시작 >>
[mysqld]
user=root
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
skip-innodb
[client]
user=root
socket=/tmp/mysql.sock
[safe_mysqld]
err-log=/var/log/mysqld.log
pid-file=/usr/local/mysql/data/mysqld.pid
<< 변경 내용 끝 >>
$> chattr +i ~virtual/etc/*
// ~virtual/etc/* 파일을 삭제하기 위해서는 먼저 chattr -i ~virtual/etc/* 를 실행해야 함
$> mknod ~virtual/dev/null c 1 3
$> chmod 1777 ~virtual/tmp
$> cd ~virtual/usr
$> mkdir bin include lib sbin share
$> cd /usr/bin
$> cp -a id whoami groups split tee dirname ~virtual/usr/bin/
$> cd ~virtual/usr/local
$> mkdir include lib
$> cp -ra /usr/local/httpd/ ~virtual/usr/local
$> cp -ra /usr/local/mysql/ ~virtual/usr/local
$> cp -ra /usr/local/php/ ~virtual/usr/local
$> cp -ra /usr/local/Zend/ ~virtual/usr/local
$> mkdir ~virtual/lib
$> cp -a /lib/*.* ~virtual/lib
$> mkdir ~virtual/lib/tls
$> cp -a /lib/tls/*.* ~virtual/lib/tls
$> cd /usr/lib
// /이 외 필요한 라이브러리가 있으면 ldd 명령으로 찾아 복사 (예: ldd /usr/bin/passwd)
$> vi /etc/init.d/httpd
// HTTPD='/usr/local/httpd/bin/httpd' 부분을 HTTPD='chroot /home/virtual /usr/local/httpd/bin/httpd' 로 수정
// /usr/local/httpd/bin/envvars 부분을 /home/virtual/usr/local/httpd/bin/envvars 로 수정 후 저장
$> /etc/init.d/httpd start
$> vi /etc/init.d/mysqld
// cd $basedir 부분을 cd /home/virtual/$basedir 로 수정
// $bindir/my_print_defaults 부분을 "/home/virtual/$bindir/my_print_defaults" 로 수정
// test -x "$bindir/mysqld_safe" 부분을 test -x "/home/virtual/$bindir/mysqld_safe" 로 수정
// $bindir/mysqld_safe --datadir=$datadir... 부분을 chroot /home/virtual $bindir/mysqld_safe --datadir=$datadir... 로 수정
// /var/lock/subsys... 부분을 /home/virtual/var/lock/subsys...로 수정 후 저장
// 기타 필요한 부분에 /home/virtual 경로 덧붙이기
$> ln -s /usr/local/mysql/include/mysql ~virtual/usr/local/include/mysql
$> ln -s /usr/local/mysql/include/mysql ~virtual/usr/include/mysql
$> ln -s /usr/local/mysql/lib/mysql ~virtual/usr/local/lib/mysql
$> ln -s /usr/local/mysql/lib/mysql ~virtual/usr/lib/mysql
$> /etc/init.d/mysqld start

8. 웹메일 설치
<< 프로그램 다운로드 >>
- PEAR DB (http://pear.php.net/)
- tcl (tcl-8.4.7-2.i386.rpm)
- expect (expect-5.42.1-1.i386.rpm)
- courier-authlib (http://www.courier-mta.org/authlib/)
- courier-imap (http://www.courier-mta.org/imap/)
- squirrelmail (http://www.squirrelmail.org)
- ko_KR-1.4.4 (http://sourceforge.net/project/showfiles.php?group_id=311&package_id=110388)
// PEAR DB 설치
$> tar -zxvf DB-1.7.6.tgz
$> cd DB-1.7.6
$> mv DB* /usr/local/php/lib/php/
// expect 설치(의존성 문제로 먼저 tcl 설치)
$> rpm -ivh tcl-8.4.7-2.i386.rpm
$> rpm -ivh expect-5.42.1-1.i386.rpm
 
// authlib 설치
$> tar -jxvf courier-authlib-0.56.tar.bz2
$> cd courier-authlib-0.56
$> ./configure \
  --prefix=/usr/local/courier/authlib \
  --with-redhat \
  --without-authpam \
  --without-authldap \
  --without-authpwd \
  --without-authmysql \
  --without-authpgsql \
  --without-authshadow \
  --without-authuserdb \
  --without-authcustom \
  --without-authcram \
  --with-authvchkpw
$> make
$> make install
$> make install-configure
$> cp courier-authlib.sysvinit /etc/init.d/courier-authlib
$> chmod 744 /etc/init.d/courier-authlib
$> chkconfig --add courier-authlib
$> /etc/init.d/courier-authlib start
// imap 설치
$> tar -jxvf courier-imap-4.0.3.tar.bz2
$> chown -R root.root courier-imap-4.0.3
$> cd courier-imap-4.0.3
$> COURIERAUTHCONFIG=/usr/local/courier/authlib/bin/courierauthconfig \
  CPPFLAGS=-I/usr/local/courier/authlib/include \
  ./configure \
    --prefix=/usr/local/courier/imap \
    --with-redhat \
    --disable-root-check \
    --with-ssl
$> make
$> make install
$> make install-configure
$> vi /usr/local/courier-imap/etc/imapd
// 다음 내용 수정
<< 수정할 내용 시작 >>
MAXDAEMONS=40
MAXPERIP=40
IMAP_EMPTYTRASH=Trash:7,Sent:30
IMAPDSTART=YES
<< 수정할 내용 끝 >>
$> cp courier-imap.sysvinit /etc/init.d/courier-imap
$> chmod 744 /etc/init.d/courier-imap
$> chkconfig --add courier-imap
$> /etc/init.d/courier-imap start
// squirrelmail 설치
$> mkdir ~virtual/squirrelmail
$> cd ~virtual/squirrelmail
$> tar -jxvf squirrelmail-1.4.4.tar.bz2
$> chown -R root.nobody squirrelmail-1.4.4
$> chmod -R 750 squirrelmail-1.4.4
$> mv squirrelmail-1.4.4 회사명-1.4.4
$> cd 회사명-1.4.4
$> chown -R nobody.nobody data
$> mkdir /var/spool/attach
$> chgrp nobody /var/spool/attach
$> chmod 730 /var/spool/attach
$> crontab -e
// 주기적 첨부파일 삭제를 위해 다음 라인 입력 후 저장
<< 입력 시작 >>
find /var/spool/attach -atime +1 -type f -exec rm -f {} \; >& /dev/null
<< 입력 끝 >>
$> cd config
$> perl conf.pl
<< 환경설정 시작 >>
D. SET PRE-DEFINED SETTINGS FOR SPECIFIC IMAP SERVERS
  Choose courier
1. ORGANIZATION PREFERENCES
  1.  Organization name            : YourCompany WebMail
  2.  Organization Logo            : /images/yourcompanylogo-100.gif
  3.  Org. Logo Height/Width      : 100/100
  4.  Organization title          : YourCompany WebMail (v$version)
  7.  Provider link                : http://www.yourdomain.com
  8.  Provider name                : YourCompany
2. SERVER SETTINGS
  1.  Domain                      : yourdomain.com
4. GENERAL OPTIONS
  2.  Attachment directory        : /var/spool/attach
5. Themes
  2.  CSS File                    : ../themes/css/default.css
6. ADDRESS BOOKS
  2. Use Javascript-x Address Book Search : True
9. DATABASE
  1.  DSN for address book : mysql://squirreluser:squirrelpassword@localhost/squirrelmail
  3.  DSN for preferences  : mysql://squirreluser:squirrelpassword@localhost/squirrelmail
10. Languages
  1. Default Language : ko_KR
  2. Default Charset : EUC-KR
<< 환경설정 끝 >>
// 스타일시트를 적용하기 위해 /themes/css/default.css 파일을 root.nobody 권한으로 생성
// 웹메일 로케일 설정
$> tar -jxvf ko_KR-1.4.4-20050308.tar.bz2
$> ./install
// squirrelmail 경로 입력하면 locale 설정됨
$> vi locale/ko_KR/LC_MESSAGES/squirrelmail.po
// 다음 부분 수정 후 저장
<< 수정 부분 시작 >>
msgid "Last Refresh"
msgstr "최종갱신"
msgid "Sent"
msgstr "보낸 편지함"
msgid "Draft"
msgstr "임시 보관함"
msgid "Trash"
msgstr "휴지통"
<< 수정 부분 끝 >>
$> vi functions/imap_mailbox.php
// 다음 부분 수정 후 저장
<< 수정 부분 시작 >>
$box2 = str_replace(' ', '&nbsp;', htmlspecialchars(imap_utf7_decode_local(_($boxes_part['unformatted-disp']))));
<< 수정 부분 끝 >>
$> vi src/left_main.php
// 다음 부분 수정 후 저장
<< 수정 부분 시작 >>
$line .= str_replace(array(' ','<','>'),array('&nbsp;','&lt;','&gt;'),_($mailbox));
<< 수정 부분 끝 >>
$> mysql -u root -p
<< squirrelmail 관련 DB 설정 시작 >>
mysql> CREATE DATABASE squirrelmail;
mysql> GRANT select,insert,update,delete ON squirrelmail.* TO squirreluser@localhost IDENTIFIED BY 'squirrelpassword';
mysql> USE squirrelmail;
mysql> CREATE TABLE address (
  owner varchar(128) DEFAULT '' NOT NULL,
  nickname varchar(16) DEFAULT '' NOT NULL,
  firstname varchar(128) DEFAULT '' NOT NULL,
  lastname varchar(128) DEFAULT '' NOT NULL,
  email varchar(128) DEFAULT '' NOT NULL,
  label varchar(255),
  PRIMARY KEY (owner,nickname),
  KEY firstname (firstname,lastname)
);
mysql> CREATE TABLE userprefs (
  user varchar(128) DEFAULT '' NOT NULL,
  prefkey varchar(64) DEFAULT '' NOT NULL,
  prefval blob DEFAULT '' NOT NULL,
  PRIMARY KEY (user,prefkey)
);
<< squirrelmail 관련 DB 설정 끝 >>
// apache 환경 설정
$> vi /usr/local/httpd/conf/httpd.conf
// 다음 라인 수정/입력 후 저장
<< 환경설정 시작 >>
Group nobody
...
ServerAdmin admin@mail-address
...
DirectoryIndex index.html index.html.var index.php index.htm
...
AddHandler cgi-script-x .cgi
...
NameVirtualHost server.ip.address
...
<VirtualHost server.ip.address>
    ServerAdmin admin@mail-address
    DocumentRoot /path/to/main/dir
    ServerName domain.name
    ErrorLog logs/domain.name-error_log
    CustomLog logs/domain.name-access_log common
</VirtualHost>
<< 환경설정 끝 >>
$> /etc/init.d/httpd restart
// 브라우저에서 http://domain.name/src/configtest.php 입력하여 환경설정 테스트

9. 서버 백업
// 두번째 디스크를 포맷 후 /var/backup 디렉토리에 마운트
$> mkdir /var/backup/data
$> mkdir /var/backup/log
$> vi /var/backup/run.sh
// 백업할 내용 입력하고, 저장 후 종료
$> crontab -e
// 다음 라인 추가하고, 저장한 후 종료
<< 추가 라인 시작 >>
0 2 * * * /var/backup/run.sh
0 2 * * * find /var/backup/data -type f -ctime +7 -exec rm -f {} \;
30 2 * * * find /var/backup/data -type d -ctime +7 -exec rmdir {} \;
<< 추가 라인 종료 >>

댓글목록

등록된 댓글이 없습니다.

회원로그인


  • 케이엔아이시스템
  • 대표 : 김현철
  • 경기도 안양시 동안구 부림로80 한양빌딩 601-1201
  • TEL : 010-2890-1451
  • E-mail : khc@knisystem.co.kr
  • 사업자등록번호 : 130-31-39246
Copyright © KNISYSTEM All rights reserved.