サーバー設定 · 4 min read · Oct 01, 2025

完璧なサーバー - Ubuntu 16.10 (Yakkety Yak) と Apache、PHP、MySQL、PureFTPD、BIND、Postfix、Dovecot および ISPConfig 3.1

このチュートリアルでは、Apache2、Postfix、Dovecot、Bind、PureFTPD を使用して、ISPConfig 3.1 のインストールの準備を整えた Ubuntu 16.10 (Yakkety Yak) ウェブホスティングサーバーのインストールを示します。結果として得られるシステムは、Web、Mail、Mailinglist、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 Time Support) バージョンの Ubuntu 16.10 に関するものです。ほとんどのユーザーは、はるかに長い間更新とセキュリティパッチを受け取る LTS バージョンを好みます。最新の LTS リリースは Ubuntu 16.04 であり、このチュートリアルは Ubuntu 16.04 バージョンでも存在します。最新のパッケージが必要で (短いサポート期間に問題がない場合)、このチュートリアルを続行してください。長期サポートが必要な場合は、代わりに Ubuntu 16.04 完璧なサーバーチュートリアルを使用してください。

1. 前提条件

このチュートリアルでは、ホスト名 server1.example.com と IP アドレス 192.168.1.100、ゲートウェイ 192.168.1.1 を使用します。これらの設定はあなたの環境によって異なる場合があるため、適切な場所で置き換える必要があります。さらに進む前に、チュートリアルで説明されているように、基本的な最小限の Ubuntu 16.10 のインストールが必要です。

2. /etc/apt/sources.list を編集し、Linux インストールを更新する

/etc/apt/sources.list を編集します。ファイルからインストール CD をコメントアウトまたは削除し、universe および multiverse リポジトリが有効になっていることを確認してください。その後、次のようになります:

nano /etc/apt/sources.list
#  
# deb cdrom:[Ubuntu-Server 16.10 _Yakkety Yak_ - Release amd64 (20161012.1)]/ yakkety main restricted  
#deb cdrom:[Ubuntu-Server 16.10 _Yakkety Yak_ - Release amd64 (20161012.1)]/ yakkety 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/ yakkety main restricted  
# deb-src http://de.archive.ubuntu.com/ubuntu/ yakkety main restricted  

## 最終リリース後に生成された主要なバグ修正更新。  
deb http://de.archive.ubuntu.com/ubuntu/ yakkety-updates main restricted  
# deb-src http://de.archive.ubuntu.com/ubuntu/ yakkety-updates main restricted  

## N.B. このリポジトリからのソフトウェアは、Ubuntu チームによって完全にサポートされていません。  
## また、universe のソフトウェアは、Ubuntu セキュリティチームからのレビューや更新を受けません。  
deb http://de.archive.ubuntu.com/ubuntu/ yakkety universe  
# deb-src http://de.archive.ubuntu.com/ubuntu/ yakkety universe  
deb http://de.archive.ubuntu.com/ubuntu/ yakkety-updates universe  
# deb-src http://de.archive.ubuntu.com/ubuntu/ yakkety-updates universe  

## N.B. このリポジトリからのソフトウェアは、Ubuntu チームによって完全にサポートされておらず、  
## 無料ライセンスの下にない可能性があります。  
## ソフトウェアの使用権について自分自身を満足させてください。  
## また、multiverse のソフトウェアは、Ubuntu セキュリティチームからのレビューや更新を受けません。  
deb http://de.archive.ubuntu.com/ubuntu/ yakkety multiverse  
# deb-src http://de.archive.ubuntu.com/ubuntu/ yakkety multiverse  
deb http://de.archive.ubuntu.com/ubuntu/ yakkety-updates multiverse  
# deb-src http://de.archive.ubuntu.com/ubuntu/ yakkety-updates multiverse  

## N.B. このリポジトリからのソフトウェアは、  
## メインリリースに含まれるソフトウェアほど広範にテストされていない可能性がありますが、  
## 有用な機能を提供する新しいバージョンのアプリケーションが含まれています。  
## また、backports のソフトウェアは、Ubuntu セキュリティチームからのレビューや更新を受けません。  
deb http://de.archive.ubuntu.com/ubuntu/ yakkety-backports main restricted universe multiverse  
# deb-src http://de.archive.ubuntu.com/ubuntu/ yakkety-backports main restricted universe multiverse  

## Canonical の 'partner' リポジトリからのソフトウェアを追加するには、次の 2 行のコメントを解除してください。  
## このソフトウェアは Ubuntu の一部ではありませんが、Canonical および  
## 関連するベンダーによって Ubuntu ユーザーへのサービスとして提供されています。  
# deb http://archive.canonical.com/ubuntu yakkety partner  
# deb-src http://archive.canonical.com/ubuntu yakkety partner  
deb http://security.ubuntu.com/ubuntu yakkety-security main restricted  
# deb-src http://security.ubuntu.com/ubuntu yakkety-security main restricted  
deb http://security.ubuntu.com/ubuntu yakkety-security universe  
# deb-src http://security.ubuntu.com/ubuntu yakkety-security universe  
deb http://security.ubuntu.com/ubuntu yakkety-security multiverse  
# deb-src http://security.ubuntu.com/ubuntu yakkety-security multiverse

その後、次を実行します:

apt-get update

apt パッケージデータベースを更新し、

apt-get upgrade

最新の更新をインストールします (ある場合)。更新の一環として新しいカーネルがインストールされる場合は、その後システムを再起動する必要があります:

reboot

3. デフォルトシェルを変更する

/bin/sh は /bin/dash へのシンボリックリンクですが、/bin/dash ではなく /bin/bash が必要です。したがって、次のようにします:

dpkg-reconfigure dash

Use dash as the default system shell (/bin/sh)? <– No

これを行わないと、ISPConfig のインストールが失敗します。

4. AppArmor を無効にする

AppArmor は、拡張セキュリティを提供するセキュリティ拡張 (SELinux に似たもの) です。私の意見では、安全なシステムを構成するために必要ありませんし、通常は利点よりも多くの問題を引き起こします (あるサービスが期待通りに動作しなかったためにトラブルシューティングを一週間行った後、すべてが正常であることがわかり、AppArmor が問題を引き起こしていたことがわかります)。したがって、無効にします (これは、後で ISPConfig をインストールしたい場合は必須です)。

次のようにして無効にできます:

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

5. システムクロックを同期する

物理サーバーを実行している場合、インターネット上の NTP ( n etwork t ime p rotocol) サーバーとシステムクロックを同期することは良いアイデアです。仮想サーバーを実行している場合は、このステップをスキップする必要があります。次を実行するだけで:

apt-get -y install ntp ntpdate

システム時間は常に同期されます。

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  

「システムメール名」として server1.example.com や server1.yourdomain.com のようなサブドメインを使用し、後でメールドメインとして使用したいドメイン (例:yourdomain.tld) ではないことが重要です。

次に、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 の行をコメントアウトします:

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 で root パスワードを設定します。次を実行します:

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

MariaDB のパスワード認証方法をネイティブに設定し、後で PHPMyAdmin から root ユーザーとして接続できるようにします:

echo "update mysql.user set plugin = 'mysql_native_password' where user='root';" | mysql -u root

ファイル /etc/mysql/debian.cnf を編集し、そこに MYSQL / MariaDB の root パスワードを 2 回設定します。

nano /etc/mysql/debian.cnf

追加する必要がある MySQL root パスワードは、読み取り専用で表示され、この例ではパスワードは “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

出力は次のようになります:

root@server1:~# netstat -tap | grep mysql  
tcp6 0 0 [::]:mysql [::]:* LISTEN 23476/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 postgrey

ISPConfig 3 のセットアップでは、amavisd が内部で SpamAssassin フィルターライブラリをロードするため、RAM を解放するために SpamAssassin を停止できます:

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 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 luarocks
luarocks install lpc

Metronome 用のシェルユーザーを追加します。

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 にインストールされました。

Share: X/Twitter LinkedIn

新しい投稿を受信箱で受け取る

スパムはありません。いつでも購読を解除できます。