서버 설정 · 5 min read · Dec 12, 2025
완벽한 서버 - 페도라 14 x86_64 [ISPConfig 2] - 페이지 4
9 MySQL 5
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 1765/mysqld
[root@server1 ~]#
만약 그렇지 않다면, /etc/my.cnf를 편집하고 skip-networking 옵션을 주석 처리합니다:
vi /etc/my.cnf| [...] #skip-networking [...] |
그런 다음 MySQL 서버를 재시작합니다:
/etc/init.d/mysqld restart 다음 명령어를 실행하여
mysql_secure_installation root 사용자에 대한 비밀번호를 설정합니다 (그렇지 않으면 누구나 MySQL 데이터베이스에 접근할 수 있습니다!).
[root@server1 ~]# mysql_secure_installation
NOTE: 이 스크립트의 모든 부분을 실행하는 것이 모든 MySQL
서버에서 권장됩니다! 각 단계를 주의 깊게 읽어주세요!
MySQL에 로그인하여 보안을 설정하려면, root 사용자에 대한 현재 비밀번호가 필요합니다. MySQL을 방금 설치했으며, root 비밀번호를 아직 설정하지 않았다면 비밀번호는 비어 있으므로 여기서 그냥 Enter를 누르세요.
현재 root 비밀번호를 입력하세요 (없으면 Enter): <– 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’라는 데이터베이스가 있습니다. 이는 테스트 용도로만 사용되며 프로덕션 환경으로 이동하기 전에 제거해야 합니다.
test 데이터베이스 및 접근을 제거하시겠습니까? [Y/n] <– ENTER
- test 데이터베이스 삭제 중…
… 성공! - test 데이터베이스에 대한 권한 제거 중…
… 성공!
권한 테이블을 다시 로드하면 지금까지 변경된 모든 사항이 즉시 적용됩니다.
권한 테이블을 지금 다시 로드하시겠습니까? [Y/n] <– ENTER
… 성공!
정리 중…
모든 작업이 완료되었습니다! 위의 모든 단계를 완료했다면, MySQL 설치가 이제 안전해야 합니다.
MySQL을 사용해 주셔서 감사합니다!
[root@server1 ~]#
10 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 [::1]/128’
/usr/lib64/sasl2/smtpd.conf를 편집하여 Postfix가 PLAIN 및 LOGIN 로그인을 허용하도록 해야 합니다 (32비트 시스템에서는 이 파일이 /usr/lib/sasl2/smtpd.conf에 있습니다). 다음과 같이 되어야 합니다:
vi /usr/lib64/sasl2/smtpd.conf| pwcheck_method: saslauthd mech_list: plain login |
그런 다음 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.crtopenssl rsa -in smtpd.key -out smtpd.key.unencryptedmv -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.7.1/samples readme_directory = /usr/share/doc/postfix-2.7.1/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 [::1]/128 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 |
이제 Postfix와 saslauthd를 시작합니다:
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
Dovecot을 시작하기 전에 평문 인증을 활성화해야 합니다. /etc/dovecot/conf.d/10-auth.conf를 열고…
vi /etc/dovecot/conf.d/10-auth.conf… disable_plaintext_auth = no라는 줄을 추가합니다:
| [...] # SSL/TLS가 사용되지 않는 한 LOGIN 명령 및 모든 다른 평문 인증을 비활성화합니다 (LOGINDISABLED 기능). 원격 IP가 로컬 IP와 일치하는 경우 (즉, 동일한 컴퓨터에서 연결하는 경우) 연결은 안전한 것으로 간주되며 평문 인증이 허용됩니다. #disable_plaintext_auth = yes disable_plaintext_auth = no [...] |
그런 다음 Dovecot을 시작합니다:
/etc/init.d/dovecot startSMTP-AUTH 및 TLS가 제대로 작동하는지 확인하려면 다음 명령어를 실행합니다:
telnet localhost 25 Postfix 메일 서버에 연결한 후 다음을 입력합니다:
ehlo localhost 다음과 같은 줄이 보이면
250-STARTTLS 및
250-AUTH LOGIN PLAIN모든 것이 정상입니다.
[root@server1 ssl]# telnet localhost 25
Trying 127.0.0.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 LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
quit
221 2.0.0 Bye
Connection closed by foreign host.
[root@server1 ssl]#
quit 를 입력하여 시스템 셸로 돌아갑니다.
10.1 Maildir
Dovecot은 Maildir 형식을 사용하므로 (mbox 아님), 서버에 ISPConfig를 설치하는 경우 관리 -> 서버 -> 설정 -> 이메일에서 Maildir을 활성화해야 합니다. ISPConfig가 필요한 구성을 수행합니다.
ISPConfig를 설치하고 싶지 않은 경우, Postfix를 사용자의 Maildir로 이메일을 배달하도록 구성해야 합니다 (ISPConfig를 사용하는 경우에도 이 작업을 수행할 수 있습니다 - 해롭지 않습니다 ;-)):
postconf -e ‘home_mailbox = Maildir/‘
postconf -e ‘mailbox_command =’
/etc/init.d/postfix restart
새 게시물을 받은 편지함에서 받기
스팸은 없습니다. 언제든지 구독 해지 가능합니다.