서버 설정 · 3 min read · Oct 16, 2025

완벽한 설정 - CentOS 4.4 (32비트) - 페이지 5

10 Postfix With SMTP-AUTH And TLS

이제 Postfix와 dovecot를 설치합니다 (dovecot는 우리의 POP3/IMAP 서버가 됩니다):

yum install cyrus-sasl cyrus-sasl-devel cyrus-sasl-gssapi cyrus-sasl-md5 cyrus-sasl-plain postfix dovecot

다음으로 SMTP-AUTH와 TLS를 구성합니다:

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'
postconf -e 'mynetworks = 127.0.0.0/8'

Postfix가 PLAIN 및 LOGIN 로그인을 허용하도록 /usr/lib/sasl2/smtpd.conf를 편집해야 합니다. 64비트 Centos 4.4에서는 /usr/lib64/sasl2/smtpd.conf 파일을 대신 편집해야 합니다. 파일은 다음과 같아야 합니다:

vi /usr/lib/sasl2/smtpd.conf

| pwcheck_method: saslauthd mech_list: plain login |

mkdir /etc/postfix/ssl
cd /etc/postfix/ssl/
openssl genrsa -des3 -rand /etc/hosts -out smtpd.key 1024
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
openssl rsa -in smtpd.key -out smtpd.key.unencrypted
mv -f smtpd.key.unencrypted smtpd.key
openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650
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는 다음과 같아야 합니다 (모든 주석을 제거했습니다):

vi /etc/postfix/main.cf

| queue_directory = /var/spool/postfix command_directory = /usr/sbin daemon_directory = /usr/libexec/postfix mail_owner = postfix inet_interfaces = all mydestination = $myhostname, localhost.$mydomain, localhost unknown_local_recipient_reject_code = 550 alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases debug_peer_level = 2 debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin xxgdb $daemon_directory/$process_name $process_id & sleep 5 sendmail_path = /usr/sbin/sendmail.postfix newaliases_path = /usr/bin/newaliases.postfix mailq_path = /usr/bin/mailq.postfix setgid_group = postdrop html_directory = no manpage_directory = /usr/share/man sample_directory = /usr/share/doc/postfix-2.1.5/samples readme_directory = /usr/share/doc/postfix-2.1.5/README_FILES 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 mynetworks = 127.0.0.0/8 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 |

기본적으로 CentOS의 dovecot 데몬은 IMAP 및 IMAPs 서비스만 제공합니다. POP3 및 POP3s도 원하므로 dovecot을 구성해야 합니다. /etc/dovecot.conf를 편집하고 protocols = imap imaps pop3 pop3s를 추가합니다:

vi /etc/dovecot.conf

| [...] # Base directory where to store runtime data. #base_dir = /var/run/dovecot/ # Protocols we want to be serving: # imap imaps pop3 pop3s protocols = imap imaps pop3 pop3s # IP or host address where to listen in for connections. It's not currently # possible to specify multiple addresses. "*" listens in all IPv4 interfaces. [...] |

이제 Postfix, saslauthd 및 dovecot을 시작합니다:

chkconfig --levels 235 sendmail off
chkconfig --levels 235 postfix on
chkconfig --levels 235 saslauthd on
chkconfig --levels 235 dovecot on
/etc/init.d/sendmail stop
/etc/init.d/postfix start
/etc/init.d/saslauthd start
/etc/init.d/dovecot start

SMTP-AUTH와 TLS가 제대로 작동하는지 확인하려면 다음 명령을 실행합니다:

telnet localhost 25

Postfix 메일 서버에 연결한 후 다음을 입력합니다:

ehlo localhost

다음과 같은 줄이 보이면

250-STARTTLS

250-AUTH

모든 것이 정상입니다.

quit

를 입력하여 시스템의 셸로 돌아갑니다.

10.1 Maildir

dovecot은 Maildir 형식(mbox 아님)을 사용하므로 서버에 ISPConfig를 설치하는 경우 Management -> Server -> Settings -> Email에서 Maildir을 활성화해야 합니다. ISPConfig는 필요한 구성을 수행합니다.

ISPConfig를 설치하고 싶지 않다면 Postfix를 구성하여 사용자의 Maildir로 이메일을 배달해야 합니다:

postconf -e 'home_mailbox = Maildir/'
postconf -e 'mailbox_command ='
/etc/init.d/postfix restart

11 Apache2 With PHP

이제 PHP와 함께 Apache를 설치합니다 (이것은 PHP 4.3.9입니다; CentOS는 PHP5 패키지를 제공하지 않습니다):

yum install php php-devel php-gd php-imap php-ldap php-mysql php-odbc php-pear php-xml php-xmlrpc curl curl-devel perl-libwww-perl ImageMagick libxml2 libxml2-devel

그런 다음 /etc/httpd/conf/httpd.conf를 편집합니다:

vi /etc/httpd/conf/httpd.conf

그리고 DirectoryIndex를 다음으로 변경합니다:

| DirectoryIndex index.html index.htm index.shtml index.cgi index.php index.php3 index.pl |

이제 시스템이 부팅 시 Apache를 시작하도록 구성합니다:

chkconfig --levels 235 httpd on

Apache를 시작합니다:

/etc/init.d/httpd start

11.1 PHP 전역 비활성화

(이 서버에 ISPConfig를 설치할 계획이 없다면 이 섹션을 건너뛰세요!)

ISPConfig에서는 웹사이트별로 PHP를 구성합니다. 즉, 어떤 웹사이트가 PHP 스크립트를 실행할 수 있고 어떤 웹사이트가 실행할 수 없는지를 지정할 수 있습니다. PHP가 전역적으로 비활성화되어야만 이 기능이 작동합니다. 그렇지 않으면 모든 웹사이트가 ISPConfig에서 지정한 것과 관계없이 PHP 스크립트를 실행할 수 있습니다.

PHP를 전역적으로 비활성화하려면 /etc/httpd/conf.d/php.conf를 편집하고 AddType 줄을 주석 처리합니다:

vi /etc/httpd/conf.d/php.conf

| # # PHP는 개발자가 동적으로 생성된 웹페이지를 쉽게 작성할 수 있도록 시도하는 HTML 내장 스크립팅 언어입니다. # LoadModule php4_module modules/libphp4.so # # PHP 인터프리터가 .php 확장자를 가진 파일을 처리하도록 합니다. # #AddType application/x-httpd-php .php # AddType application/x-httpd-php-source .phps # # 디렉토리 인덱스로 제공될 파일 목록에 index.php를 추가합니다. # DirectoryIndex index.php |

그 후 Apache를 재시작합니다:

/etc/init.d/httpd restart
Share: X/Twitter LinkedIn

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

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