インストールガイド · 6 min read · Nov 17, 2025
Kumaのインストール方法 - Ubuntu 20.04での自己ホスト型Uptime Robotの代替

Uptime-Kumaは、Nodejsで書かれた「Uptime Robot」のようなオープンソースの監視ツールです。これは、豪華で美しいダッシュボードを持つ自己ホスト型の監視ツールで、複数の通知方法をサポートしています。Uptime-Kumaは、HTTP(s)、TCP、およびPingプロトコルを介してホストまたはサーバーの稼働時間を監視します。これらのプロトコルでホストにアクセスできない場合、稼働時間ホストはWebhook、Telegram、Discord、Gotify、Slack、Pushover、Email (SMTP)などを介して通知を送信します。
このガイドでは、UbuntuサーバーにUptime-Kumaをインストールし、Apacheウェブサーバーをリバースプロキシとして使用し、その前に無料のLet’s Encrypt SSL証明書を設定する方法を学びます。インストール中に、nvm (Node Version Manager)を通じたnodejsのインストールについても学びます。
前提条件
- Ubuntuサーバー20.04。
- ルート権限を持つユーザー。このユーザーを使用して新しいパッケージをインストールし、システム設定を変更します。
新しいユーザーの追加
まず、Ubuntuシステムに新しいユーザーを追加します。セキュリティ上の理由から、アプリケーションUptime-Kumaは非ルートユーザーとして実行されます。
- 以下のコマンドを実行して新しいユーザーを追加します。この例では、ユーザー名「 johndoe 」を使用します。自分のユーザー名に変更してください。
useradd -m -s /bin/bash johndoe知っておくべきオプション:
- -m = ユーザー名のホームディレクトリを自動的に作成し、’/home’ディレクトリの下に利用可能になります。
- -s = ユーザーのシェルのパスを定義します。ほとんどのLinuxには
/bin/bashシェルがあります。
- その後、以下のコマンドを実行してユーザー「johndoe」のパスワードを設定します。
passwd johndoe新しい強力なパスワードを入力し、再度入力してから「 Enter 」を押して確認します。
- 次に、以下のコマンドを使用してユーザー「johndoe」を「 sudo 」グループに追加します。
usermod -aG sudo johndoeユーザーを「 sudo 」グループに追加することで、ユーザーは「sudo su」コマンドを実行してルート権限を取得できるようになります。
NVM (Node Version Manager)のインストール
NVMまたはNode Version Managerは、1つのシステムに複数のnodejsバージョンをインストールするためのコマンドラインツールです。このツールを使用すると、アプリケーションに特定のnodejsバージョンをインストールでき、開発およびデプロイメント環境を柔軟にします。
この段階では、非ルートユーザー「johndoe」の下にnvmをインストールします。
- ルートシェルから、以下のコマンドを使用してユーザー「johndoe」にログインします。
su - johndoe- 以下のようにnvmインストーラーのスクリプトをダウンロードして実行します。
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
- 成功したら、以下のコマンドを使用してbash環境を再読み込みします。
source ~/.bashrc- 次に、以下のコマンドを実行して「 nvm 」のインストールを確認します。
command -v nvmインストールが成功すると、結果として「 nvm 」が表示されます。そうでない場合は、何も表示されないか、空の結果が表示されます。
次に、以下のようにnvmコマンドを実行します。
nvm --helpすると、nvmコマンドのマニュアルヘルプページが表示されます。
Node Version Manager (v0.38.0)
Note: refers to any version-like string nvm understands. This includes:
- full or partial version numbers, starting with an optional "v" (0.10, v0.1.2, v1)
- default (built-in) aliases: node, stable, unstable, iojs, system
- custom aliases you define with `nvm alias foo`
Any options that produce colorized output should respect the `--no-colors` option.
Usage:
nvm --help Show this message
--no-colors Suppress colored output
.....
Note:
to remove, delete, or uninstall nvm - just remove the `$NVM_DIR` folder (usually `~/.nvm`) Nodejs LTSバージョンのインストール
Uptime-Kumaアプリケーションをインストールするには、nodejs >= 14、git、およびpm2をインストールする必要があります。この時点で、nvmコマンドを使用してnodejsのLTS最新バージョンをインストールします。
- 以下のnvmコマンドを実行してnodejsのLTS最新バージョンをインストールします。
nvm install --ltsインストールが成功すると、以下のような出力が表示されます。

最初にインストールしたnodejsバージョンが、開発環境のデフォルトバージョンになります。
- 次に、以下のコマンドを実行してnodejsのインストールを確認します。
node --version
npm --versionインストールが成功すると、以下のような出力が表示されます。
# nodejs version
v14.17.4
# npm version
6.14.14Uptime-Kumaのダウンロードとインストール
この時点で、Uptime-Kumaアプリケーションをインストールする準備が整いました。
- 以下のgitコマンドを使用してuptime-Kumaのソースコードをクローンします。
git clone https://github.com/louislam/uptime-kuma.git- その後、作業ディレクトリを「 uptime-kuma/ 」に変更し、npmコマンドを実行してUptime-Kumaに必要なすべてのパッケージをインストールします。
cd uptime-kuma/
npm run setupすると、以下のような出力が表示されます。

pm2を使用したUptime-Kumaの設定
pm2とは何ですか?それは、nodejsプロセスマネージャーで、nodejsアプリケーションを永遠に管理し、維持するのに役立ちます。pm2には、nodejsアプリケーションのデプロイを簡単にするためのいくつかの組み込み機能があり、アプリケーションの状態、ログを監視し、アプリケーションのサービスファイルを設定することもできます。
- 以下のnpmコマンドを使用してpm2パッケージをインストールします。
npm install pm2- インストールが完了したら、以下のpm2コマンドを実行してUptime-Kumaアプリケーションを起動します。
pm2 start npm --name uptime-kuma -- run start-server -- --port=3001 --hostname=127.0.0.1すると、以下のような出力メッセージが表示されます。

画像に示されているように、アプリケーション名「 uptime-kuma 」が「 online 」の状態で実行されています。
- pm2でアプリケーションの状態を確認するには、以下のコマンドを実行します。
nodejsアプリケーションの状態を確認します。
pm2 statusnodejsアプリケーションのログを確認します。
pm2 logs
リアルタイムのnodejsアプリケーション監視。
pm2 monit
- 次に、以下のpm2コマンドを実行してUptime-Kumaアプリケーションのサービスファイルを生成します。
pm2 startupその後、出力に表示されたコマンドを実行する必要があります。
sudo env PATH=$PATH:/home/johndoe/.nvm/versions/node/v14.17.4/bin /home/johndoe/.nvm/versions/node/v14.17.4/lib/node_modules/pm2/bin/pm2 startup systemd -u johndoe --hp /home/johndoe「 sudo 」コマンドを使用し、ルート権限を取得するためにユーザーの正しいパスワードを入力してください。
コマンドが完了すると、以下の出力が表示されます。

スクリーンショットに示されているように、pm2はユーザーに基づいてsystemdサービスを生成します。この例では「 pm2-johndoe.service 」です。
次に、以下のコマンドを実行してUptime-Kumaアプリケーションの状態を生成して保存します。このコマンドは、Uptime-Kumaアプリケーションがシステム起動後も常にバックグラウンドで実行されるようにするために重要です。
pm2 save- サービス「 pm2-johndoe 」を確認するには、以下のコマンドを実行します。
sudo systemctl is-enabled pm2-johndoe出力に「 enabled 」が表示され、Uptime-Kumaアプリケーションがシステム起動後に自動的に実行されることを意味します。
さらに、システムを再起動し、再度サーバーにログインして、Uptime-Kumaサービスを確認することができます。
sudo systemctl status pm2-johndoe以下のような出力が表示されるはずです。
? pm2-johndoe.service - PM2プロセスマネージャー
Loaded: loaded (/etc/systemd/system/pm2-johndoe.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2021-08-10 01:52:37 UTC; 3min 57s ago
Docs: https://pm2.keymetrics.io/
Main PID: 745 (PM2 v5.1.0: God)
Tasks: 34 (limit: 2343)
Memory: 120.4M
CGroup: /system.slice/pm2-johndoe.service
??745 PM2 v5.1.0: God Daemon (/home/johndoe/.pm2)
??772 npm
??873 sh -c node server/server.js "--port=3001" "--hostname=127.0.0.1"
??874 node server/server.js --port=3001 --hostname=127.0.0.1
Aug 10 01:52:36 ubuntu64 pm2[633]: [PM2] Spawning PM2 daemon with pm2_home=/home/johndoe/.pm2
Aug 10 01:52:37 ubuntu64 pm2[633]: [PM2] PM2 Successfully daemonized
Aug 10 01:52:37 ubuntu64 pm2[633]: [PM2] Resurrecting
Aug 10 01:52:37 ubuntu64 pm2[633]: [PM2] Restoring processes located in /home/johndoe/.pm2/dump.pm2
Aug 10 01:52:37 ubuntu64 pm2[633]: [PM2] Process /home/johndoe/.nvm/versions/node/v14.17.4/bin/npm restored「 pm2-johndoe.service 」はシステム起動時に稼働しています。
Apacheをリバースプロキシとして設定
このガイドでは、Uptime-KumaアプリケーションのためにApacheウェブサーバーをリバースプロキシとしてインストールおよび構成します。
- 以下のコマンドを実行してApacheウェブサーバーパッケージをインストールします。
sudo apt install apache2「y」と入力して「 Enter 」を押してApacheウェブサーバーをインストールします。
- その後、以下のコマンドを使用していくつかのApacheモジュールを有効にします。
sudo a2enmod ssl proxy proxy_ajp proxy_wstunnel proxy_http rewrite deflate headers proxy_balancer proxy_connect proxy_html- 次に、以下のnanoエディタコマンドを使用して新しい仮想ホスト設定「 uptime-kuma.conf 」を作成します。
sudo nano /etc/apache2/sites-available/uptime-kuma.conf以下の設定をターミナルシェルに貼り付け、ドメイン名「 uptime.example.net 」を「 domain.com 」などの自分のドメインに変更します。
ServerName uptime.example.net
ProxyPass / http://localhost:3001/
RewriteEngine on
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule ^/?(.*) "ws://localhost:3001/$1" [P,L]
「 Ctrl+x 」を押し、「 Y 」と入力して設定を保存します。
- 次に、以下のコマンドを使用してApacheの仮想ホスト設定「uptime-kuma」を有効にします。
sudo a2ensite uptime-kumaその後、以下のコマンドを実行してApacheの設定を確認し、エラーがないことを確認します。
sudo apachectl configtest- 次に、以下のコマンドを使用してApacheサービスを再起動し、新しい設定を適用します。
sudo systemctl restart apache2
SSL LetsencryptでUptime-Kumaを保護
Uptime-Kumaへのアクセスを保護するために、Apacheウェブサーバー用にLetsencryptからSSLを設定します。
- まず、以下のコマンドを実行してcertbotツールをインストールします。
sudo apt install python3-certbot-apache「y」と入力して「 Enter 」を押してインストールを開始します。
- インストール後、以下のようにcertbotコマンドを使用してSSL Let’s encryptを生成します。
sudo certbot --apache yourdomain.comメールアドレスを入力してLetsencryptに登録し、「 Enter 」を押して続行します。Letsencryptは、SSL証明書が期限切れになるたびにメールを送信します。
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): [email protected]LetsencryptのTOS(利用規約)については、「 A 」と入力して同意し、「 Enter 」を押して続行します。
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: AEFF(Electronic Frontier Foundation)とのメール共有については、「 Y 」ははい、「 N 」はいいえと入力できます。この例では、EFFとメールアドレスを共有しません。
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: N今、certbotツールはUptime-Kumaのドメイン名のためにSSL Letsencryptを生成します。また、Apache仮想ホスト設定にいくつかの追加設定を追加します。
HTTPからHTTPSへの自動リダイレクトを設定するように求められます。「 2 」を入力してApacheのHTTPからHTTPSへの自動リダイレクトを設定し、「 Enter 」を押します。
Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2デプロイプロセスが成功すると、以下のような出力が表示されます。
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://uptime.example.net
You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=uptime.example.net
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/uptime.example.net/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/uptime.example.net/privkey.pem
Your cert will expire on 2021-10-10. To obtain a new or tweaked
version of this certificate in the future, simply run certbot again
with the "certonly" option. To non-interactively renew *all* of
your certificates, run "certbot renew"
- Your account credentials have been saved in your Certbot
configuration directory at /etc/letsencrypt. You should make a
secure backup of this folder now. This configuration directory will
also contain certificates and private keys obtained by Certbot so
making regular backups of this folder is ideal.
- If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le
- We were unable to subscribe you the EFF mailing list because your
e-mail address appears to be invalid. You can try again later by
visiting https://act.eff.org.Uptime-Kumaのインストールを確認
- ウェブブラウザを開き、アドレスバーにUptime-KumaのURLインストールを入力します。
HTTPSセキュア接続にリダイレクトされます。
- 最初のページでUptime-Kumaの新しい管理ユーザーを作成します。管理ユーザー名とパスワードを入力し、「 Create 」ボタンをクリックします。

- その後、新しいユーザー名とパスワードでログインし、「 Login 」ボタンをクリックします。

これで、Uptime-Kumaのダッシュボードが表示されます。
- 監視する新しいホストを追加するには、「 Add New Monitor 」ボタンをクリックします。

- この例では、ウェブサイトを監視するため、「 Monitor Type 」を「 HTTP(s) 」として選択し、ウェブサイトのURLアドレスを入力し、通知サポートのために「 Setup Notification 」をクリックし、ページの下部にある「 Save 」ボタンをクリックします。

- Uptime-Kumaダッシュボードにリダイレクトされ、ダッシュボードページにホストが表示されます。

以下は、ポートが閉じられた新しいタイプ「 TCP/IP 」を追加した後の別の例で、結果は「 ENCONNREFUSED 」または接続エラーです。ポートが拒否または閉じられています。

結論
おめでとうございます!Apacheウェブサーバーをリバースプロキシとして使用してUptime-Kumaを正常にインストールし、SSL LetsencryptでUptime-Kumaのデプロイを保護しました。次の段階では、ホストを追加し、ダウンインシデントの通知を有効にできます。
新しい投稿を受信箱で受け取る
スパムはありません。いつでも購読を解除できます。