サーバー設定 · 4 min read · Sep 25, 2025
完璧なサーバー - Ubuntu 15.10 (Wily Werewolf) に Apache、PHP、MySQL、PureFTPD、BIND、Postfix、Dovecot、ISPConfig 3 をインストールする
このチュートリアルでは、Apache2、Postfix、Dovecot、Bind、PureFTPD を使用して、Ubuntu 15.10 (Wily Werewolf) ウェブホスティングサーバーのインストールを示し、ISPConfig 3 のインストールの準備をします。結果として得られるシステムは、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 の代わりに) のインストールをカバーします。
ISPConfig 3 マニュアル
ISPConfig 3 の使い方を学ぶために、ISPConfig 3 マニュアルをダウンロードすることを強くお勧めします。
300 ページ以上にわたり、ISPConfig の背後にある概念 (管理者、リセラー、クライアント) を説明し、ISPConfig 3 のインストールと更新方法を説明し、ISPConfig のすべてのフォームとフォームフィールドのリファレンスを有効な入力の例と共に含み、ISPConfig 3 の最も一般的なタスクに関するチュートリアルを提供します。また、サーバーをより安全にする方法を説明し、最後にトラブルシューティングセクションが付いています。
1. 予備ノート
このチュートリアルでは、ホスト名 server1.example.com と IP アドレス 192.168.1.100、ゲートウェイ 192.168.1.1 を使用します。これらの設定はあなたの環境によって異なる場合があるため、適宜置き換える必要があります。さらに進む前に、チュートリアルで説明されているように、基本的な最小限の Ubuntu 15.10 のインストールが必要です。
2. /etc/apt/sources.list を編集し、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
## Major bug fix updates produced after the final release of the
## distribution.
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. 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/ 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. 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/ 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. 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/ 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
## 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 wily partner
# deb-src http://archive.canonical.com/ubuntu wily partnerその後、次のコマンドを実行します。
apt-get updateapt パッケージデータベースを更新し、
apt-get upgrade最新の更新をインストールします (ある場合)。更新の一環として新しいカーネルがインストールされる場合は、その後システムを再起動する必要があります:
reboot3. デフォルトシェルを変更する
/bin/sh は /bin/dash へのシンボリックリンクですが、/bin/bash が必要です。したがって、次のようにします。
dpkg-reconfigure dashUse dash as the default system shell (/bin/sh)? <– No
これを行わないと、ISPConfig のインストールが失敗します。
4. AppArmor を無効にする
AppArmor は、拡張セキュリティを提供するセキュリティ拡張 (SELinux に似ています) ですが、私の意見では、安全なシステムを構成するためには必要ありません。また、通常は利点よりも問題を引き起こすことが多いです (あるサービスが期待通りに動作しなかったためにトラブルシューティングを1週間行った後、すべてが正常であったことがわかり、AppArmor が問題を引き起こしていたことがわかることを考えてみてください)。したがって、これを無効にします (後で ISPConfig をインストールする場合は必須です)。
次のようにして無効にできます。
service apparmor stop
update-rc.d -f apparmor remove
apt-get remove apparmor apparmor-utils5. システムクロックを同期する
物理サーバーを運用している場合、NTP ( n etwork t ime p rotocol) サーバーとシステムクロックを同期することは良いアイデアです。仮想サーバーを運用している場合は、このステップをスキップしてください。次のコマンドを実行します。
apt-get 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 install postfix postfix-mysql postfix-doc mariadb-client mariadb-server openssl getmail4 rkhunter binutils dovecot-imapd dovecot-pop3d dovecot-mysql dovecot-sieve 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 restartMySQL が localhost だけでなくすべてのインターフェースでリッスンするようにしたいため、/etc/mysql/my.cnf を編集し、bind-address = 127.0.0.1 の行をコメントアウトします。
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 で 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 を再起動します。
service mysql restartネットワーキングが有効になっていることを確認します。次のコマンドを実行します。
netstat -tap | grep mysql出力は次のようになります。
root@server1:~# netstat -tap | grep mysql
tcp 0 0 *:mysql *:* LISTEN 24603/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-perlISPConfig 3 のセットアップでは、amavisd を使用しており、内部で SpamAssassin フィルターライブラリをロードするため、RAM を解放するために SpamAssassin を停止できます。
service spamassassin stop
update-rc.d -f spamassassin removeclamd 設定ファイルを編集します。
nano /etc/clamav/clamd.confそして、次の行を変更します。
AllowSupplementaryGroups falseを次のように変更します。
AllowSupplementaryGroups true ファイルを保存します。clamav を起動するには、次のコマンドを実行します。
freshclam
service clamav-daemon start新しい投稿を受信箱で受け取る
スパムはありません。いつでも購読を解除できます。