Install on Ubuntu
This guide was last updated for Ubuntu 24.04, although it should work for most recent versions.
Prerequisites
- Ubuntu 24.04
- Allow SSH access
- Allow HTTP and HTTPS access
- Public IP address for Lets Encrypt SSL certificate
- At least 4 GB of RAM
- At least 4 GB of disk space
Install PostgreSQL
These Postgres installation steps can be skipped if you've already installed Postgres, or are using a database hosted elsewhere. Medplum server can be configured to connect to remote databases. We'll discuss how to connect to a remote Postgres server below.
Add the PostgreSQL Apt Repository (see PostgreSQL Apt Repository docs)
# Configure the Apt repository
sudo apt install -y postgresql-common
sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
# Install Postgres 16
sudo apt install postgresql-16 postgresql-client-16
Start Postgres
sudo pg_ctlcluster 16 main start
Start Postgres client
sudo -u postgres psql
Create a "medplum" user:
CREATE USER medplum WITH PASSWORD 'medplum';
Create a "medplum" database:
CREATE DATABASE medplum;
GRANT ALL PRIVILEGES ON DATABASE medplum TO medplum;
\c medplum
GRANT ALL ON SCHEMA public TO medplum;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO medplum;
Exit psql
exit
Install Redis
sudo apt-get install redis-server
Open the Redis config file
sudo vi /etc/redis/redis.conf
Uncomment the "requirepass" line and set a password
requirepass medplum
Restart Redis
sudo systemctl restart redis-server
Install Node.js
Add the Node.js v22.x Ubuntu repository:
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo bash -
Install Node.js
sudo apt-get install nodejs
Install Nginx
Install Nginx and Certbot:
sudo apt-get install nginx certbot python3-certbot-nginx
Start Nginx:
sudo systemctl start nginx
sudo systemctl enable nginx
Before setting up SSL, make sure your domains point to your server's IP address. There should be two DNS entries, one for app
and one for api
. For example, app.example.com
and api.example.com
. Please refer to your DNS provider's documentation for more information.
Get SSL certificates from Let's Encrypt for both domains:
sudo certbot --nginx -d app.example.com
sudo certbot --nginx -d api.example.com
Install Medplum
Add the Medplum Ubuntu repository:
curl -fsSL https://apt.medplum.com/setup.sh | sudo bash -
sudo apt-get update
Install Medplum:
sudo apt-get install medplum
Start Medplum:
sudo systemctl start medplum
Enable the sites
Enable the site:
sudo ln -s /etc/nginx/sites-available/medplum-app /etc/nginx/sites-enabled/
sudo ln -s /etc/nginx/sites-available/medplum-server /etc/nginx/sites-enabled/
Remove the default site:
sudo rm /etc/nginx/sites-enabled/default
Test the configuration:
sudo nginx -t
If the test is successful, reload Nginx:
sudo systemctl reload nginx
Verify the setup
You should now be able to view the API server healthcheck at https://api.example.com/healthcheck
And the app at https://app.example.com
Admin Commands
Check service status:
systemctl status medplum
Start service:
sudo systemctl start medplum
Stop service:
sudo systemctl stop medplum
Restart service:
sudo systemctl restart medplum
Check logs:
journalctl -u medplum
Force reinstall:
sudo apt-get install --reinstall medplum
Additional Configuration
The Medplum server configuration is located at /etc/medplum/medplum.config.json
. You can edit this file to change the server configuration. After editing the file, restart the Medplum service:
sudo systemctl restart medplum
See Config Settings for full details on Medplum configuration settings.