웹사이트 검색

완벽한 서버 - Apache, PHP, MySQL, PureFTPD, BIND, Postfix, Dovecot 및 ISPConfig 3.1이 포함된 Ubuntu 17.04(Zesty Zapus)


이 튜토리얼은 다음 OS 버전에 대해 존재합니다.

  • 우분투 16.04(Xenial Xerus)

이 페이지에서

  1. 1. 서문
  2. 2. /etc/apt/sources.list 편집 및 Linux 설치 업데이트
  3. 3. 기본 셸 변경
  4. 4. AppArmor 비활성화\n
  5. 5. 시스템 시계 동기화\n
  6. 6. Postfix, Dovecot, MariaDB, rkhunter 및 binutils 설치
  7. 7. Amavisd-new, SpamAssassin 및 Clamav 설치
  8. 7.1 Metronome XMPP 서버 설치(선택 사항)\n

이 가이드에서는 ISPConfig 3.1 설치를 준비하기 위해 Apache2, Postfix, Dovecot, Bind 및 PureFTPD와 함께 Ubuntu 17.04(Zesty Zapus) 웹 호스팅 서버를 설치하는 방법을 보여줍니다. 결과 시스템은 웹, 메일, 메일링리스트, DNS 및 FTP 서버를 제공합니다.

ISPConfig 3은 웹 브라우저를 통해 다음 서비스를 구성할 수 있는 웹 호스팅 제어판입니다. Apache 또는 nginx 웹 서버, Postfix 메일 서버, Courier 또는 Dovecot IMAP/POP3 서버, MySQL, BIND 또는 MyDNS 네임서버, PureFTPd, SpamAssassin, ClamAV 등이 있습니다. 이 설정은 Apache(Nginx 대신), BIND(MyDNS 대신) 및 Dovecot(Courier 대신)의 설치를 다룹니다.

이 튜토리얼은 비 LTS(Long Term Support) 버전인 Ubuntu 17.04에 관한 것입니다. 대부분의 사용자는 훨씬 더 오랜 시간 동안 업데이트 및 보안 패치를 받는 서버로 LTS 버전을 선호합니다. 최신 LTS 릴리스는 Ubuntu 16.04이며 이 자습서는 Ubuntu 16.04 버전에도 있습니다. 최신 패키지가 필요한 경우(짧은 지원 기간에 문제가 없는 경우) 신중하게 고려한 다음 이 자습서를 계속 진행하십시오. 오랜 지원이 필요한 경우 대신 Ubuntu 16.04 Perfect Server Tutorial을 사용하세요.

1. 서문

이 자습서에서는 IP 주소가 192.168.1.100이고 게이트웨이가 192.168.1.1인 호스트 이름 server1.example.com을 사용합니다. 이러한 설정은 사용자에 따라 다를 수 있으므로 적절하게 교체해야 합니다. 계속 진행하기 전에 자습서에 설명된 대로 Ubuntu 17.04의 기본 최소 설치가 필요합니다.

2. /etc/apt/sources.list 편집 및 Linux 설치 업데이트

/etc/apt/sources.list를 편집합니다. 파일에서 설치 CD를 주석 처리하거나 제거하고 유니버스 및 다중 우주 리포지토리가 활성화되어 있는지 확인하십시오. 나중에 다음과 같이 표시됩니다.

nano /etc/apt/sources.list
#

# deb cdrom:[Ubuntu-Server 17.04 _Zesty Zapus_ - Release amd64 (20170412)]/ zesty main restricted

#deb cdrom:[Ubuntu-Server 17.04 _Zesty Zapus_ - Release amd64 (20170412)]/ zesty main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://de.archive.ubuntu.com/ubuntu/ zesty main restricted
# deb-src http://de.archive.ubuntu.com/ubuntu/ zesty main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://de.archive.ubuntu.com/ubuntu/ zesty-updates main restricted
# deb-src http://de.archive.ubuntu.com/ubuntu/ zesty-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://de.archive.ubuntu.com/ubuntu/ zesty universe
# deb-src http://de.archive.ubuntu.com/ubuntu/ zesty universe
deb http://de.archive.ubuntu.com/ubuntu/ zesty-updates universe
# deb-src http://de.archive.ubuntu.com/ubuntu/ zesty-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://de.archive.ubuntu.com/ubuntu/ zesty multiverse
# deb-src http://de.archive.ubuntu.com/ubuntu/ zesty multiverse
deb http://de.archive.ubuntu.com/ubuntu/ zesty-updates multiverse
# deb-src http://de.archive.ubuntu.com/ubuntu/ zesty-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://de.archive.ubuntu.com/ubuntu/ zesty-backports main restricted universe multiverse
# deb-src http://de.archive.ubuntu.com/ubuntu/ zesty-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu zesty partner
# deb-src http://archive.canonical.com/ubuntu zesty partner

deb http://security.ubuntu.com/ubuntu zesty-security main restricted
# deb-src http://security.ubuntu.com/ubuntu zesty-security main restricted
deb http://security.ubuntu.com/ubuntu zesty-security universe
# deb-src http://security.ubuntu.com/ubuntu zesty-security universe
deb http://security.ubuntu.com/ubuntu zesty-security multiverse
# deb-src http://security.ubuntu.com/ubuntu zesty-security multiverse

그런 다음 실행

apt-get update

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

apt-get upgrade

최신 업데이트를 설치합니다(있는 경우). 업데이트의 일부로 새 커널이 설치되면 나중에 시스템을 재부팅해야 합니다.

reboot

3. 기본 쉘 변경

/bin/sh는 /bin/dash에 대한 심볼릭 링크이지만 /bin/dash가 아니라 /bin/bash가 필요합니다. 따라서 다음과 같이 합니다.

dpkg-reconfigure dash

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

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

4. AppArmor 비활성화

AppArmor는 확장된 보안을 제공해야 하는 보안 확장(SELinux와 유사)입니다. 제 생각에는 보안 시스템을 구성하는 데 필요하지 않으며 일반적으로 이점보다 더 많은 문제를 야기합니다(일부 서비스가 예상대로 작동하지 않았기 때문에 일주일 동안 문제 해결을 수행한 후 생각해 보십시오. 모든 것이 괜찮았고 AppArmor만이 문제를 일으켰습니다.) 따라서 비활성화합니다(나중에 ISPConfig를 설치하려면 필수입니다).

다음과 같이 비활성화할 수 있습니다.

service apparmor stop
update-rc.d -f apparmor remove
apt-get remove apparmor apparmor-utils

5. 시스템 시계 동기화

물리적 서버를 실행할 때 인터넷을 통해 NTP(네트워크 시간 프로토콜) 서버와 시스템 시계를 동기화하는 것이 좋습니다. 가상 서버를 실행하는 경우 이 단계를 건너뛰어야 합니다. 그냥 실행

apt-get -y install ntp

시스템 시간은 항상 동기화됩니다.

6. Postfix, Dovecot, MariaDB, rkhunter 및 binutils 설치

postfix를 설치하려면 sendmail이 설치되어 있지 않고 실행 중인지 확인해야 합니다. sendmail을 중지하고 제거하려면 다음 명령을 실행하십시오.

service sendmail stop; update-rc.d -f sendmail remove

오류 메시지:

Failed to stop sendmail.service: Unit sendmail.service not loaded.

괜찮습니다. sendmail이 설치되지 않았으므로 제거할 항목이 없다는 의미입니다.

이제 단일 명령으로 Postfix, Dovecot, MariaDB(MySQL 대체품), rkhunter 및 binutils를 설치할 수 있습니다.

apt-get -y 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

다음과 같은 질문을 받게 됩니다.

General type of mail configuration: <-- Internet Site
System mail name: <-- server1.example.com

나중에 이메일 도메인(예: yourdomain.tld)으로 사용하려는 도메인이 아니라 server1.example.com 또는 server1.yourdomain.com과 같은 "시스템 메일 이름"으로 하위 도메인을 사용하는 것이 중요합니다.

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

nano /etc/postfix/master.cf

다음과 같이 제출 및 smtps 섹션의 주석 처리를 제거하십시오. 두 섹션 모두에 -o smtpd_client_restrictions=permit_sasl_authenticated,reject 행을 추가하고 그 이후의 모든 항목은 주석 처리된 상태로 두십시오.

[...]
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=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=permit_sasl_authenticated,reject
#  -o milter_macro_daemon_name=ORIGINATING
[...]

참고: "-o .... " 줄 앞의 공백은 중요합니다!

나중에 Postfix를 다시 시작하십시오.

service postfix restart

우리는 MySQL이 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
[...]
# 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

sql-mode="NO_ENGINE_SUBSTITUTION"

[...]

이제 MariaDB에서 루트 비밀번호를 설정합니다. 달리다:

mysql_secure_installation

다음과 같은 질문을 받게 됩니다.

Enter current password for root (enter for none): <-- press enter
Set root password? [Y/n] <-- y
New password: <-- Enter the new MariaDB root password here
Re-enter new password: <-- Repeat the password
Remove anonymous users? [Y/n] <-- y
Disallow root login remotely? [Y/n] <-- y
Reload privilege tables now? [Y/n] <-- y

나중에 PHPMyAdmin을 사용하여 루트 사용자로 연결할 수 있도록 MariaDB의 암호 인증 방법을 기본으로 설정합니다.

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"입니다.

# Automatically generated for Debian scripts. DO NOT TOUCH!
[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

그런 다음 MariaDB를 다시 시작합니다.

service mysql restart

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

netstat -tap | grep mysql

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

:~#

7. Amavisd-new, SpamAssassin 및 Clamav 설치

amavisd-new, SpamAssassin 및 ClamAV를 설치하려면 다음을 실행합니다.

apt-get -y 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
update-rc.d -f spamassassin remove

ClamAV를 시작하려면 다음을 사용하십시오.

freshclam
service clamav-daemon start

freshclam을 처음 실행할 때 다음 오류는 무시해도 됩니다.

ERROR: /var/log/clamav/freshclam.log is locked by another process
ERROR: Problem with internal logger (UpdateLogFile = /var/log/clamav/freshclam.log).

7.1 메트로놈 XMPP 서버 설치(선택 사항)

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

다음 패키지를 apt로 설치합니다.

apt-get -y 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

메트로놈에 대한 쉘 사용자를 추가하십시오.

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에 설치되었습니다.