서버 설정 · 6 min read · Nov 03, 2025
완벽한 서버 - Debian 9 (Nginx, BIND, Dovecot, ISPConfig 3.1)
이 튜토리얼은 ISPConfig 3.1 설치를 위해 Nginx, BIND, Dovecot이 포함된 Debian 9 서버를 준비하는 방법과 ISPConfig 3.1을 설치하는 방법을 보여줍니다. ISPConfig 3는 웹 브라우저를 통해 다음 서비스를 구성할 수 있는 웹 호스팅 제어판입니다: Apache 또는 nginx 웹 서버, Postfix 메일 서버, Courier 또는 Dovecot IMAP/POP3 서버, MySQL, BIND 또는 MyDNS 네임서버, PureFTPd, SpamAssassin, ClamAV 등. 이 설정은 Nginx 웹 서버, DNS 서버로서의 BIND, IMAP / POP3 서버로서의 Dovecot을 포함합니다.
1 사전 참고
이 튜토리얼에서는 호스트 이름 server1.example.com과 IP 주소 192.168.1.100 및 게이트웨이 192.168.1.1을 사용합니다. 이러한 설정은 귀하의 경우 다를 수 있으므로 적절한 곳에서 교체해야 합니다. 진행하기 전에 Debian 9의 최소 설치가 필요합니다. 이는 호스팅 제공업체의 Debian 최소 이미지일 수 있으며, 기본 시스템을 설정하기 위해 Minimal Debian Server 튜토리얼을 사용할 수 있습니다.
2 SSH 서버 설치
시스템 설치 중 OpenSSH 서버를 설치하지 않았다면 지금 설치할 수 있습니다:
apt-get -y install ssh openssh-server이제부터는 PuTTY와 같은 SSH 클라이언트를 사용하여 작업대에서 Debian 9 서버에 연결하고 이 튜토리얼의 나머지 단계를 따를 수 있습니다.
3 셸 텍스트 편집기 설치 (선택 사항)
이 튜토리얼에서는 nano 텍스트 편집기를 사용할 것입니다. 일부 사용자는 고전적인 vi 편집기를 선호하므로 여기에서 두 편집기를 모두 설치할 것입니다. 기본 vi 프로그램은 Debian 및 Ubuntu에서 이상한 동작을 하므로 이를 수정하기 위해 vim-nox를 설치합니다:
apt-get -y install nano vim-nox(다른 텍스트 편집기(예: joe)를 사용하는 경우 이 작업을 수행할 필요는 없습니다.)
4 호스트 이름 구성
서버의 호스트 이름은 “server1.example.com”과 같은 서브도메인이어야 합니다. 호스트 이름으로 “example.com”과 같은 서브도메인 부분이 없는 도메인 이름을 사용하지 마십시오. 이는 나중에 메일 설정에 문제를 일으킬 수 있습니다. 먼저 /etc/hosts에서 호스트 이름을 확인하고 필요에 따라 변경해야 합니다. 줄은 다음과 같아야 합니다: “IP 주소 - 공백 - 전체 호스트 이름 포함 도메인 - 공백 - 서브도메인 부분”. /etc/hosts를 편집합니다. 다음과 같이 보이게 만듭니다:
nano /etc/hosts127.0.0.1 localhost.localdomain localhost
192.168.1.100 server1.example.com server1
# 다음 줄은 IPv6 지원 호스트에 바람직합니다
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters그런 다음 /etc/hostname 파일을 편집합니다:
nano /etc/hostname여기에는 서브도메인 부분만 포함되어야 하며, 우리의 경우:
server1마지막으로 변경 사항을 적용하기 위해 서버를 재부팅합니다:
reboot다시 로그인하고 다음 명령어로 호스트 이름이 올바른지 확인합니다:
hostname
hostname -f출력은 다음과 같아야 합니다:
root@server1:/tmp# hostname
server1
root@server1:/tmp# hostname -f
server1.example.com5 Debian 설치 업데이트
먼저 /etc/apt/sources.list에 stretch/updates 리포지토리가 포함되어 있는지 확인합니다(이는 ClamAV 바이러스 스캐너의 최신 업데이트를 항상 받을 수 있도록 합니다 - 이 프로젝트는 매우 자주 릴리스를 게시하며, 때때로 이전 버전이 작동을 멈춥니다), 그리고 contrib 및 non-free 리포지토리가 활성화되어 있는지 확인합니다.
nano /etc/apt/sources.listdeb http://ftp.us.debian.org/debian/ stretch main contrib non-free
deb-src http://ftp.us.debian.org/debian/ stretch main contrib non-free
deb http://security.debian.org/debian-security stretch/updates main contrib non-free
deb-src http://security.debian.org/debian-security stretch/updates main contrib non-free중요: 위와 같이 Debian Backports 리포지토리를 추가합니다.
다음 명령어를 실행하여
apt-get updateapt 패키지 데이터베이스를 업데이트하고
apt-get upgrade최신 업데이트를 설치합니다(있는 경우).
6 기본 셸 변경
/bin/sh는 /bin/dash에 대한 심볼릭 링크이지만, 우리는 /bin/bash가 필요합니다, /bin/dash가 아닙니다. 따라서 다음과 같이 합니다:
dpkg-reconfigure dash기본 시스템 셸로 dash를 사용합니까? <– 아니요
이 작업을 수행하지 않으면 ISPConfig 설치가 실패합니다.
7 시스템 시계 동기화
시스템 시계를 인터넷의 NTP (network time protocol) 서버와 동기화하는 것이 좋습니다. 다음 명령어를 실행하기만 하면 됩니다:
apt-get install ntp그러면 시스템 시간이 항상 동기화됩니다.
8 Postfix, Dovecot, MySQL, rkhunter 및 binutils 설치
Postfix, Dovecot, MySQL, rkhunter 및 Binutils를 단일 명령어로 설치할 수 있습니다:
apt-get install postfix postfix-mysql postfix-doc mariadb-client mariadb-server openssl getmail4 rkhunter binutils dovecot-imapd dovecot-pop3d dovecot-mysql dovecot-sieve dovecot-lmtpd sudo다음 질문을 받게 됩니다:
일반 메일 구성 유형: <– 인터넷 사이트
시스템 메일 이름: <– server1.example.com
MariaDB / MySQL 설치를 보안하고 테스트 데이터베이스를 비활성화하려면 다음 명령어를 실행합니다:
mysql_secure_installation설치 중에 새 비밀번호를 설정했으므로 MySQL 루트 비밀번호를 변경할 필요는 없습니다. 질문에 다음과 같이 답변합니다:
루트 비밀번호를 변경하시겠습니까? [Y/n] <-- y
새 비밀번호: <-- 새 MySQL 루트 비밀번호 입력
새 비밀번호를 다시 입력하세요: <-- MySQL 루트 비밀번호 반복
익명 사용자 제거? [Y/n] <-- y
원격에서 루트 로그인 금지? [Y/n] <-- y
테스트 데이터베이스 및 이에 대한 접근 제거? [Y/n] <-- y
권한 테이블을 지금 다시 로드하시겠습니까? [Y/n] <-- y다음으로 Postfix에서 TLS/SSL 및 제출 포트를 엽니다:
nano /etc/postfix/master.cf제출 및 smtps 섹션의 주석을 제거합니다(우리는 필요하지 않으므로 -o milter_macro_daemon_name=ORIGINATING은 그대로 두십시오):
[...]
submission inet n - y - - smtpd
-o syslog_name=postfix/submission
-o smtpd_tls_security_level=encrypt
-o smtpd_sasl_auth_enable=yes
-o smtpd_client_restrictions=permit_sasl_authenticated,reject
# -o smtpd_reject_unlisted_recipient=no
# -o smtpd_client_restrictions=$mua_client_restrictions
# -o smtpd_helo_restrictions=$mua_helo_restrictions
# -o smtpd_sender_restrictions=$mua_sender_restrictions
# -o smtpd_recipient_restrictions=
# -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
# -o milter_macro_daemon_name=ORIGINATING
smtps inet n - y - - smtpd
-o syslog_name=postfix/smtps
-o smtpd_tls_wrappermode=yes
-o smtpd_sasl_auth_enable=yes
-o smtpd_client_restrictions=permit_sasl_authenticated,reject
# -o smtpd_reject_unlisted_recipient=no
# -o smtpd_client_restrictions=$mua_client_restrictions
# -o smtpd_helo_restrictions=$mua_helo_restrictions
# -o smtpd_sender_restrictions=$mua_sender_restrictions
# -o smtpd_recipient_restrictions=
# -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
# -o milter_macro_daemon_name=ORIGINATING
[...]그런 다음 Postfix를 재시작합니다:
service postfix restartMariaDB가 localhost뿐만 아니라 모든 인터페이스에서 수신 대기하도록 하려면 /etc/mysql/mariadb.conf.d/50-server.cnf 파일을 편집하고 bind-address = 127.0.0.1 줄의 주석을 제거하고 sql-mode=”NO_ENGINE_SUBSTITUTION” 줄을 추가합니다:
nano /etc/mysql/mariadb.conf.d/50-server.cnf[...]
# skip-networking 대신 기본값은 이제
# localhost에서만 수신 대기하는 것이며
# 더 호환성이 높고 덜 안전하지 않습니다.
#bind-address = 127.0.0.1
sql-mode="NO_ENGINE_SUBSTITUTION"
[...]MariaDB의 비밀번호 인증 방법을 네이티브로 설정하여 나중에 PHPMyAdmin을 사용하여 루트 사용자로 연결할 수 있도록 합니다:
echo "update mysql.user set plugin = 'mysql_native_password' where user='root';" | mysql -u root/etc/mysql/debian.cnf 파일을 편집하고 비밀번호가 시작되는 두 줄에 MYSQL / MariaDB 루트 비밀번호를 설정합니다.
nano /etc/mysql/debian.cnf추가해야 할 MySQL 루트 비밀번호는 빨간색으로 표시되어 있으며, 이 예제에서는 비밀번호가 “howtoforge”입니다.
# Debian 스크립트용으로 자동 생성되었습니다. 수정하지 마십시오!
[client]
host = localhost
user = root
password = howtoforge
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user = root
password = howtoforge
socket = /var/run/mysqld/mysqld.sock
basedir = /usr‘ Error in accept: Too many open files ‘ 오류를 방지하기 위해 이제 MariaDB에 대해 더 높은 열린 파일 제한을 설정합니다.
편집기로 /etc/security/limits.conf 파일을 엽니다:
nano /etc/security/limits.conf그리고 파일 끝에 다음 줄을 추가합니다.
mysql soft nofile 65535
mysql hard nofile 65535다음으로 mkdir 명령어로 새 디렉토리 /etc/systemd/system/mysql.service.d/를 생성합니다.
mkdir -p /etc/systemd/system/mysql.service.d/그리고 그 안에 새 파일을 추가합니다:
nano /etc/systemd/system/mysql.service.d/limits.conf다음 줄을 해당 파일에 붙여넣습니다:
[Service]
LimitNOFILE=infinity파일을 저장하고 nano 편집기를 닫습니다.
그런 다음 systemd를 다시 로드하고 MariaDB를 재시작합니다:
systemctl daemon-reload
service mysql restart이제 네트워킹이 활성화되었는지 확인합니다. 다음 명령어를 실행합니다:
netstat -tap | grep mysql출력은 다음과 같아야 합니다:
root@server1:~# netstat -tap | grep mysql
tcp6 0 0 [::]:mysql [::]:* LISTEN 4027/mysqld
root@server1:~#9 Amavisd-new, SpamAssassin 및 ClamAV 설치
amavisd-new, SpamAssassin 및 ClamAV를 설치하려면 다음을 실행합니다:
apt-get install amavisd-new spamassassin clamav clamav-daemon zoo unzip bzip2 arj nomarch lzop cabextract apt-listchanges libnet-ldap-perl libauthen-sasl-perl clamav-docs daemon libio-string-perl libio-socket-ssl-perl libnet-ident-perl zip libnet-dns-perl libdbd-mysql-perl postgreyISPConfig 3 설정은 내부적으로 SpamAssassin 필터 라이브러리를 로드하는 amavisd를 사용하므로 RAM을 확보하기 위해 SpamAssassin을 중지할 수 있습니다:
service spamassassin stop
systemctl disable spamassassin9.1 Metronome XMPP 서버 설치 (선택 사항)
이 단계에서는 XMPP 프로토콜과 호환되는 채팅 서버를 제공하는 Metronome XMPP 서버를 설치합니다. 이 단계는 선택 사항이며, 채팅 서버가 필요하지 않다면 이 단계를 건너뛸 수 있습니다. 다른 ISPConfig 기능은 이 소프트웨어에 의존하지 않습니다.
Debian에 Prosody 패키지 리포지토리를 추가합니다.
echo "deb http://packages.prosody.im/debian stretch main" > /etc/apt/sources.list.d/metronome.list
wget http://prosody.im/files/prosody-debian-packages.key -O - | sudo apt-key add -패키지 목록을 업데이트합니다:
apt-get update빌드 프로세스에 필요한 프로그램을 설치합니다:
apt-get install build-essential그리고 apt로 패키지를 설치합니다.
apt-get install git lua5.1 liblua5.1-0-dev lua-filesystem libidn11-dev libssl-dev lua-zlib lua-expat lua-event lua-bitop lua-socket lua-sec luarocks luarocksluarocks install lpcMetronome에 대한 셸 사용자를 추가합니다.
adduser --no-create-home --disabled-login --gecos 'Metronome' metronome/opt 디렉토리에 Metronome을 다운로드하고 컴파일합니다.
cd /opt; git clone https://github.com/maranda/metronome.git metronome
cd ./metronome; ./configure --ostype=debian --prefix=/usr
make
make install이제 Metronome이 /opt/metronome에 설치되었습니다.
새 게시물을 받은 편지함에서 받기
스팸은 없습니다. 언제든지 구독 해지 가능합니다.