サーバー設定 · 16 min read · Sep 11, 2025

完璧なサーバー - Apache、PHP、MariaDB、PureFTPD、BIND、Postfix、Dovecot、および ISPConfig 3.2 を使用した Ubuntu 20.04

このチュートリアルでは、Apache 2.4、Postfix、Dovecot、Bind、および PureFTPD を使用して、ISPConfig 3.2 のインストールの準備を整えた Ubuntu 20.04 (Focal Fossa) ウェブホスティングサーバーのインストールを示します。結果として得られるシステムは、Web、Mail、Mailinglist、DNS、および FTP サーバーを提供します。

ISPConfig は、ウェブブラウザを通じて次のサービスを構成できるウェブホスティングコントロールパネルです: Apache または Nginx ウェブサーバー、Postfix メールサーバー、Courier または Dovecot IMAP/POP3 サーバー、MySQL の代替としての MariaDB、BIND または MyDNS ネームサーバー、PureFTPd、SpamAssassin、ClamAV など。 このセットアップでは、Apache (Nginx の代わりに)、BIND (MyDNS の代わりに)、および Dovecot (Courier の代わりに) のインストールをカバーしています。

ISPConfig をインストールする方法は 2 つあります。以下の手動インストール手順を使用するか、ISPConfig 自動インストーラーを使用して、数分で ISPConfig を自動的にインストールできます。自動インストーラーを使用することをお勧めします。これは Ubuntu 22.04 もサポートしています。ISPConfig を自動的にインストールする方法については、ISPConfig 自動インストールを参照してください。

1. 予備ノート

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

このチュートリアルのコマンドは、root 権限で実行する必要があります。各コマンドの前に sudo を追加しないようにするために、次のコマンドを実行して root ユーザーになります:

sudo -s

進む前に実行してください。

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

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

nano /etc/apt/sources.list
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://de.archive.ubuntu.com/ubuntu focal main restricted
# deb-src http://de.archive.ubuntu.com/ubuntu focal main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://de.archive.ubuntu.com/ubuntu focal-updates main restricted
# deb-src http://de.archive.ubuntu.com/ubuntu focal-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 focal universe
# deb-src http://de.archive.ubuntu.com/ubuntu focal universe
deb http://de.archive.ubuntu.com/ubuntu focal-updates universe
# deb-src http://de.archive.ubuntu.com/ubuntu focal-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 focal multiverse
# deb-src http://de.archive.ubuntu.com/ubuntu focal multiverse
deb http://de.archive.ubuntu.com/ubuntu focal-updates multiverse
# deb-src http://de.archive.ubuntu.com/ubuntu focal-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 focal-backports main restricted universe multiverse
# deb-src http://de.archive.ubuntu.com/ubuntu focal-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 focal partner
# deb-src http://archive.canonical.com/ubuntu focal partner

deb http://de.archive.ubuntu.com/ubuntu focal-security main restricted
# deb-src http://de.archive.ubuntu.com/ubuntu focal-security main restricted
deb http://de.archive.ubuntu.com/ubuntu focal-security universe
# deb-src http://de.archive.ubuntu.com/ubuntu focal-security universe
deb http://de.archive.ubuntu.com/ubuntu focal-security multiverse
# deb-src http://de.archive.ubuntu.com/ubuntu focal-security multiverse

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

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 に似ています) です。私の意見では、セキュアなシステムを構成するために必要ありませんし、通常は利点よりも問題を引き起こすことが多いです (サービスが期待通りに動作しなかったために 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 -y install ntp

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

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 を 1 つのコマンドでインストールできます:

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 sudo patch

次の質問が表示されます:

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       -       y       -       -       smtpd
  -o syslog_name=postfix/submission
  -o smtpd_tls_security_level=encrypt
  -o smtpd_sasl_auth_enable=yes  
  -o smtpd_tls_auth_only=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       -       y       -       -       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」です。「howtoforge」という単語を、mysql_secure_installation コマンドで設定した MySQL root ユーザーのパスワードに置き換えます。

# 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

エディタでファイル /etc/security/limits.conf を開きます:

nano /etc/security/limits.conf

ファイルの最後に次の行を追加します。

mysql soft nofile 65535  
mysql hard nofile 65535

次に、mkdir コマンドで新しいディレクトリ /etc/systemd/system/mysql.service.d/ を作成します。

mkdir /etc/systemd/system/mysql.service.d/

その中に新しいファイルを追加します:

nano /etc/systemd/system/mysql.service.d/limits.conf

そのファイルに次の行を貼り付けます:

[Service]  
LimitNOFILE=infinity

ファイルを保存して nano エディタを閉じます。

次に、systemd をリロードし、MariaDB を再起動します:

systemctl daemon-reload  
service mariadb restart

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

netstat -tap | grep mysql

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

root@server1:~# netstat -tap | grep mysql  
tcp6       0      0 [::]:mysql              [::]:*                    LISTEN      51836/mysqld  
root@server1:~#

7. Amavisd-new、SpamAssassin、および Clamav をインストールする

amavisd-new、SpamAssassin、および ClamAV をインストールするには、次のコマンドを実行します:

apt-get -y install amavisd-new spamassassin clamav clamav-daemon 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).

8. Apache、PHP、phpMyAdmin、FCGI、SuExec、Pear をインストールする

Apache 2.4、PHP 7.4、phpMyAdmin、FCGI、suExec、および Pear は次のようにインストールできます:

apt-get -y install apache2 apache2-doc apache2-utils libapache2-mod-php php7.4 php7.4-common php7.4-gd php7.4-mysql php7.4-imap phpmyadmin php7.4-cli php7.4-cgi libapache2-mod-fcgid apache2-suexec-pristine php-pear libruby libapache2-mod-python php7.4-curl php7.4-intl php7.4-pspell php7.4-sqlite3 php7.4-tidy php7.4-xmlrpc php7.4-xsl memcached php-memcache php-imagick php7.4-zip php7.4-mbstring php-soap php7.4-soap php7.4-opcache php-apcu php7.4-fpm libapache2-reload-perl

次の質問が表示されます:

Web server to reconfigure automatically: <-- apache2

Apache2 での PHPMyAdmin の有効化


Configure database for phpmyadmin with dbconfig-common? <-- Yes

MySQL application password for phpmyadmin: <-- Press enter  

MySQL アプリケーションパスワード

次に、Apache モジュール suexec、rewrite、ssl、actions、および include (WebDAV を使用する場合は dav、dav_fs、および auth_digest も) を有効にするために、次のコマンドを実行します:

a2enmod suexec rewrite ssl actions include cgi alias proxy_fcgi
a2enmod dav_fs dav auth_digest headers

サーバーが HTTPOXY 脆弱性を通じて攻撃されないように、Apache で HTTP_PROXY ヘッダーをグローバルに無効にします。次のコマンドで新しい httpoxy.conf ファイルを作成します:

nano /etc/apache2/conf-available/httpoxy.conf

ファイルに次の内容を貼り付けます:


    RequestHeader unset Proxy early

次のコマンドを実行して設定ファイルを有効にします:

a2enconf httpoxy

その後、Apache を再起動します:

service apache2 restart

ISPConfig を通じて作成されたウェブサイトで拡張子 .rb の Ruby ファイルをホストしたい場合は、/etc/mime.types の行 application/x-ruby rb をコメントアウトする必要があります:

nano /etc/mime.types
[...]
#application/x-ruby                             rb
[...]

(これは .rb ファイルにのみ必要です; 拡張子 .rbx の Ruby ファイルはそのままで動作します。)

その後、Apache を再起動します:

service apache2 restart

9. Let’s Encrypt をインストールする

ISPConfig 3.2 には、無料の SSL 証明書機関 Let’s Encrypt の組み込みサポートがあります。Let’s Encrypt 機能を使用すると、ISPConfig でウェブサイトの無料 SSL 証明書を作成できます。

次に、Let’s Encrypt のサポートを追加します。

apt-get install certbot

10. Mailman をインストールする

ISPConfig では、Mailman メーリングリストを管理 (作成/変更/削除) できます。この機能を利用したい場合は、次のように Mailman をインストールします:

apt-get -y install mailman

少なくとも 1 つの言語を選択します。例:

Languages to support: <– en (English)
Missing site list <– Ok

エラー ‘Job for mailman.service failed because the control process exited with error code.‘ は今のところ無視できます。

Mailman を開始する前に、mailman という最初のメーリングリストを作成する必要があります:

newlist mailman

root@server1:~# newlist mailman
Enter the email of the person running the list: <– admin email address, e.g. [email protected]
Initial mailman password: <– admin password for the mailman list
To finish creating your mailing list, you must edit your /etc/aliases (or
equivalent) file by adding the following lines, and possibly running the
newaliases' program: ## mailman mailing list mailman: |/var/lib/mailman/mail/mailman post mailman mailman-admin: |/var/lib/mailman/mail/mailman admin mailman mailman-bounces: |/var/lib/mailman/mail/mailman bounces mailman mailman-confirm: |/var/lib/mailman/mail/mailman confirm mailman mailman-join: |/var/lib/mailman/mail/mailman join mailman mailman-leave: |/var/lib/mailman/mail/mailman leave mailman mailman-owner: |/var/lib/mailman/mail/mailman owner mailman mailman-request: |/var/lib/mailman/mail/mailman request mailman mailman-subscribe: |/var/lib/mailman/mail/mailman subscribe mailman mailman-unsubscribe: |/var/lib/mailman/mail/mailman unsubscribe mailman Hit enter to notify mailman owner... <-- ENTER root@server1:~# その後、/etc/aliases を開きます... ``` nano /etc/aliases ``` ... 次の行を追加します: ``` [...] ## mailman mailing list mailman: |/var/lib/mailman/mail/mailman post mailman mailman-admin: |/var/lib/mailman/mail/mailman admin mailman mailman-bounces: |/var/lib/mailman/mail/mailman bounces mailman mailman-confirm: |/var/lib/mailman/mail/mailman confirm mailman mailman-join: |/var/lib/mailman/mail/mailman join mailman mailman-leave: |/var/lib/mailman/mail/mailman leave mailman mailman-owner: |/var/lib/mailman/mail/mailman owner mailman mailman-request: |/var/lib/mailman/mail/mailman request mailman mailman-subscribe: |/var/lib/mailman/mail/mailman subscribe mailman mailman-unsubscribe: |/var/lib/mailman/mail/mailman unsubscribe mailman ``` その後、次のコマンドを実行します: ``` newaliases ``` その後、Postfix を再起動します: ``` service postfix restart ``` 最後に、Mailman の Apache 設定を有効にする必要があります: ``` ln -s /etc/mailman/apache.conf /etc/apache2/conf-available/mailman.conf ``` これにより、すべての Apache vhosts に対して /cgi-bin/mailman/ というエイリアスが定義され、http:///cgi-bin/mailman/admin/ でメーリングリストの管理インターフェースにアクセスでき、http:///cgi-bin/mailman/listinfo/ でメーリングリストのユーザー用のウェブページにアクセスできます。 http:///pipermail ではメーリングリストのアーカイブを見つけることができます。 次のコマンドで設定を有効にします: ``` a2enconf mailman ``` その後、Apache を再起動します: ``` service apache2 restart ``` 次に、Mailman デーモンを起動します: ``` service mailman start ``` ## 11. PureFTPd と Quota をインストールする PureFTPd と quota は次のコマンドでインストールできます: ``` apt-get -y install pure-ftpd-common pure-ftpd-mysql quota quotatool ``` ファイル /etc/default/pure-ftpd-common を編集します... ``` nano /etc/default/pure-ftpd-common ``` ... スタートモードがスタンドアロンに設定され、VIRTUALCHROOT=true に設定されていることを確認します: ``` [...] STANDALONE_OR_INETD=standalone [...] VIRTUALCHROOT=true [...] ``` 次に、PureFTPd を構成して FTP および TLS セッションを許可します。FTP は非常に安全でないプロトコルであり、すべてのパスワードとすべてのデータが平文で転送されます。TLS を使用することで、通信全体を暗号化でき、FTP をはるかに安全にします。 FTP および TLS セッションを許可する場合は、次のコマンドを実行します: ``` echo 1 > /etc/pure-ftpd/conf/TLS ``` TLS を使用するには、SSL 証明書を作成する必要があります。私はそれを /etc/ssl/private/ に作成するため、最初にそのディレクトリを作成します: ``` mkdir -p /etc/ssl/private/ ``` その後、次のようにして SSL 証明書を生成できます: ``` openssl req -x509 -nodes -days 7300 -newkey rsa:2048 -keyout /etc/ssl/private/pure-ftpd.pem -out /etc/ssl/private/pure-ftpd.pem ``` Country Name (2 letter code) [AU]: <-- Enter your Country Name (e.g., "DE"). State or Province Name (full name) [Some-State]: <-- Enter your State or Province Name. Locality Name (eg, city) []: <-- Enter your City. Organization Name (eg, company) [Internet Widgits Pty Ltd]: <-- Enter your Organization Name (e.g., the name of your company). Organizational Unit Name (eg, section) []: <-- Enter your Organizational Unit Name (e.g. "IT Department"). Common Name (eg, YOUR name) []: <-- Enter the Fully Qualified Domain Name of the system (e.g. "server1.example.com"). Email Address []: <-- Enter your Email Address. SSL 証明書の権限を変更します: ``` chmod 600 /etc/ssl/private/pure-ftpd.pem ``` その後、PureFTPd を再起動します: ``` service pure-ftpd-mysql restart ``` ファイル /etc/fstab を編集します。私のは次のようになっています (マウントポイント / のパーティションに usrjquota=quota.user,grpjquota=quota.group,jqfmt=vfsv0 を追加しました): ``` nano /etc/fstab ``` ``` # /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # /dev/mapper/server1--vg-root / ext4 errors=remount-ro,usrjquota=quota.user,grpjquota=quota.group,jqfmt=vfsv0 0 1 /dev/mapper/server1--vg-swap_1 none swap sw 0 0 /dev/fd0 /media/floppy0 auto rw,user,noauto,exec,utf8 0 0 ``` クォータを有効にするには、次のコマンドを実行します: ``` mount -o remount / ``` ``` quotacheck -avugm quotaon -avug ``` 次の出力が表示されます: ``` root@server1:/tmp# quotacheck -avugm quotacheck: Scanning /dev/mapper/server1--vg-root [/] done quotacheck: Cannot stat old user quota file //quota.user: No such file or directory. Usage will not be subtracted. quotacheck: Cannot stat old group quota file //quota.group: No such file or directory. Usage will not be subtracted. quotacheck: Cannot stat old user quota file //quota.user: No such file or directory. Usage will not be subtracted. quotacheck: Cannot stat old group quota file //quota.group: No such file or directory. Usage will not be subtracted. quotacheck: Checked 13602 directories and 96597 files quotacheck: Old file not found. quotacheck: Old file not found. root@server1:/tmp# quotaon -avug /dev/mapper/server1--vg-root [/]: group quotas turned on /dev/mapper/server1--vg-root [/]: user quotas turned on ``` ## 12. BIND DNS サーバーをインストールする BIND は次のようにインストールできます: ``` apt-get -y install bind9 dnsutils haveged ``` haveged デーモンを有効にして起動します: ``` systemctl enable haveged systemctl start haveged ``` ## 13. Vlogger、Webalizer、AWStats および GoAccess をインストールする Vlogger、Webalizer、および AWStats は次のようにインストールできます: ``` apt-get -y install vlogger webalizer awstats geoip-database libclass-dbi-mysql-perl ``` 最新の GoAccess バージョンを GoAccess リポジトリから直接インストールします: ``` echo "deb https://deb.goaccess.io/ $(lsb_release -cs) main" | sudo tee -a /etc/apt/sources.list.d/goaccess.list wget -O - https://deb.goaccess.io/gnugpg.key | sudo apt-key --keyring /etc/apt/trusted.gpg.d/goaccess.gpg add - sudo apt-get update sudo apt-get install goaccess ``` その後、/etc/cron.d/awstats を開き... ``` nano /etc/cron.d/awstats ``` ... そのファイルのすべてをコメントアウトします: ``` #MAILTO=root #*/10 * * * * www-data [ -x /usr/share/awstats/tools/update.sh ] && /usr/share/awstats/tools/update.sh # Generate static reports: #10 03 * * * www-data [ -x /usr/share/awstats/tools/buildstatic.sh ] && /usr/share/awstats/tools/buildstatic.sh ``` ## 14. Jailkit をインストールする Jailkit は、ISPConfig でシェルユーザーと cronjob を監禁するために使用されます。apt で jailkit をインストールします: ``` apt-get -y install jailkit ``` ## 15. fail2ban および UFW をインストールする これはオプションですが、ISPConfig モニターがログを表示しようとするため、推奨されます: ``` apt-get -y install fail2ban ``` fail2ban が PureFTPd と Dovecot を監視できるようにするには、ファイル /etc/fail2ban/jail.local を作成します: ``` nano /etc/fail2ban/jail.local ``` ``` [pure-ftpd] enabled = true port = ftp filter = pure-ftpd logpath = /var/log/syslog maxretry = 3 [dovecot] enabled = true filter = dovecot action = iptables-multiport[name=dovecot-pop3imap, port="pop3,pop3s,imap,imaps", protocol=tcp] logpath = /var/log/mail.log maxretry = 5 [postfix] enabled = true port = smtp filter = postfix logpath = /var/log/mail.log maxretry = 3 ``` その後、fail2ban を再起動します: ``` service fail2ban restart ``` UFW ファイアウォールをインストールするには、次の apt コマンドを実行します: ``` apt-get install ufw ``` ## 16. Roundcube Webmail をインストールする Roundcube Webmail をインストールするには、次のコマンドを実行します: ``` apt-get -y install roundcube roundcube-core roundcube-mysql roundcube-plugins roundcube-plugins-extra javascript-common libjs-jquery-mousewheel php-net-sieve tinymce ``` インストーラーは次の質問をするかもしれません: ``` Configure database for roundcube with dbconfig-common? <-- Yes MySQL application password for roundcube: <-- Press enter ``` これらの質問が表示されず、ucf スクリプトに関する警告が表示されても心配しないでください。それは問題ありません。 シェルで表示される ucf 警告は無視できます。インストールに悪影響はありません。 次に、RoundCube の apache 設定ファイルを編集します。 ``` nano /etc/apache2/conf-enabled/roundcube.conf ``` # その行の前の # を削除し、/webmail のための 2 番目の Alias 行を追加し、次の行を追加します "AddType application/x-httpd-php .php" を "" 行の直後に: ``` # Those aliases do not work properly with several hosts on your apache server # Uncomment them to use it or adapt them to your configuration Alias /roundcube /var/lib/roundcube Alias /webmail /var/lib/roundcube [...] AddType application/x-httpd-php .php [...] ``` そして、Apache を再起動します: ``` service apache2 restart ``` 次に、RoundCube config.inc.php 設定ファイルを編集します: ``` nano /etc/roundcube/config.inc.php ``` デフォルトホストを localhost に変更します: ``` $config['default_host'] = 'localhost'; ``` SMTP サーバーを: ``` $config['smtp_server'] = 'localhost'; ``` および ``` $config['smtp_port'] = 25; ``` これにより、Roundcube がログインフォームにサーバー名入力フィールドを表示しないようになります。 ## 17. ISPConfig 3.2 をインストールする ここでは、ISPConfig 3.2 の安定版を使用します。 ``` cd /tmp wget -O ispconfig.tar.gz https://www.ispconfig.org/downloads/ISPConfig-3-stable.tar.gz tar xfz ispconfig.tar.gz cd ispconfig3*/install/ ``` 次のステップは、次のコマンドを実行することです: ``` php -q install.php ``` これにより、ISPConfig 3 インストーラーが起動します。インストーラーは、Postfix、Dovecot などのすべてのサービスを自動的に構成します。 ``` # php -q install.php ``` ``` -------------------------------------------------------------------------------- _____ ___________ _____ __ _ ____ |_ _/ ___| ___ \ / __ \ / _(_) /__ \ | | \–.| |/ / | / \/ __ __ | | __ / /
| | `–. \ __/ | | /
\| ‘ \| | |/ ` | | |
| |\// / | | \/\ () | | | | | | | (| | \ \
\
/_/\| __/_/|| ||| |\, | __/ / |
|_/


初期設定

Operating System: Ubuntu 20.04.1 LTS (Focal Fossa)

Following will be a few questions for primary configuration so be careful.
Default values are in [brackets] and can be accepted with .
Tap in “quit” (without the quotes) to stop the installer.

Select language (en,de) [en]: <– Hit Enter

Installation mode (standard,expert) [standard]: <– Hit Enter

Full qualified hostname (FQDN) of the server, eg server1.domain.tld [server1.canomi.com]: <– Hit Enter

MySQL server hostname [localhost]: <– Hit Enter

MySQL server port [3306]: <– Hit Enter

MySQL root username [root]: <– Hit Enter

MySQL root password []: <– Enter your MySQL root password

MySQL database to create [dbispconfig]: <– Hit Enter

MySQL charset [utf8]: <– Hit Enter

Configuring Postgrey
Configuring Postfix
Generating a 4096 bit RSA private key
……………………………………………………………..++
……………………………………………………………………………………………………………………….++
writing new private key to ‘smtpd.key’

—–
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter ‘.’, the field will be left blank.

—–
Country Name (2 letter code) [AU]: <– Enter 2 letter country code
State or Province Name (full name) [Some-State]: <– Enter the name of the state
Locality Name (eg, city) []: <– Enter your city
Organization Name (eg, company) [Internet Widgits Pty Ltd]: <– Enter company name or press enter
Organizational Unit Name (eg, section) []: <– Hit Enter
Common Name (e.g. server FQDN or YOUR name) []: <– Enter the server hostname, in my case: server1.example.com
Email Address []: <– Hit Enter
Configuring Mailman
Configuring Dovecot
Configuring Spamassassin
Configuring Amavisd
Configuring Getmail
Configuring BIND
Configuring Jailkit
Configuring Pureftpd
Configuring Apache
Configuring vlogger
Configuring Metronome XMPP Server
writing new private key to ‘localhost.key’

—–
Country Name (2 letter code) [AU]: <– Enter 2 letter country code
Locality Name (eg, city) []: <– Enter your city
Organization Name (eg, company) [Internet Widgits Pty Ltd]: <– Enter company name or press enter
Organizational Unit Name (eg, section) []: <– Hit Enter
Common Name (e.g. server FQDN or YOUR name) [server1.canomi.com]: <– Enter the server hostname, in my case: server1.example.com
Email Address []: <– Hit Enter

Configuring Ubuntu Firewall
Configuring Fail2ban
[INFO] service OpenVZ not detected
Configuring Apps vhost
Installing ISPConfig
ISPConfig Port [8080]:

Admin password [admin]:

Do you want a secure (SSL) connection to the ISPConfig web interface (y,n) [y]: <– Hit Enter

Generating RSA private key, 4096 bit long modulus
…………………..++
………………………………………………………………………………………………………………..++
e is 65537 (0x10001)
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter ‘.’, the field will be left blank.

—–
Country Name (2 letter code) [AU]: <– Enter 2 letter country code
State or Province Name (full name) [Some-State]: <– Enter the name of the state
Locality Name (eg, city) []: <– Enter your city
Organization Name (eg, company) [Internet Widgits Pty Ltd]: <– Enter company name or press enter
Organizational Unit Name (eg, section) []: <– Hit Enter
Common Name (e.g. server FQDN or YOUR name) []: <– Enter the server hostname, in my case: server1.example.com
Email Address []: <– Hit Enter

Please enter the following ‘extra’ attributes
to be sent with your certificate request
A challenge password []: <– Hit Enter
An optional company name []: <– Hit Enter
writing RSA key

Symlink ISPConfig LE SSL certs to postfix? (y,n) [y]: <– Hit Enter

Symlink ISPConfig LE SSL certs to pureftpd? Creating dhparam file takes some times. (y,n) [y]: <– Hit Enter

Generating DH parameters, 2048 bit long safe prime, generator 2
This is going to take a long time
…………………………………………………….+…………………………………………………………………………………………………………………………………………………….+……………….

Configuring DBServer
Installing ISPConfig crontab
no crontab for root
no crontab for getmail
Detect IP addresses
Restarting services …
Installation completed.


インストーラーは、すべての基盤となるサービスを自動的に構成するため、手動での構成は必要ありません。

その後、http(s)://server1.example.com:8080/ または http(s)://192.168.0.100:8080/ (HTTP または HTTPS は、インストール中に選択したものに依存します) で ISPConfig 3 にアクセスできます。ユーザー名 admin とパスワード admin でログインします (初回ログイン後にデフォルトのパスワードを変更することをお勧めします):

![ISPConfig のログイン画面 (Ubuntu 18.04 LTS)](/files/24a359d6-6ef5-41f5-934b-3c7d69d55dcf.png)  
  
![ISPConfig 3.2 ダッシュボード](/files/0aadd86c-90dd-42d7-9206-15914f387fbb.png)  
  

システムは現在使用する準備が整いました。

## 18. このチュートリアルの仮想マシンイメージのダウンロード

このチュートリアルは、VMWare および Virtualbox と互換性のある ovf/ova 形式の使用準備が整った仮想マシンイメージとして利用可能です。仮想マシンイメージは次のログイン詳細を使用します:

SSH / シェルログイン

ユーザー名: administrator  
パスワード: howtoforge

このユーザーには sudo 権限があります。

ISPConfig ログイン

ユーザー名: admin  
パスワード: howtoforge

MySQL ログイン

ユーザー名: root  
パスワード: howtoforge

VM の IP は 192.168.0.100 で、ファイル */etc/netplan/01-netcfg.yaml* で変更できます。上記のすべてのパスワードを変更して、仮想マシンを保護してください。

## 19. リンク

- Ubuntu: http://www.ubuntu.com/
- ISPConfig: http://www.ispconfig.org/
Share: X/Twitter LinkedIn

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

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