서버 설정 · 5 min read · Jan 20, 2026

완벽한 서버 - CentOS 6.0 x86_64 [ISPConfig 2] - 페이지 4

10 MySQL (5.1)

MySQL을 설치하려면, 다음과 같이 합니다:

yum install mysql mysql-devel mysql-server

그런 다음 MySQL의 시스템 시작 링크를 생성하여 (시스템이 부팅될 때마다 MySQL이 자동으로 시작되도록) MySQL 서버를 시작합니다:

chkconfig –levels 235 mysqld on
/etc/init.d/mysqld start

이제 네트워킹이 활성화되었는지 확인합니다. 다음을 실행합니다:

netstat -tap | grep mysql

다음과 같은 줄이 표시되어야 합니다:

[root@server1 ~]# netstat -tap | grep mysql
tcp 0 0 :mysql :* LISTEN 2044/mysqld
[root@server1 ~]#

표시되지 않으면 /etc/my.cnf를 편집하고 skip-networking 옵션을 주석 처리합니다:

vi /etc/my.cnf

| [...] #skip-networking [...] |

그런 다음 MySQL 서버를 재시작합니다:

/etc/init.d/mysqld restart 

MySQL root 계정의 비밀번호를 설정합니다:

mysql_secure_installation

[root@server1 ~]# mysql_secure_installation

NOTE: 이 스크립트의 모든 부분을 실행하는 것이 모든 MySQL
서버에서 권장됩니다! 각 단계를 주의 깊게 읽어주세요!

MySQL에 로그인하여 보안을 설정하려면, 현재 root 사용자에 대한 비밀번호가 필요합니다. MySQL을 방금 설치했으며, root 비밀번호를 아직 설정하지 않았다면 비밀번호는 비어 있으므로 여기서 그냥 Enter를 누르세요.

현재 root 비밀번호 입력 (없으면 Enter):
OK, 비밀번호가 성공적으로 사용되었습니다. 계속 진행합니다…

root 비밀번호를 설정하면 아무도 적절한 권한 없이 MySQL root 사용자로 로그인할 수 없게 됩니다.

root 비밀번호를 설정하시겠습니까? [Y/n] <– ENTER
새 비밀번호: <– yourrootsqlpassword
새 비밀번호를 다시 입력하세요: <– yourrootsqlpassword
비밀번호가 성공적으로 업데이트되었습니다!
권한 테이블을 다시 로드하는 중..
… 성공!

기본적으로 MySQL 설치에는 익명 사용자가 있어 누구나 사용자 계정을 생성하지 않고도 MySQL에 로그인할 수 있습니다. 이는 테스트 용도로만 의도되었으며 설치를 조금 더 원활하게 하기 위한 것입니다. 프로덕션 환경으로 이동하기 전에 이를 제거해야 합니다.

익명 사용자를 제거하시겠습니까? [Y/n] <– ENTER
… 성공!

일반적으로 root는 ‘localhost’에서만 연결할 수 있어야 합니다. 이는 누군가가 네트워크에서 root 비밀번호를 추측할 수 없도록 보장합니다.

원격으로 root 로그인을 허용하지 않으시겠습니까? [Y/n] <– ENTER
… 성공!

기본적으로 MySQL에는 누구나 접근할 수 있는 ‘test’라는 데이터베이스가 있습니다. 이는 테스트 용도로만 의도되었으며 프로덕션 환경으로 이동하기 전에 제거해야 합니다.

테스트 데이터베이스 및 그 접근을 제거하시겠습니까? [Y/n] <– ENTER

  • 테스트 데이터베이스 삭제 중… … 성공!
  • 테스트 데이터베이스에 대한 권한 제거 중… … 성공!

권한 테이블을 다시 로드하면 지금까지 변경된 모든 사항이 즉시 적용됩니다.

지금 권한 테이블을 다시 로드하시겠습니까? [Y/n] <– ENTER
… 성공!

정리 중…

모든 작업이 완료되었습니다! 위의 모든 단계를 완료했다면, MySQL 설치가 이제 안전해야 합니다.

MySQL을 사용해 주셔서 감사합니다!

[root@server1 ~]#

11 Postfix와 SMTP-AUTH 및 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_sasl_authenticated_header = 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’

그런 다음 TLS용 인증서를 생성합니다:

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

다음으로 Postfix를 TLS에 대해 구성합니다:

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’

그런 다음 Postfix 설치에서 호스트 이름을 설정합니다 (server1.example.com을 자신의 호스트 이름으로 바꾸는 것을 잊지 마세요):

postconf -e 'myhostname = server1.example.com'

이러한 구성 단계를 완료한 후 /etc/postfix/main.cf는 다음과 같아야 합니다 (모든 주석을 제거했습니다):

cat /etc/postfix/main.cf

| queue_directory = /var/spool/postfix command_directory = /usr/sbin daemon_directory = /usr/libexec/postfix data_directory = /var/lib/postfix mail_owner = postfix inet_interfaces = all inet_protocols = 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 ddd $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.6.6/samples readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES smtpd_sasl_local_domain = smtpd_sasl_auth_enable = yes smtpd_sasl_security_options = noanonymous broken_sasl_auth_clients = yes smtpd_sasl_authenticated_header = 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 myhostname = server1.example.com |

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

vi /etc/dovecot/dovecot.conf

| [...] # 우리가 제공하고자 하는 프로토콜. protocols = imap pop3 [...] |

다음으로 평문 인증을 활성화해야 합니다:

vi /etc/dovecot/conf.d/10-auth.conf

| [...] # SSL/TLS가 사용되지 않는 한 LOGIN 명령 및 모든 다른 평문 인증을 비활성화합니다 (LOGINDISABLED 기능). 원격 IP가 로컬 IP와 일치하는 경우 (즉, 같은 컴퓨터에서 연결하는 경우) 연결이 안전하다고 간주되며 평문 인증이 허용됩니다. disable_plaintext_auth = no [...] |

이제 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 PLAIN LOGIN 

모든 것이 정상입니다.

[root@server1 ssl]# telnet localhost 25
Trying ::1…
Connected to localhost.
Escape character is ‘^]’.
220 server1.example.com ESMTP Postfix
<– ehlo localhost
250-server1.example.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
<– quit
221 2.0.0 Bye
Connection closed by foreign host.
[root@server1 ssl]#

quit 

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

11.1 Maildir

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

ISPConfig를 설치하고 싶지 않다면, Postfix를 구성하여 사용자의 Maildir로 이메일을 배달해야 합니다 (ISPConfig를 사용하는 경우에도 이렇게 할 수 있습니다 - 해가 되지 않습니다 ;-)):

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

Share: X/Twitter LinkedIn

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

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