서버 설정 · 7 min read · Sep 10, 2025
완벽한 서버 - Ubuntu 16.04 (Nginx, MySQL, PHP, Postfix, BIND, Dovecot, Pure-FTPD 및 ISPConfig 3.1)
이 튜토리얼은 Nginx, PHP, MariaDB, Postfix, pure-ftpd, BIND, Dovecot 및 ISPConfig 3.1이 설치된 Ubuntu 16.04 (Xenial Xerus) 서버를 설치하는 단계를 보여줍니다. ISPConfig는 웹 브라우저를 통해 설치된 서비스를 구성할 수 있는 웹 호스팅 제어판입니다. 이 설정은 웹, 이메일(스팸 및 바이러스 필터 포함), 데이터베이스, FTP 및 DNS 서비스를 갖춘 전체 호스팅 서버를 제공합니다.
1. 사전 참고
이 튜토리얼에서는 호스트 이름 server1.example.com과 IP 주소 192.168.1.100 및 게이트웨이 192.168.1.1을 네트워크 구성에 사용할 것입니다. 이러한 설정은 귀하의 경우 다를 수 있으므로 적절한 곳에서 교체해야 합니다. 진행하기 전에 튜토리얼에서 설명한 대로 Ubuntu 16.04의 기본 최소 설치가 필요합니다.
이 튜토리얼의 단계는 루트 사용자로 실행해야 하므로 명령 앞에 “sudo”를 붙이지 않겠습니다. 진행하기 전에 루트 사용자로 서버에 로그인하거나 다음을 실행하십시오:
sudo -s다른 사용자로 셸에 로그인한 경우 루트가 되기 위해 사용합니다.
파일을 편집하는 명령은 편집기 “nano”를 사용할 것이며, 원하는 편집기로 교체할 수 있습니다. Nano는 셸에서 사용하기 쉬운 파일 편집기입니다. nano를 사용하고 싶지만 아직 설치하지 않았다면 다음을 실행하십시오:
apt-get install nano2. 리눅스 설치 업데이트
/etc/apt/sources.list를 편집합니다. 파일에서 설치 CD를 주석 처리하거나 제거하고 universe 및 multiverse 저장소가 활성화되어 있는지 확인하십시오. 다음과 같이 보여야 합니다:
nano /etc/apt/sources.list#
# deb cdrom:[Ubuntu-Server 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420)]/ xenial main restricted
#deb cdrom:[Ubuntu-Server 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420)]/ xenial 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/ xenial main restricted
# deb-src http://de.archive.ubuntu.com/ubuntu/ xenial main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://de.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
# deb-src http://de.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
## 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
universe WILL NOT receive any review or updates from the Ubuntu security
## team.
deb http://de.archive.ubuntu.com/ubuntu/ xenial universe
# deb-src http://de.archive.ubuntu.com/ubuntu/ xenial universe
deb http://de.archive.ubuntu.com/ubuntu/ xenial-updates universe
# deb-src http://de.archive.ubuntu.com/ubuntu/ xenial-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/ xenial multiverse
# deb-src http://de.archive.ubuntu.com/ubuntu/ xenial multiverse
deb http://de.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
# deb-src http://de.archive.ubuntu.com/ubuntu/ xenial-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/ xenial-backports main restricted universe multiverse
# deb-src http://de.archive.ubuntu.com/ubuntu/ xenial-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 xenial partner
# deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://security.ubuntu.com/ubuntu xenial-security main restricted
# deb-src http://security.ubuntu.com/ubuntu xenial-security main restricted
deb http://security.ubuntu.com/ubuntu xenial-security universe
# deb-src http://security.ubuntu.com/ubuntu xenial-security universe
deb http://security.ubuntu.com/ubuntu xenial-security multiverse
# deb-src http://security.ubuntu.com/ubuntu xenial-security multiverse그런 다음 실행합니다:
apt-get updateapt 패키지 데이터베이스를 업데이트하고 다음을 실행합니다:
apt-get upgrade최신 업데이트를 설치합니다(있는 경우). 업데이트의 일환으로 새로운 커널이 설치되는 경우, 이후에 시스템을 재부팅해야 합니다:
reboot3. 기본 셸 변경
/bin/sh는 /bin/dash에 대한 심볼릭 링크이지만, 우리는 /bin/dash가 아닌 /bin/bash가 필요합니다. 따라서 이렇게 합니다:
dpkg-reconfigure dashUse dash as the default system shell (/bin/sh)? <– 아니요
이 작업을 수행하지 않으면 ISPConfig 설치가 실패합니다.
4. AppArmor 비활성화
AppArmor는 확장된 보안을 제공해야 하는 보안 확장(SELinux와 유사)입니다. 설치되어 있는지 확인하고 필요시 제거합니다. 제 생각에는 안전한 시스템을 구성하는 데 필요하지 않으며, 일반적으로 장점보다 더 많은 문제를 일으킵니다(어떤 서비스가 예상대로 작동하지 않아 문제 해결을 일주일 동안 한 후, 모든 것이 괜찮았고 단지 AppArmor가 문제를 일으켰다는 것을 알게 되는 경우를 생각해 보십시오). 따라서 비활성화합니다(나중에 ISPConfig를 설치하려면 필수입니다).
다음과 같이 비활성화할 수 있습니다:
service apparmor stop
update-rc.d -f apparmor remove
apt-get remove apparmor apparmor-utils5. 시스템 시계 동기화
시스템 시계를 인터넷을 통한 NTP(network time protocol) 서버와 동기화하는 것이 좋습니다. 간단히 실행하십시오:
apt-get -y install ntp ntpdate그러면 시스템 시간이 항상 동기화됩니다.
6. Postfix, Dovecot, MariaDB, phpMyAdmin, 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 sudoMariaDB는 원래 MySQL 개발자인 Monty Widenius가 개발한 MySQL 데이터베이스 서버의 포크입니다. 인터넷에서 발견된 테스트에 따르면 MariaDB는 MySQL보다 빠르며 개발 속도가 더 빠릅니다. 따라서 대부분의 리눅스 배포판은 기본 “MySQL 유사” 데이터베이스 서버로 MySQL을 MariaDB로 대체했습니다. MySQL을 MariaDB보다 선호하는 경우 위 명령에서 “mariadb-client mariadb-server”를 “mysql-client mysql-server”로 교체하십시오.
다음 질문이 표시됩니다:
General type of mail configuration: <-- Internet Site
System mail name: <-- server1.example.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
[...] 그 후 Postfix를 재시작합니다:
service postfix restartMariaDB/MySQL이 localhost뿐만 아니라 모든 인터페이스에서 수신 대기하도록 설정합니다. 따라서 /etc/mysql/mariadb.conf.d/50-server.cnf(또는 MySQL의 경우 /etc/mysql/my.cnf)를 편집하고 bind-address = 127.0.0.1 줄을 주석 처리합니다:
MariaDB
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
[...] 그런 다음 MariaDB를 재시작합니다:
service mysql restartMariaDB와 MySQL의 systemd 서비스 이름은 “mysql”이므로 재시작 명령은 두 데이터베이스 서버 모두에 대해 동일합니다.
이제 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] <-- yMySQL
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 restartMariaDB와 MySQL의 systemd 서비스 이름은 “mysql”이므로 재시작 명령은 두 데이터베이스 서버 모두에 대해 동일합니다.
MySQL 및 MariaDB의 경우:
이제 네트워킹이 활성화되어 있는지 확인합니다. 실행하십시오:
netstat -tap | grep mysql출력은 다음과 같아야 합니다:
root@server1:~# netstat -tap | grep mysql
tcp6 0 0 [::]:mysql [::]:* LISTEN 13796/mysqld
root@server1:~#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 postgreyISPConfig 3 설정은 내부적으로 SpamAssassin 필터 라이브러리를 로드하는 amavisd-new를 사용하므로 RAM을 확보하기 위해 SpamAssassin을 중지할 수 있습니다:
service spamassassin stop
update-rc.d -f spamassassin removeClamAV 안티바이러스 서명을 업데이트하고 Clamd 서비스를 시작합니다. 업데이트 프로세스는 시간이 걸릴 수 있으니 중단하지 마십시오.
service clamav-freshclam restart
service clamav-daemon start7.1 Metronome 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 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에 설치되었습니다.
새 게시물을 받은 편지함에서 받기
스팸은 없습니다. 언제든지 구독 해지 가능합니다.