웹사이트 검색

완벽한 서버 - Debian 8.6(nginx, BIND, Dovecot, ISPConfig 3.1)


이 튜토리얼은 ISPConfig 3.1 설치를 위해 Debian Jessie 서버(nginx, BIND, Dovecot 포함)를 준비하는 방법과 ISPConfig 3.1을 설치하는 방법을 보여줍니다. ISPConfig 3은 웹 브라우저를 통해 다음 서비스를 구성할 수 있는 웹 호스팅 제어판입니다. Apache 또는 nginx 웹 서버, Postfix 메일 서버, Courier 또는 Dovecot IMAP/POP3 서버, MySQL, BIND 또는 MyDNS 네임서버, PureFTPd, SpamAssassin, ClamAV 등이 있습니다. 이 설정은 nginx(Apache 대신), BIND를 DNS 서버로, Dovecot을 IMAP/POP3 서버로 포함합니다.

1 서문

이 자습서에서는 IP 주소가 192.168.1.100이고 게이트웨이가 192.168.1.1인 호스트 이름 server1.example.com을 사용합니다. 이러한 설정은 사용자에 따라 다를 수 있으므로 적절하게 교체해야 합니다. 더 진행하기 전에 Debian 8의 최소 설치가 필요합니다. 이것은 호스팅 제공업체의 Debian 최소 이미지이거나 최소 Debian 서버 자습서를 사용하여 기본 시스템을 설정할 수 있습니다.

2 SSH 서버 설치

시스템 설치 중에 OpenSSH 서버를 설치하지 않은 경우 지금 수행할 수 있습니다.

apt-get -y install ssh openssh-server

이제부터 PuTTY와 같은 SSH 클라이언트를 사용하고 워크스테이션에서 Debian 8 서버에 연결하고 이 가이드의 나머지 단계를 따를 수 있습니다.

3 쉘 텍스트 편집기 설치(선택 사항)

이 가이드에서는 nano 텍스트 편집기를 사용하겠습니다. 일부 사용자는 클래식 vi 편집기를 선호하므로 여기에 두 편집기를 모두 설치하겠습니다. 기본 vi 프로그램은 데비안과 우분투에서 이상한 동작을 합니다. 이 문제를 해결하기 위해 vim-nox를 설치합니다.

apt-get -y install nano vim-nox

(joe와 같은 다른 텍스트 편집기를 사용하는 경우에는 이 작업을 수행할 필요가 없습니다.)

4 호스트 이름 구성

서버의 호스트 이름은 \server1.example.com\과 같은 하위 도메인이어야 합니다. \example.com\과 같은 하위 도메인 부분이 없는 도메인 이름을 호스트 이름으로 사용하지 마십시오. 나중에 메일 설정에 문제가 발생할 수 있습니다. 먼저 /etc/hosts에서 호스트 이름을 확인하고 필요한 경우 변경해야 합니다. 줄은 \IP 주소 - 공백 - 도메인을 포함한 전체 호스트 이름 - 공백 - 하위 도메인 부분\이어야 합니다. /etc/hosts를 편집합니다. 다음과 같이 만드십시오.

nano /etc/hosts
127.0.0.1       localhost.localdomain   localhost
192.168.1.100   server1.example.com     server1

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

그런 다음 /etc/hostname 파일을 편집합니다.

nano /etc/hostname

우리의 경우에는 하위 도메인 부분만 포함해야 합니다.

server1

마지막으로 서버를 재부팅하여 변경사항을 적용합니다.

reboot

다시 로그인하고 다음 명령을 사용하여 호스트 이름이 올바른지 확인하십시오.

hostname
hostname -f

출력은 다음과 같아야 합니다.

:/tmp# hostname -f
server1.example.com

5 데비안 설치 업데이트

먼저 /etc/apt/sources.list에 wheezy-updates 리포지토리가 포함되어 있는지 확인합니다(이렇게 하면 항상 ClamAV 바이러스 스캐너에 대한 최신 업데이트를 받을 수 있습니다. 이 프로젝트는 릴리스를 매우 자주 게시하며 때로는 이전 버전이 작동을 멈춥니다). 그리고 contrib 및 non-free 리포지토리가 활성화되어 있는지 확인합니다(libapache2-mod-fastcgi와 같은 일부 패키지는 기본 리포지토리에 없음).

nano /etc/apt/sources.list
deb http://ftp.us.debian.org/debian/ jessie main contrib non-free
deb-src http://ftp.us.debian.org/debian/ jessie main contrib non-free

deb http://security.debian.org/ jessie/updates main contrib non-free
deb-src http://security.debian.org/ jessie/updates main contrib non-free

# Debian backports - Required for Letsencrypt
deb http://ftp.debian.org/debian jessie-backports main

중요: 위와 같이 Debian Backports 저장소를 추가합니다.

달리다

apt-get update

apt 패키지 데이터베이스를 업데이트하고

apt-get upgrade

최신 업데이트를 설치합니다(있는 경우).

6 기본 쉘 변경

/bin/sh는 /bin/dash에 대한 심볼릭 링크이지만 /bin/dash가 아닌 /bin/bash가 필요합니다. 그러므로 우리는 이렇게 합니다:

dpkg-reconfigure dash

대시를 기본 시스템 셸(/bin/sh)로 사용하시겠습니까? <-- 아니요

이렇게 하지 않으면 ISPConfig 설치가 실패합니다.

7 시스템 시계 동기화

인터넷을 통해 시스템 시계를 NTP(nnetwork ttime 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 \root\ 사용자의 새 비밀번호: <-- yourrootsqlpassword
비밀번호 반복 MariaDB \root\ 사용자의 경우: <-- yourrootsqlpassword

MariaDB/MySQL 설치를 보호하고 테스트 데이터베이스를 비활성화하려면 다음 명령을 실행하십시오.

mysql_secure_installation

설치 중에 새 암호를 설정했기 때문에 MySQL 루트 암호를 변경할 필요가 없습니다. 다음과 같이 질문에 답하십시오.

Change the root password? [Y/n] <-- n
Remove anonymous users? [Y/n] <-- y
Disallow root login remotely? [Y/n] <-- y
Remove test database and access to it? [Y/n] <-- y
Reload privilege tables now? [Y/n] <-- y

다음으로 Postfix에서 TLS/SSL 및 제출 포트를 엽니다.

nano /etc/postfix/master.cf

다음과 같이 submit 및 smtps 섹션의 주석을 제거합니다(필요하지 않으므로 -o milter_macro_daemon_name=ORIGINATING을 그대로 둡니다).

[...]
submission inet n - - - - 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 - - - - 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 restart

우리는 MySQL이 localhost뿐만 아니라 모든 인터페이스에서 수신 대기하기를 원하므로 /etc/mysql/my.cnf를 편집하고 bind-address=127.0.0.1 행을 주석 처리합니다.

nano /etc/mysql/my.cnf
[...]
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address           = 127.0.0.1
[...]

그런 다음 MySQL을 다시 시작합니다.

service mysql restart

이제 네트워킹이 활성화되었는지 확인하십시오. 달리다

netstat -tap | grep mysql

출력은 다음과 같아야 합니다.

:~#

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 postgrey

ISPConfig 3 설정은 SpamAssassin 필터 라이브러리를 내부적으로 로드하는 amavisd를 사용하므로 SpamAssassin을 중지하여 일부 RAM을 확보할 수 있습니다.

service spamassassin stop
systemctl disable spamassassin

9.1 Metronome XMPP 서버 설치(선택 사항)

이 단계에서는 XMPP 프로토콜과 호환되는 채팅 서버를 제공하는 Metronome XMPP 서버를 설치합니다. 이 단계는 선택 사항이며 채팅 서버가 필요하지 않은 경우 이 단계를 건너뛸 수 있습니다. 다른 ISPConfig 기능은 이 소프트웨어에 의존하지 않습니다.

Debian에서 Prosody 패키지 저장소를 추가합니다.

echo "deb http://packages.prosody.im/debian jessie 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 luarocks
luarocks install lpc

Metronome에 대한 쉘 사용자를 추가하십시오.

adduser --no-create-home --disabled-login --gecos 'Metronome' metronome

Metronome을 /opt 디렉토리에 다운로드하고 컴파일합니다.

cd /opt; git clone https://github.com/maranda/metronome.git metronome
cd ./metronome; ./configure --ostype=debian --prefix=/usr
make
make install

Metronome이 이제 /opt/metronome에 설치되었습니다.