サーバー設定 · 4 min read · Sep 25, 2025

完璧なサーバー - Ubuntu 15.10 (nginx, MySQL, PHP, Postfix, BIND, Dovecot, Pure-FTPD と ISPConfig 3)

このチュートリアルでは、Nginx、PHP、MariaDB、Postfix、pure-ftpd、BIND、Dovecot、および ISPConfig 3 を使用して Ubuntu 15.10 (Wiley Werewolf) サーバーをインストールする手順を示します。ISPConfig 3 は、インストールされたサービスをウェブブラウザを通じて構成できるウェブホスティングコントロールパネルです。このセットアップは、ウェブ、メール (スパムおよびウイルス対策フィルターを含む)、データベース、FTP、および DNS サービスを提供する完全なホスティングサーバーを提供します。

1. 前提条件

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

このチュートリアルの手順は root ユーザーとして実行する必要があるため、コマンドの前に “sudo” を付けません。サーバーに進む前に root ユーザーとしてログインするか、次のコマンドを実行してください:

sudo su

別のユーザーとしてシェルにログインしている場合は、root になるためのコマンドです。

ファイルを編集するためのコマンドでは “nano” エディタを使用しますが、お好みのエディタに置き換えることができます。Nano はシェル用の使いやすいファイルエディタです。nano を使用したいがまだインストールしていない場合は、次のコマンドを実行してください:

apt-get install nano

2. Linux インストールの更新

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

nano /etc/apt/sources.list
#  
# deb cdrom:[Ubuntu-Server 15.10 _Wily Werewolf_ - Release amd64 (20151021)]/ wily main restricted  
#deb cdrom:[Ubuntu-Server 15.10 _Wily Werewolf_ - Release amd64 (20151021)]/ wily 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/ wily main restricted  
deb-src http://de.archive.ubuntu.com/ubuntu/ wily main restricted  
  
## 最終リリース後に生成された主要なバグ修正更新。  
deb http://de.archive.ubuntu.com/ubuntu/ wily-updates main restricted  
deb-src http://de.archive.ubuntu.com/ubuntu/ wily-updates main restricted  
  
## N.B. このリポジトリからのソフトウェアは、Ubuntu チームによって完全にサポートされていません。  
## また、universe のソフトウェアは、Ubuntu セキュリティチームからのレビューや更新を受けません。  
deb http://de.archive.ubuntu.com/ubuntu/ wily universe  
deb-src http://de.archive.ubuntu.com/ubuntu/ wily universe  
deb http://de.archive.ubuntu.com/ubuntu/ wily-updates universe  
deb-src http://de.archive.ubuntu.com/ubuntu/ wily-updates universe  
  
## N.B. このリポジトリからのソフトウェアは、Ubuntu チームによって完全にサポートされておらず、  
## 無料ライセンスの下にない可能性があります。  
## ソフトウェアの使用権について自分自身を満足させてください。  
## また、multiverse のソフトウェアは、Ubuntu セキュリティチームからのレビューや更新を受けません。  
deb http://de.archive.ubuntu.com/ubuntu/ wily multiverse  
deb-src http://de.archive.ubuntu.com/ubuntu/ wily multiverse  
deb http://de.archive.ubuntu.com/ubuntu/ wily-updates multiverse  
deb-src http://de.archive.ubuntu.com/ubuntu/ wily-updates multiverse  
  
## N.B. このリポジトリからのソフトウェアは、  
## メインリリースに含まれるものと同じくらい広範にテストされていない可能性がありますが、  
## 一部のアプリケーションの新しいバージョンが含まれており、  
## 有用な機能を提供する可能性があります。  
## また、backports のソフトウェアは、Ubuntu セキュリティチームからのレビューや更新を受けません。  
deb http://de.archive.ubuntu.com/ubuntu/ wily-backports main restricted universe multiverse  
deb-src http://de.archive.ubuntu.com/ubuntu/ wily-backports main restricted universe multiverse  
  
deb http://security.ubuntu.com/ubuntu wily-security main restricted  
deb-src http://security.ubuntu.com/ubuntu wily-security main restricted  
deb http://security.ubuntu.com/ubuntu wily-security universe  
deb-src http://security.ubuntu.com/ubuntu wily-security universe  
deb http://security.ubuntu.com/ubuntu wily-security multiverse  
deb-src http://security.ubuntu.com/ubuntu wily-security multiverse  
  
## Canonical の 'partner' リポジトリからのソフトウェアを追加するには、次の 2 行のコメントを解除してください。  
## このソフトウェアは Ubuntu の一部ではありませんが、Canonical と  
## 各ベンダーによって Ubuntu ユーザーへのサービスとして提供されています。  
# deb http://archive.canonical.com/ubuntu wily partner  
# deb-src http://archive.canonical.com/ubuntu wily partner                                                 

その後、次のコマンドを実行します:

apt-get update

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

apt-get upgrade

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

reboot

3. デフォルトシェルの変更

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

dpkg-reconfigure dash

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

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

4. AppArmor の無効化

AppArmor は、拡張セキュリティを提供するセキュリティ拡張 (SELinux に似ています) ですが、13.10 以降はデフォルトでインストールされていません。インストールされているかどうかを確認します。私の意見では、安全なシステムを構成するために必要ありませんし、通常は利点よりも問題を引き起こします (サービスが期待通りに動作しなかったためにトラブルシューティングを1週間行った後、すべてが正常であることがわかり、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 install ntp ntpdate

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

6. Postfix、Dovecot、MariaDB、phpMyAdmin、rkhunter、Binutils のインストール

Postfix、Dovecot、MariaDB (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 sudo

MariaDB は、元の MySQL 開発者 Monty Widenius によって開発された MySQL データベースサーバーのフォークです。インターネット上のテストによると、MariaDB は MySQL よりも高速であり、開発がより迅速に進んでいるため、ほとんどの Linux ディストリビューションはデフォルトの「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 restart

MariaDB/MySQL が localhost だけでなくすべてのインターフェースでリッスンするようにします。したがって、/etc/mysql/mariadb.conf.d/mysqld.cnf (MariaDB 用) または /etc/mysql/my.cnf (MySQL 用) を編集し、bind-address = 127.0.0.1 の行をコメントアウトします:

MariaDB

nano /etc/mysql/mariadb.conf.d/mysqld.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 restart

MariaDB と MySQL の systemd サービス名は “mysql” なので、再起動コマンドは両方のデータベースサーバーで同じです。

次に、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

次に、次のコマンドを実行して root ユーザーの UNIX 認証プラグインを無効にします:

echo "update user set plugin='' where User='root';flush privileges;" | mysql --defaults-file=/etc/mysql/debian.cnf mysql

PHPMyAdmin からのパスワードベースの認証を許可します。

MySQL

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

MariaDB と MySQL の systemd サービス名は “mysql” なので、再起動コマンドは両方のデータベースサーバーで同じです。

MySQL と MariaDB のために:

ネットワーキングが有効になっていることを確認します。次のコマンドを実行します:

netstat -tap | grep mysql

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

root@server1:~# netstat -tap | grep mysql  
tcp        0      0 *:mysql                 *:*                     LISTEN      8032/mysqld       
root@server1:~#

7. 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

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

service spamassassin stop  
update-rc.d -f spamassassin remove

ClamAV ウイルス対策シグネチャを更新し、Clamd サービスを開始します。更新プロセスには時間がかかる場合がありますので、途中で中断しないでください。

freshclam  
service clamav-daemon start
Share: X/Twitter LinkedIn

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

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