サーバー設定 · 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 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 -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 restartMySQL が 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] <-- yMariaDB のパスワード認証方法をネイティブに設定し、後で 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 postgreyISPConfig 3 のセットアップでは、amavisd を使用して内部的に SpamAssassin フィルターライブラリをロードするため、RAM を解放するために SpamAssassin を停止できます:
service spamassassin stop
update-rc.d -f spamassassin removeClamAV を起動するには:
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
Configure database for phpmyadmin with dbconfig-common? <-- Yes
MySQL application password for phpmyadmin: <-- Press enter 
次に、Apache モジュール suexec、rewrite、ssl、actions、および include (WebDAV を使用する場合は dav、dav_fs、および auth_digest も) を有効にするために、次のコマンドを実行します:
a2enmod suexec rewrite ssl actions include cgi alias proxy_fcgia2enmod 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 restartISPConfig を通じて作成されたウェブサイトで拡張子 .rb の Ruby ファイルをホストしたい場合は、/etc/mime.types の行 application/x-ruby rb をコメントアウトする必要があります:
nano /etc/mime.types[...]
#application/x-ruby rb
[...](これは .rb ファイルにのみ必要です; 拡張子 .rbx の Ruby ファイルはそのままで動作します。)
その後、Apache を再起動します:
service apache2 restart9. Let’s Encrypt をインストールする
ISPConfig 3.2 には、無料の SSL 証明書機関 Let’s Encrypt の組み込みサポートがあります。Let’s Encrypt 機能を使用すると、ISPConfig でウェブサイトの無料 SSL 証明書を作成できます。
次に、Let’s Encrypt のサポートを追加します。
apt-get install certbot10. 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 mailmanroot@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 thenewaliases' 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://–.| |/ / | / \/ __ __ | | __ / /
| | `–. \ __/ | | / \| ‘ \| | |/ ` | | |
| |\// / | | \/\ () | | | | | | | (| | \ \
\/_/\| __/_/|| ||| |\, | __/ / |
|_/
初期設定
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 でログインします (初回ログイン後にデフォルトのパスワードを変更することをお勧めします):


システムは現在使用する準備が整いました。
## 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/新しい投稿を受信箱で受け取る
スパムはありません。いつでも購読を解除できます。