Open-EMR v7.0.3 Print

  • 0

Last Updated: 31 August 2025
Applies to: Ubuntu 24.04 LTS (fresh server recommended)
Skill Level: Intermediate to Advanced


Overview

This guide explains how to manually install OpenEMR on a fresh Ubuntu 24.04 VPS, including Apache, MariaDB, PHP configuration, SSL setup, and OpenEMR database preparation.


Prerequisites

Before starting, have the following ready:

  • Ubuntu 24.04 VPS with root access
  • A domain name pointing to your VPS IP
  • The following details:
Variable Example Value Description
VERSION rel-7.0.3 OpenEMR version/tag from GitHub
SITE_NAME ehr.example.com Domain for OpenEMR
MARIADB_ROOT_PASSWORD StrongRootPass MariaDB root password
OPENEMR_DB_USER openemruser Database username for OpenEMR
OPENEMR_DB_PASS StrongDBPass Password for OpenEMR DB user
OPENEMR_ADMIN_USER admin OpenEMR Administrator username
OPENEMR_ADMIN_PASS StrongAdminPass OpenEMR Administrator password

---

Step 1: Prepare Server

Remove apt locks

sudo fuser -k /var/lib/dpkg/lock-frontend || true
sudo rm -f /var/lib/dpkg/lock-frontend /var/lib/dpkg/lock
sudo dpkg --configure -a || true

Update and upgrade packages

sudo apt update
sudo apt dist-upgrade -y

Step 2: Install Required Packages

sudo apt install -y apache2 mariadb-server mariadb-client \
php php-mysql php-cli php-gd php-curl php-xml php-zip php-mbstring \
php-soap php-intl php-bcmath php-readline php-opcache php-fileinfo \
php-tokenizer php-exif php-iconv php-apcu git unzip composer nodejs npm \
python3-pymysql

Step 3: Configure MariaDB

sudo mysql -u root <

(Replace MARIADB_ROOT_PASSWORD)

Create OpenEMR DB user and database

sudo mysql -u root -pMARIADB_ROOT_PASSWORD <

(Replace placeholders accordingly, e.g., SITE_NAME_DB = site_name with dots replaced by underscores)


Step 4: Download OpenEMR

sudo mkdir -p /var/www/SITE_NAME
sudo chown www-data:www-data /var/www/SITE_NAME
sudo git clone --branch VERSION https://github.com/openemr/openemr.git /var/www/SITE_NAME

Step 5: Install Dependencies

cd /var/www/SITE_NAME
sudo chown -R www-data:www-data .
sudo -u www-data composer install --no-dev
sudo -u www-data npm install
sudo -u www-data npm run build

Step 6: Import OpenEMR Database

If you have a pre-prepared openemrdb.sql file:

mysql -u root -pMARIADB_ROOT_PASSWORD SITE_NAME_DB < /path/to/openemrdb.sql

Step 7: Configure Apache

Create Virtual Host

sudo tee /etc/apache2/sites-available/SITE_NAME.conf > /dev/null <
    ServerName SITE_NAME
    DocumentRoot /var/www/SITE_NAME
    
        Options FollowSymLinks
        AllowOverride All
        Require all granted
    

EOL

Enable site and modules

sudo a2dissite 000-default.conf
sudo a2enmod rewrite
sudo a2ensite SITE_NAME.conf

Step 8: Enable SSL

sudo apt install -y certbot python3-certbot-apache
sudo certbot --apache -d SITE_NAME --non-interactive --agree-tos -m admin@SITE_NAME

If Let's Encrypt fails, create a self-signed certificate:

sudo mkdir -p /etc/letsencrypt/live/SITE_NAME
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout /etc/letsencrypt/live/SITE_NAME/privkey.pem \
-out /etc/letsencrypt/live/SITE_NAME/fullchain.pem \
-subj "/C=ZA/ST=NA/L=NA/O=Sive/CN=SITE_NAME"

Step 9: Configure PHP for OpenEMR

sudo sed -i 's/^max_input_vars.*/max_input_vars = 6000/' /etc/php/8.3/apache2/php.ini
sudo sed -i 's/^max_execution_time.*/max_execution_time = 60/' /etc/php/8.3/apache2/php.ini
sudo sed -i 's/^max_input_time.*/max_input_time = -1/' /etc/php/8.3/apache2/php.ini
sudo sed -i 's/^post_max_size.*/post_max_size = 300M/' /etc/php/8.3/apache2/php.ini
sudo sed -i 's/^memory_limit.*/memory_limit = 512M/' /etc/php/8.3/apache2/php.ini
sudo sed -i 's/^upload_max_filesize.*/upload_max_filesize = 300M/' /etc/php/8.3/apache2/php.ini

Step 10: Finalize and Restart Apache

sudo systemctl restart apache2

Login to OpenEMR

Visit:

https://SITE_NAME

Login with:

  • Username: OPENEMR_ADMIN_USER
  • Password: OPENEMR_ADMIN_PASS

Notes

  • Use a fresh VPS to avoid conflicts.
  • Secure your credentials.
  • After install, configure backups and security settings.

Was this answer helpful?
Back