서버 설정 · 3 min read · Feb 03, 2026

Debian Sarge (3.1) with Ruby on Rails and Apache 2 with FastCGI - Page 3

MySQL 설치

apt-get install mysql-server mysql-client libmysqlclient12-dev

MySQL 루트 비밀번호 설정

mysqladmin -u root password yourrootsqlpassword  
mysqladmin -h server1.example.com -u root password yourrootsqlpassword

netstat -tap을 실행하면 이제 다음과 같은 줄이 표시되어야 합니다:

| tcp 0 0 localhost.localdo:mysql *:* |

이는 MySQL이 127.0.0.1의 포트 3306에서 접근 가능함을 의미합니다. 다음 섹션(포스트픽스)으로 이동할 수 있습니다. 이 줄이 보이지 않으면 /etc/mysql/my.cnf를 편집하고 skip-networking을 주석 처리하십시오:

| # skip-networking |

MySQL이 모든 사용 가능한 IP 주소에서 수신 대기하도록 하려면 /etc/mysql/my.cnf를 편집하고 bind-address = 127.0.0.1을 주석 처리하십시오:

| # bind-address = 127.0.0.1 |

/etc/mysql/my.cnf를 편집해야 했다면 MySQL을 재시작해야 합니다:

/etc/init.d/mysql restart

Postfix/POP3/IMAP 설치

SMTP-AUTH 및 TLS와 함께 Postfix를 설치하고 POP3 서버와 IMAP 서버를 설치하려면 다음 단계를 수행하십시오:

apt-get install postfix postfix-tls libsasl2 sasl2-bin libsasl2-modules ipopd-ssl uw-imapd-ssl

프롬프트에 다음과 같이 답하십시오:

libc-client를 Maildir 지원 없이 계속 설치하시겠습니까? 답변: 아니요
서버가 수신 대기할 포트는 무엇입니까? 답변: pop3 및 pop3s
포트 선택을 강제하시겠습니까? 답변: 아니요
서버가 수신 대기할 포트는 무엇입니까? 답변: imap2 및 ipmaps
포트 선택을 강제하시겠습니까? 답변: 아니요
구성의 일반 유형은 무엇입니까? 답변: 인터넷 사이트
루트에 대한 메일은 어디로 가야 합니까? 답변: 없음
메일 이름은 무엇입니까? 답변: server1.example.com
메일을 수신할 다른 목적지는 무엇입니까? (없으면 비워두기) 답변: server1.example.com, localhost.example.com, localhost
메일 큐에서 동기식 업데이트를 강제하시겠습니까? 답변: 아니요

이제 postfix를 구성하십시오:

postconf -e 'smtpd_sasl_local_domain ='  
postconf -e 'smtpd_sasl_auth_enable = yes'  
postconf -e 'smtpd_sasl_security_options = noanonymous'  
postconf -e 'broken_sasl_auth_clients = yes'  
postconf -e 'smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination'  
postconf -e 'inet_interfaces = all'  
echo 'pwcheck_method: saslauthd' >> /etc/postfix/sasl/smtpd.conf  
echo 'mech_list: plain login' >> /etc/postfix/sasl/smtpd.conf

SSL 설정

mkdir /etc/postfix/ssl  
cd /etc/postfix/ssl/  
openssl genrsa -des3 -rand /etc/hosts -out smtpd.key 1024

smtpd.key에 대한 비밀번호를 입력해야 합니다(4~8191자)

chmod 600 smtpd.key  
openssl req -new -key smtpd.key -out smtpd.csr

인증서 요청을 작성하거나 기본값을 사용하십시오

openssl x509 -req -days 3650 -in smtpd.csr -signkey smtpd.key -out smtpd.crt

이전에 입력한 smtpd.key에 대한 비밀번호를 입력해야 합니다

openssl rsa -in smtpd.key -out smtpd.key.unencrypted

이전에 입력한 smtpd.key에 대한 비밀번호를 입력해야 합니다

mv -f smtpd.key.unencrypted smtpd.key
openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650

인증서 요청을 작성하거나 기본값을 사용하십시오

Postfix 구성을 추가로 수행하십시오

postconf -e 'smtpd_tls_auth_only = no'  
postconf -e 'smtp_use_tls = yes'  
postconf -e 'smtpd_use_tls = yes'  
postconf -e 'smtp_tls_note_starttls_offer = yes'  
postconf -e 'smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key'  
postconf -e 'smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt'  
postconf -e 'smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem'  
postconf -e 'smtpd_tls_loglevel = 1'  
postconf -e 'smtpd_tls_received_header = yes'  
postconf -e 'smtpd_tls_session_cache_timeout = 3600s'  
postconf -e 'tls_random_source = dev:/dev/urandom'

이제 /etc/postfix/main.cf 파일은 다음과 같아야 합니다:

joe /etc/postfix/main.cf

| # See /usr/share/postfix/main.cf.dist for a commented, more complete version smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU) biff = no # appending .domain is the MUA's job. append_dot_mydomain = no # Uncomment the next line to generate "delayed mail" warnings #delay_warning_time = 4h myhostname = server1.example.com alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases myorigin = /etc/mailname mydestination = server1.example.com, localhost.example.com, localhost relayhost = mynetworks = 127.0.0.0/8 mailbox_command = procmail -a "$EXTENSION" mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = all smtpd_sasl_local_domain = smtpd_sasl_auth_enable = yes smtpd_sasl_security_options = noanonymous broken_sasl_auth_clients = yes smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination smtpd_tls_auth_only = no smtp_use_tls = yes smtpd_use_tls = yes smtp_tls_note_starttls_offer = yes smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem smtpd_tls_loglevel = 1 smtpd_tls_received_header = yes smtpd_tls_session_cache_timeout = 3600s tls_random_source = dev:/dev/urandom |

Postfix 재시작

/etc/init.d/postfix restart

인증은 saslauthd에 의해 수행됩니다. 제대로 작동하도록 몇 가지를 변경해야 합니다. Postfix가 /var/spool/postfix에서 chroot로 실행되기 때문에 다음을 수행해야 합니다:

mkdir -p /var/spool/postfix/var/run/saslauthd

이제 /etc/default/saslauthd를 편집하여 saslauthd를 활성화해야 합니다. START=yes 앞의 #을 제거하고 PARAMS=”-m /var/spool/postfix/var/run/saslauthd -r”라는 줄을 추가하십시오:

joe /etc/default/saslauthd

| # This needs to be uncommented before saslauthd will be run automatically START=yes PARAMS="-m /var/spool/postfix/var/run/saslauthd -r" # You must specify the authentication mechanisms you wish to use. # This defaults to "pam" for PAM support, but may also include # "shadow" or "sasldb", like this: # MECHANISMS="pam shadow" MECHANISMS="pam" |

이제 saslauthd를 시작하십시오:

/etc/init.d/saslauthd start

다음으로 /etc/c-client.cf 파일을 생성합니다:

echo "I accept the risk" > /etc/c-client.cf echo "set disable-plaintext 0" >> /etc/c-client.cf

이제 inetd를 재시작하십시오:

/etc/init.d/inetd restart

이 작업을 수행하지 않으면 POP3/IMAP 로그인이 실패합니다.

SMTP-AUTH 및 TLS가 제대로 작동하는지 확인하려면 다음 명령을 실행하십시오:

telnet localhost 25

Postfix 메일 서버에 연결한 후 다음을 입력하십시오:

ehlo localhost

다음 줄이 표시되면:

250-STARTTLS

250-AUTH

모든 것이 정상입니다.

quit

시스템의 셸로 돌아갑니다.

Maildir 지원이 있는 Courier-IMAP/Courier-POP3 설치

apt-get install courier-imap courier-imap-ssl courier-pop courier-pop-ssl

프롬프트에 다음과 같이 답하십시오:

웹 기반 관리용 디렉토리를 생성하시겠습니까? 답변: 아니요
SSL 인증서가 필요합니까? 답변: 확인

그런 다음 Postfix를 구성하여 사용자의 Maildir로 이메일을 전달합니다:

postconf -e 'home_mailbox = Maildir/'  
postconf -e 'mailbox_command ='  
/etc/init.d/postfix restart
Share: X/Twitter LinkedIn

새 게시물을 받은 편지함에서 받기

스팸은 없습니다. 언제든지 구독 해지 가능합니다.