サーバー設定 · 3 min read · Oct 02, 2025
完璧なサーバー - Apache、PHP、MySQL、PureFTPD、BIND、Postfix、Dovecot、ISPConfigを搭載したUbuntu 14.10
完璧なサーバー - Apache、PHP、MySQL、PureFTPD、BIND、Postfix、Dovecot、ISPConfigを搭載したUbuntu 14.10
バージョン 1.0
著者: Falko Timme、更新者: Srijan Kishore
howtoforgeをTwitterでフォロー
最終編集日 2014年10月31日
このチュートリアルでは、ISPConfig 3のインストールのためにApache2、BIND、Dovecotを搭載したUbuntu 14.10 (Utopic Unicorn) サーバーをインストールする方法と、ISPConfig 3のインストール方法を示します。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.0.100、ゲートウェイ192.168.0.1を使用します。これらの設定はあなたの環境によって異なる場合があるため、適宜置き換える必要があります。先に進む前に、チュートリアルで説明されているように、基本的な最小限のUbuntu 14.10のインストールが必要です。
2. /etc/apt/sources.listを編集し、Linuxインストールを更新する
/etc/apt/sources.listを編集します。ファイルからインストールCDをコメントアウトまたは削除し、universeおよびmultiverseリポジトリが有効になっていることを確認します。以下のようになります:
nano /etc/apt/sources.list#
# deb cdrom:[Ubuntu-Server 14.10 _Utopic Unicorn_ - Release amd64 (20141022.2)]/ utopic main restricted
#deb cdrom:[Ubuntu-Server 14.10 _Utopic Unicorn_ - Release amd64 (20141022.2)]/ utopic 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/ utopic main restricted
deb-src http://de.archive.ubuntu.com/ubuntu/ utopic main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://de.archive.ubuntu.com/ubuntu/ utopic-updates main restricted
deb-src http://de.archive.ubuntu.com/ubuntu/ utopic-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/ utopic universe
deb-src http://de.archive.ubuntu.com/ubuntu/ utopic universe
deb http://de.archive.ubuntu.com/ubuntu/ utopic-updates universe
deb-src http://de.archive.ubuntu.com/ubuntu/ utopic-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/ utopic multiverse
deb-src http://de.archive.ubuntu.com/ubuntu/ utopic multiverse
deb http://de.archive.ubuntu.com/ubuntu/ utopic-updates multiverse
deb-src http://de.archive.ubuntu.com/ubuntu/ utopic-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/ utopic-backports main restricted universe multiverse
deb-src http://de.archive.ubuntu.com/ubuntu/ utopic-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu utopic-security main restricted
deb-src http://security.ubuntu.com/ubuntu utopic-security main restricted
deb http://security.ubuntu.com/ubuntu utopic-security universe
deb-src http://security.ubuntu.com/ubuntu utopic-security universe
deb http://security.ubuntu.com/ubuntu utopic-security multiverse
deb-src http://security.ubuntu.com/ubuntu utopic-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 utopic partner
# deb-src http://archive.canonical.com/ubuntu utopic partner
## Uncomment the following two lines to add software from Ubuntu's
## 'extras' repository.
## This software is not part of Ubuntu, but is offered by third-party
## developers who want to ship their latest software.
# deb http://extras.ubuntu.com/ubuntu utopic main
# deb-src http://extras.ubuntu.com/ubuntu utopic mainその後、次のコマンドを実行します:
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)? <– 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(network time protocol)サーバーと同期することは良いアイデアです。単に次のコマンドを実行します:
apt-get install ntp ntpdateこれでシステム時間が常に同期されます。
6. Postfix、Dovecot、MySQL、phpMyAdmin、rkhunter、binutilsをインストールする
Postfixをインストールするために、sendmailを停止して削除する必要があります:
service sendmail stop; update-rc.d -f sendmail removeこれで、次のコマンドでPostfix、Dovecot、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次の質問が表示されます:
MySQL “root”ユーザーの新しいパスワード: <– yourrootsqlpassword
MySQL “root”ユーザーのパスワードを再入力: <– yourrootsqlpassword
自己署名のSSL証明書を作成しますか?: <– Yes
ホスト名: <– server1.example.com
ローカルのみ: <– OK
メール構成の一般的なタイプ: <– Internet Site
システムメール名: <– 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 restartMySQLがlocalhostだけでなくすべてのインターフェースでリッスンするように、/etc/mysql/my.cnfを編集し、bind-address = 127.0.0.1の行をコメントアウトします:
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ネットワーキングが有効になっていることを確認します。次のコマンドを実行します:
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 removeclamavを実行するには:
freshclam
service clamav-daemon start新しい投稿を受信箱で受け取る
スパムはありません。いつでも購読を解除できます。