서버 설정 · 4 min read · Dec 16, 2025

완벽한 서버 - OpenSUSE 11.4 x86_64 [ISPConfig 2] - 페이지 4

8 MySQL

MySQL을 설치하기 위해 다음을 실행합니다:

yast2 -i mysql mysql-community-server mysql-client perl-DBD-mysql perl-DBI perl-Data-ShowTable libmysqlclient-devel libmysqlclient16 libmysqlclient16-32bit libmysqlclient_r16-32bit

그런 다음 MySQL의 시스템 시작 링크를 추가하고 시작합니다:

chkconfig -f –add mysql
/etc/init.d/mysql start

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

netstat -tap | grep mysql

출력에서 다음과 같은 내용을 확인할 수 있어야 합니다:

server1:~ # netstat -tap | grep mysql
tcp 0 0 :mysql :* LISTEN 5059/mysqld
server1:~ #

이와 같은 줄이 보이지 않으면 /etc/my.cnf를 편집하고 skip-networking 옵션을 주석 처리합니다:

vi /etc/my.cnf

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

그리고 MySQL 서버를 재시작합니다:

/etc/init.d/mysql restart

MySQL 설치를 보안하기 위해 다음을 실행합니다:

mysql_secure_installation

이제 여러 가지 질문을 받게 됩니다:

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을 사용해 주셔서 감사합니다!

server1:~ #

이제 MySQL 설정이 보안되었습니다.

이제 다음을 수행해야 합니다…

mkdir -p /usr/local/lib/mysql
ln -s /usr/include/mysql /usr/local/lib/mysql/include
ln -s /usr/lib64/mysql /usr/local/lib/mysql/lib
cd /usr/local/lib/mysql/lib
ln -s /usr/lib64/libmysqlclient.so.16.0.0 libmysqlclient.so
ln -s /usr/lib64/libmysqlclient.so.16.0.0 libmysqlclient.so.16
ln -s /usr/lib64/libmysqlclient.so.16.0.0 libmysqlclient.so.16.0.0
ln -s /usr/lib64/libmysqlclient_r.so.16.0.0 libmysqlclient_r.so
ln -s /usr/lib64/libmysqlclient_r.so.16.0.0 libmysqlclient_r.so.16
ln -s /usr/lib64/libmysqlclient_r.so.16.0.0 libmysqlclient_r.so.16.0.0

… 그렇지 않으면 ISPConfig 설치 중 다음과 같은 오류가 발생합니다:

configure: error: Cannot find libmysqlclient under /usr/local/lib/mysql. 

9 Postfix와 SMTP-AUTH 및 TLS

이제 Postfix와 Cyrus-SASL을 설치합시다:

yast2 -i postfix cyrus-sasl cyrus-sasl-crammd5 cyrus-sasl-digestmd5 cyrus-sasl-gssapi cyrus-sasl-otp cyrus-sasl-plain cyrus-sasl-saslauthd procmail

그런 다음 Postfix와 saslauthd의 시스템 시작 링크를 추가하고 시작합니다:

chkconfig -f –add postfix
/etc/init.d/postfix start

chkconfig -f –add saslauthd
/etc/init.d/saslauthd start

그 후 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를 SMTP-AUTH 및 TLS에 맞게 구성합니다:

postconf -e ‘mydomain = example.com’
postconf -e ‘myhostname = server1.$mydomain’
postconf -e ‘mynetworks = 127.0.0.0/8’
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,check_relay_domains’
postconf -e ‘inet_interfaces = all’
postconf -e ‘alias_maps = hash:/etc/aliases’
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에서 TLS 연결을 활성화하려면 /etc/postfix/master.cf를 편집하고 tlsmgr 줄의 주석을 제거하여 다음과 같이 만듭니다:

vi /etc/postfix/master.cf

| [...] tlsmgr unix - - n 1000? 1 tlsmgr [...] |

이제 Postfix를 재시작합니다:

/etc/init.d/postfix restart

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

telnet localhost 25

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

ehlo localhost

다음과 같은 줄이 보이면

250-STARTTLS

250-AUTH PLAIN LOGIN 

모든 것이 정상입니다.

내 시스템에서 출력은 다음과 같습니다:

server1:/etc/postfix/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
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.
server1:/etc/postfix/ssl #

quit

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

10 Courier-IMAP/Courier-POP3

Maildir 지원이 있는 POP3/IMAP 데몬을 사용하고 싶습니다. 그래서 Courier-IMAP과 Courier-POP3를 사용합니다.

yast2 -i courier-imap fam-server courier-authlib expect tcl

그런 다음 시스템 시작 링크를 추가하고 POP3, IMAP, POP3s 및 IMAPs를 시작합니다:

chkconfig -f –add fam
chkconfig -f –add courier-authdaemon
chkconfig -f –add courier-pop
chkconfig -f –add courier-imap
/etc/init.d/courier-pop start
/etc/init.d/courier-imap start
chkconfig -f –add courier-pop-ssl
chkconfig -f –add courier-imap-ssl
/etc/init.d/courier-pop-ssl start
/etc/init.d/courier-imap-ssl start

ISPConfig를 사용하고 싶지 않다면 Postfix를 사용자의 Maildir로 이메일을 배달하도록 구성합니다:

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

*참고: ISPConfig를 시스템에서 사용할 계획이라면 이 작업을 수행할 필요는 없습니다(하지만 해도 나쁘지 않습니다 ;-)). ISPConfig는 procmail 레시피를 사용하여 필요한 구성을 수행합니다. 그러나 ISPConfig 웹 인터페이스의 관리 -> 서버 -> 설정 -> 이메일에서 Maildir을 활성화하는 것을 잊지 마십시오.

Share: X/Twitter LinkedIn

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

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