OpenEMRインストール · 7 min read · Sep 24, 2025
Ubuntu 22.04にOpenEMRをインストールする方法

OpenEMRは、オープンソースの電子健康記録および医療業務管理ツールです。これは、米国保健情報技術コーディネーター局(ONC)によって認定されており、統合された健康記録、業務管理、スケジューリング、電子請求、国際化、無料サポートなど、多くの機能を備えています。患者の人口統計を追跡し、患者をスケジュールし、ラボレポート、薬、手順を含む非常に詳細な健康記録を維持し、処方を追跡し、医療請求を支援し、詳細なレポートを生成し、多言語サポートを提供します。
このチュートリアルでは、Ubuntu 22.04を実行しているサーバーにOpenEMRソフトウェアをインストールする方法を学びます。
前提条件
- Ubuntu 20.04を実行しているサーバー。
- 非ルートのsudoユーザー。
openemr.example.comのような完全修飾ドメイン名(FQDN)。- すべてが更新されていることを確認してください。
$ sudo apt update $ sudo apt upgrade - システムに必要な数パッケージ。 これらのパッケージのいくつかは、すでにシステムにインストールされている場合があります。
$ sudo apt install wget curl nano ufw software-properties-common dirmngr apt-transport-https gnupg2 ca-certificates lsb-release ubuntu-keyring unzip -y
ステップ1 - ファイアウォールの設定
最初のステップは、ファイアウォールを設定することです。Ubuntuにはデフォルトでufw(Uncomplicated Firewall)が付属しています。
ファイアウォールが実行中かどうかを確認します。
$ sudo ufw status次の出力が得られます。
Status: inactiveSSHポートを許可して、ファイアウォールを有効にした際に現在の接続が切断されないようにします。
$ sudo ufw allow OpenSSHHTTPおよびHTTPSポートも許可します。
$ sudo ufw allow http
$ sudo ufw allow httpsファイアウォールを有効にします。
$ sudo ufw enable
Command may disrupt existing ssh connections. Proceed with operation (y|n)? y
Firewall is active and enabled on system startupファイアウォールの状態を再度確認します。
$ sudo ufw status同様の出力が表示されるはずです。
Status: active
To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
80/tcp ALLOW Anywhere
443 ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
80/tcp (v6) ALLOW Anywhere (v6)
443 (v6) ALLOW Anywhere (v6)ステップ2 - Nginxのインストール
Ubuntuには古いバージョンのNginxが付属しています。最新バージョンをインストールするには、公式のNginxリポジトリをダウンロードする必要があります。
Nginxの署名キーをインポートします。
$ curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor \
| sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/nullNginxの安定版のリポジトリを追加します。
$ echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg arch=amd64] \
http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \
| sudo tee /etc/apt/sources.list.d/nginx.listシステムリポジトリを更新します。
$ sudo apt updateNginxをインストールします。
$ sudo apt install nginxインストールを確認します。
$ nginx -v
nginx version: nginx/1.24.0Nginxサーバーを起動します。
$ sudo systemctl start nginxステップ3 - MySQLのインストール
Ubuntu 22.04には最新のMySQLバージョンが付属しています。単一のコマンドでインストールできます。
$ sudo apt install mysql-serverMySQLのバージョンを確認します。
$ mysql --version
mysql Ver 8.0.33-0ubuntu0.22.04.2 for Linux on x86_64 ((Ubuntu))このステップはMySQLバージョン8.0.28以上に必要です。MySQLシェルに入ります。
$ sudo mysqlルートユーザーのパスワードを設定するために次のコマンドを実行します。数字、大文字、小文字、特殊文字を組み合わせてください。
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'YourPassword12!';シェルを終了します。
mysql> exitMySQLのセキュアインストールスクリプトを実行します。
$ sudo mysql_secure_installation最初に、ルートパスワードを尋ねられます。入力してください。次に、Validate Password Componentをインストールするかどうかを尋ねられます。これはMySQLで使用されるパスワードの強度をチェックします。Yを押してインストールします。次に、パスワード検証ポリシーのレベルを設定するように求められます。最も強力な2を選択します。
Securing the MySQL server deployment.
Enter password for user root:
VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?
Press y|Y for Yes, any other key for No: Y
There are three levels of password validation policy:
LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
Using existing password for root.
Estimated strength of the password: 100次に、ルートパスワードを変更しないことを拒否するためにNを入力します。また、匿名ユーザーを削除し、リモートルートログインを禁止し、テストデータベースを削除し、特権テーブルを再読み込みするためにYを入力します。
Change the password for root ? ((Press y|Y for Yes, any other key for No) : N
... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
Success.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y
Success.
All done!ステップ4 - MySQLの設定
MySQLシェルにログインします。プロンプトが表示されたらルートパスワードを入力します。
$ sudo mysql -u root -pサンプルデータベースを作成します。
mysql> CREATE DATABASE openemr;SQLユーザーアカウントを作成します。
mysql> CREATE USER 'openemruser'@'localhost' IDENTIFIED BY 'Your_password2';ユーザーにデータベースへのすべての特権を付与します。
mysql> GRANT ALL PRIVILEGES ON openemr.* TO 'openemruser'@'localhost';ユーザー特権をフラッシュします。
mysql> FLUSH PRIVILEGES;シェルを終了します。
mysql> exitステップ5 - PHPとその拡張機能のインストール
Ubuntu 22.04には少し古いPHP 8.1.2バージョンが付属しています。OndrejのPHPリポジトリを使用して最新のPHP 8.2バージョンをインストールします。
$ sudo add-apt-repository ppa:ondrej/php次に、OpenEMRに必要なPHPとその拡張機能をインストールします。
$ sudo apt install php8.2-fpm php8.2-mysql php8.2-bcmath php8.2-xml php8.2-zip php8.2-curl php8.2-mbstring php8.2-gd php8.2-tidy php8.2-intl php8.2-cli php8.2-soap imagemagick libtiff-tools php8.2-ldapインストールを確認します。
$ php --version
PHP 8.2.7 (cli) (built: Jun 8 2023 15:27:40) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.7, Copyright (c) Zend Technologies
with Zend OPcache v8.2.7, Copyright (c), by Zend Technologiesステップ6 - SSLのインストール
SSL証明書を生成するためにCertbotをインストールする必要があります。Ubuntuのリポジトリを使用してCertbotをインストールするか、Snapdツールを使用して最新バージョンを取得できます。Snapdバージョンを使用します。
Ubuntu 22.04にはデフォルトでSnapdがインストールされています。次のコマンドを実行して、Snapdのバージョンが最新であることを確認します。
$ sudo snap install core && sudo snap refresh coreCertbotをインストールします。
$ sudo snap install --classic certbot次のコマンドを使用して、Certbotコマンドが/usr/binディレクトリで実行できるようにシンボリックリンクを作成します。
$ sudo ln -s /snap/bin/certbot /usr/bin/certbot次のコマンドを実行してSSL証明書を生成します。
$ sudo certbot certonly --nginx --agree-tos --no-eff-email --staple-ocsp --preferred-challenges http -m [email protected] -d openemr.example.com上記のコマンドは、サーバーの/etc/letsencrypt/live/openemr.example.comディレクトリに証明書をダウンロードします。
Diffie-Hellmanグループ証明書を生成します。
$ sudo openssl dhparam -dsaparam -out /etc/ssl/certs/dhparam.pem 4096Certbotの更新スケジューラーサービスを確認します。
$ sudo systemctl list-timerssnap.certbot.renew.serviceが実行予定のサービスの1つとして表示されます。
NEXT LEFT LAST PASSED UNIT ACTIVATES
.....
Sun 2023-02-26 06:32:00 UTC 9h left Sat 2023-02-25 18:04:05 UTC 2h 59min ago snap.certbot.renew.timer snap.certbot.renew.service
Sun 2023-02-26 06:43:20 UTC 9h left Sat 2023-02-25 10:49:23 UTC 10h ago apt-daily-upgrade.timer apt-daily-upgrade.service
Sun 2023-02-26 09:00:06 UTC 11h left Sat 2023-02-25 20:58:06 UTC 5min ago apt-daily.timer apt-daily.serviceSSL更新が正常に機能しているかどうかを確認するために、プロセスのドライランを行います。
$ sudo certbot renew --dry-runエラーが表示されなければ、すべて設定完了です。証明書は自動的に更新されます。
ステップ7 - OpenEMRのダウンロード
OpenEMRのダウンロードページにアクセスし、最新バージョンのOpenEMRのリンクを取得します。OpenEMRをサーバーにダウンロードします。
$ wget https://sourceforge.net/projects/openemr/files/OpenEMR%20Current/7.0.1/openemr-7.0.1.tar.gzファイルを抽出します。
$ tar -pxzf openemr-7.0.1.tar.gz/var/www/htmlディレクトリを作成します。
$ sudo mkdir /var/wwww/html -p抽出したファイルをWebディレクトリに移動します。
$ sudo mv openemr-7.0.1 /var/www/html/openemrWebルートディレクトリに対してNginxユーザーに権限を与えます。
$ sudo chown -R nginx:nginx /var/www/html/openemrステップ8 - PHP-FPMの設定
/etc/php/8.2/fpm/pool.d/www.confファイルを開きます。
$ sudo nano /etc/php/8.2/fpm/pool.d/www.confPHPプロセスのUnixユーザー/グループをnginxに設定する必要があります。ファイル内のuser=www-dataおよびgroup=www-data行を見つけて、nginxに変更します。
...
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
; RPM: apache user chosen to provide access to the same directories as httpd
user = nginx
; RPM: Keep a group allowed to write in log dir.
group = nginx
...listen.owner = www-dataおよびlisten.group = www-data行を見つけて、nginxに変更します。
; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions. The owner
; and group can be specified either by name or by their numeric IDs.
; Default Values: user and group are set as the running user
; mode is set to 0660
listen.owner = nginx
listen.group = nginxファイルを保存するには、Ctrl + Xを押し、プロンプトが表示されたらYを入力します。 PHP-FPMとPHP-CLIの実行時間を60秒に増やします。
$ sudo sed -i 's/max_execution_time = 30/max_execution_time = 60/' /etc/php/8.2/fpm/php.ini変数max_input_timeの値を1に設定します。
$ sudo sed -i 's/max_input_time = 60/max_input_time = -1/' /etc/php/8.2/fpm/php.iniPHP-FPMのメモリ制限を128MBから512MBに増やします。
$ sudo sed -i 's/memory_limit = 128M/memory_limit = 512M/' /etc/php/8.2/fpm/php.iniファイルアップロードサイズを30MBに増やします。
$ sudo sed -i 's/post_max_size = 8M/post_max_size = 30M/' /etc/php/8.2/fpm/php.ini
$ sudo sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 30M/' /etc/php/8.2/fpm/php.ini最大入力変数の数を3000に増やします。
$ sudo sed -i 's/;max_input_vars = 1000/max_input_vars = 3000/g' /etc/php/8.2/fpm/php.iniPHPの観点から、LOAD DATAステートメントでローカルファイルにアクセスできるようにします。
$ sudo sed -i 's/;mysqli.allow_local_infile = On/mysqli.allow_local_infile = On/g' /etc/php/8.2/fpm/php.iniPHP-FPMサービスを再起動します。
$ sudo systemctl restart php8.2-fpmPHPセッションディレクトリのグループをNginxに変更します。
$ sudo chgrp -R nginx /var/lib/php/sessionsステップ9 - Nginxの設定
/etc/nginx/conf.d/openemr.confファイルを作成して開きます。
$ sudo nano /etc/nginx/conf.d/openemr.conf以下のコードを貼り付けます。
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name openemr.example.com;
access_log /var/log/nginx/openemr.access.log;
error_log /var/log/nginx/openemr.error.log;
# SSL
ssl_certificate /etc/letsencrypt/live/openemr.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/openemr.example.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/openemr.example.com/chain.pem;
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:50m;
ssl_session_tickets off;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_ecdh_curve X25519:prime256v1:secp384r1:secp521r1;
ssl_stapling on;
ssl_stapling_verify on;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
# use https://blog.cloudflare.com/announcing-1111 Cloudfare+Apnic labs, It is free and secure
resolver 1.1.1.1 1.0.0.1 [2606:4700:4700::1111] [2606:4700:4700::1001] valid=300s;
root /var/www/html/openemr;
index index.php;
location / {
try_files $uri $uri/ /index.php;
}
# Pass PHP Scripts To FastCGI Server
location ~* \.php$ {
try_files $uri =404;
fastcgi_index index.php;
fastcgi_pass unix:/run/php/php8.2-fpm.sock; # Depends On The PHP Version
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
include fastcgi_params;
}
# deny access to writable files/directories
location ~* ^/sites/*/(documents|edi|era) {
deny all;
return 404;
}
# deny access to certain directories
location ~* ^/(contrib|tests) {
deny all;
return 404;
}
# Alternatively all access to these files can be denied
location ~* ^/(admin|setup|acl_setup|acl_upgrade|sl_convert|sql_upgrade|gacl/setup|ippf_upgrade|sql_patch)\.php {
deny all;
return 404;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
log_not_found off;
access_log off;
}
location ~ \. {
deny all;
}
}
# enforce HTTPS
server {
listen 80;
listen [::]:80;
server_name openemr.example.com;
return 301 https://$host$request_uri;
}Nginx設定で使用されるルートディレクトリは/var/www/html/wallabag/public/であることに注意してください。
ファイルを保存するには、Ctrl + Xを押し、プロンプトが表示されたらYを入力します。 /etc/nginx/nginx.confファイルを開いて編集します。
$ sudo nano /etc/nginx/nginx.confinclude /etc/nginx/conf.d/*.conf;の前に次の行を追加します。
server_names_hash_bucket_size 64;ファイルを保存するには、Ctrl + Xを押し、プロンプトが表示されたらYを入力します。 Nginx設定ファイルの構文を確認します。
$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successfulNginxサービスを再起動します。
$ sudo systemctl restart nginxステップ10 - OpenEMRのインストール
ブラウザでURL https://openemr.example.comを開くと、次のセットアップ画面が表示されます。
ここではファイルの権限をチェックし、ステップ1に進むことができるかどうかを確認します。緑色のreadyという言葉が表示されている場合は、進むことができます。青いボタンをクリックしてステップ1に進みます。
次のページでは、インストーラーにデータベースを作成させるか、事前に作成したものを使用するかを尋ねられます。I have already created the databaseオプションを選択し、ステップ2に進むためのボタンをクリックします。
次のページでは、前のステップ4で設定したデータベースの資格情報を入力します。また、管理者アカウントの資格情報も入力します。ユーザー名は12文字以上である必要があります。そうでない場合、エラーが表示されます。ここで二要素認証(2FA)を有効にできますが、インストール後に設定することをお勧めします。データベースとユーザーアカウントを作成するためのボタンをクリックします。
次のページではインストール状況が表示され、ユーザー名とパスワードが表示されます。ステップ4に進むためのボタンをクリックします。
次のページでは、php.iniファイルからの推奨値と現在の値がリストされます。現在の値が要件を満たしていることを確認してください。インストーラーは、理由もなくmax_input_timeおよびmax_execution_time変数の誤った値を表示しますが、これらは無視できます。現在の値を確認するには、次のコマンドを使用できます。 満足したら、ステップ5に進むためのボタンをクリックします。
次のステップでは、Apacheサーバーの設定がリストされますが、Nginxサーバーを使用しているため無視します。次のページに進むためのボタンをクリックします。
ここでは管理パネルのテーマを選択するように求められます。Keep Currentオプションを選択し、次に進むためのボタンをクリックします。管理パネルから後でテーマを変更できますが、どのように見えるかは確認できません。インストーラーページから選択すると、選択する前にどのように見えるかを確認できます。デフォルトテーマを使用します。
最後のページには、ソフトウェアとアカウント資格情報に関する最終的な注意事項が表示されます。Startボタンをクリックしてログインページを開きます。
OpenEMRの登録ポップアップが表示され、サイトからの通知を受け取ることができます。無視して資格情報を入力し、Loginボタンをクリックしてダッシュボードにアクセスします。
インストール中に二要素認証を設定しなかった場合は、右上のアバターアイコンをクリックし、MFA Managementオプションを選択して設定します。
次のページで、ドロップダウンメニューから認証方法を選択し、設定を開始します。
ここからOpenEMRを使用して健康ビジネスを管理できます。
結論
これで、Ubuntu 22.04サーバーにOpenEMRをインストールするチュートリアルは終了です。質問がある場合は、下のコメントに投稿してください。
新しい投稿を受信箱で受け取る
スパムはありません。いつでも購読を解除できます。