How to Install OpenEMR Medical Office Workflow Software on Ubuntu 20.04

A medical office’s workflow can be a tangled mess of electronic documents, including insurance forms and appointments. In order to streamline the process for both patients and staff members, it is necessary that they have access to efficient software - which offers all necessities from scheduling weeks in advance with no reminders around receptionists’ availability slots or how much inventory each pharmacy has on hand at any given moment.

Are you looking for a medical practice that can fit your needs? Many options are available, including proprietary software. However, there is another option: open source solutions. The OpenEMR project offers an easy way to get started with this type of digital health innovation.

In this guide, we will walk you through the process of installing OpenEMR on an Ubuntu Server 20.04.

Prerequisites

  • To make the most out of this tutorial, you will need to have access to an Ubuntu Server running version 20.04. If you do not have one at your disposal but still wish to follow along with the installation procedure, you can always create a virtual machine using VirtualBox or any other virtualization software that supports Linux guest machines.
  • You will also need to have root access to the virtual machine. Or non-root user account with sudo privileges.
  • In addition to this, you will also need to have a fully qualified domain name pointing on your server.

Step 1: Updating the System

Before we begin, we need to ensure that our system is up-to-date and contains all of the most recent software versions.

Running the following command to update your system.

sudo apt update && sudo apt upgrade -y

This will install any updates that might be available for Ubuntu 20.04 Server.

Step 2: Installing Apache

The next step is to install the webserver. We will choose Apache as our web server since it is one of the most widely used web servers available. Apache has a nice set of features, including support for the HTTP/2 protocol, which allows faster page loading.

Running the following command to install Apache o Ubuntu 20.04

sudo apt install apache2 apache2-utils

When prompted whether to continue, type Y and hit ENTER.

Update Ubuntu

The installation process should take some time, depending on the internet speed of the server.

Once this installation is complete, we need to enable the Apache modules that are required for LAMP (Linux-Apache-MariaDB-PHP) to work.

sudo systemctl start apache2

Run the following command to start Apache automatically at system boots.

sudo systemctl enable apache2

To ensure that Apache is up and running, you can run the following command.

sudo systemctl status apache2

If everything is set up correctly, you should see a result similar to the one below.

Install Apache web server and check its status

Step 3. Installing MariaDB

In this step, we will install the MariaDB server. This is a relational database management system that works alongside PHP to provide a standard MySQL installation that can be accessed by other programs and scripts.

We can install MariaDB by running the following command.

sudo apt install software-properties-common mariadb-server mariadb-client

When prompted whether to continue, type Y and hit ENTER.

Once MariaDB is installed, we need to run the following command to start the database server.

After MariaDB has been installed. We need to start the database server by running the following command

sudo systemctl start mariadb

We now need to configure MariaDB to start automatically whenever the operating system boots up. We can do this by running the following command.

sudo systemctl enable mariadb

If we need to stop the server, we can do this by running the following command.

sudo systemctl stop mariadb

You can also check that the service is running. You run the following command.

sudo systemctl status mariadb

If everything is set up correctly, you should see a result similar to the one below.

MariaDB server online

Step 4: Installing PHP

Now that we have Apache and MariaDB installed, we will need to install PHP. In web development, PHP is a widely used scripting language that is mainly used for server-side scripting, but it may also be used for making modifications to the front-end of a website.

We will install PHP and some extra modules required by OpenEMR.

sudo apt-get install php
sudo apt-get install php libapache2-mod-php php-mysql php-mbstring php-xml

Once this installation has been completed, we need to restart Apache so that it can load in the new PHP modules.

sudo systemctl restart apache2

In order to test the PHP installation, we will create a file named info.php and place it in the document root directory.

echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php

Now, if you point your browser to the IP Address of your server, you should see a PHP information page.

PHP version information

Step 5: Creating a Database for OpenEMR

In this step, we will create a database and user account for OpenEMR.

First, we will log in to MariaDB as the root user.

mysql -u root -p

You will be prompted to enter the root password. Enter the password and hit Enter. Once you log into the MariaDB shell, you can create a database for OpenEMR by running the following command.

CREATE DATABASE openemr;

This will create a new database called openemr. We will now create a user for this database.

CREATE USER 'openemr-user'@'localhost' IDENTIFIED BY '<$trongp@ss>';

This will create a user and password for OpenEMR to log in with. Replace $trongp@ss with a secure password.

We now need to grant all privileges to the openemr-user on the openemr database we just created.

GRANT ALL PRIVILEGES ON openemr.* TO 'openemr-user'@'localhost';

Now we need to run a FLUSH PRIVILEGES command so that the privileges table is updated.

FLUSH PRIVILEGES;

Exit the MariaDB shell by typing the following command.

exit;

Step 6: Downloading OpenEMR

Now we will download, extract the downloaded zip file, and move the extracted file to the web root directory.

sudo apt install wget
wget https://downloads.sourceforge.net/project/openemr/OpenEMR%20Current/5.0.2.1/openemr-5.0.2.tar.gz
tar xvzf openemr*.tar.gz
mv openemr-5.0.2 /var/www/html/openemr5

Once this is done, we want to change ownership of all the files in the OpenEMR directory to www-data. We also need to change the permissions of the sqlconf.php file in the OpenEMR directory.

chown -R www-data:www-data /var/www/html/openemr
chmod 666 /var/www/html/openemr/sites/default/sqlconf.php

Step 7: Installing OpenEMR

Now all that is left to do is run the installer. You need to open your web browser and navigate to the IP Address of your server, followed by /openemr.

http://SERVER_IP/openemr

You will be taken to the Pre Install - Checking File and Directory Permissions screen. Click on the Proceed to Step 1 button.

Check system prerequisites for OpenEMR

You will now be taken to Step 1 - Select Database Setup screen. Click on the I have already created the database radio button, and click Proceed to Step 2 to continue.

In Step 2 - Database and OpenEMR Initial User Setup Details screen, we need to provide the username and password, database name and host, database port, and database type, as shown below.

Database settings

Select the Enable 2FA checkbox if you’d like to enable two-factor authentication for this user.

Once you fill in all the details, click on the Create DB and User button.

2FA auth

Wait for the next page to load. Please be patient. This page will check to see whether the user and database have been successfully created. When the page is fully loaded, click Proceed to Step 4 button.

Create database user

You will be taken to Step 4 - Creating and Configuring Access Control List screen. Keep the default and click Proceed to Step 6 button.

Create ACL

You will be taken to Step 5 - Configure PHP screen. This page tells you how to set up your Apache Web Server for OpenEMR.

We will now proceed to configure the Apache Web Server for OpenEMR.Return to your terminal and, using your favorite text editor, create a new configuration file called openemr.conf in the apache directory.

sudo nano /etc/apache2/sites-available/openemr.conf

Now, populate the file with the following lines. Remember to save and exit the file when you are done.

<Directory "/var/www/html/openemr">
AllowOverride FileInfo
Require all granted
</Directory>

<Directory "/var/www/html/openemr/sites">
AllowOverride None
</Directory>

<Directory "/var/www/html/openemr/sites/*/documents">
Require all denied
</Directory>

Next, run the following command to restart the Apache service.

sudo systemctl restart apache2

Once you have done all the steps above, return to your browser and click on the Proceed to Step 6 button.

OpenEMR Setup

On the next page, click Proceed to Select a Theme button. When you are done choosing a theme for your OpenEMR, click on Proceed to Final Step.

Choose a theme

Final installation step

Finally, a confirmation page appears, which shows all details regarding your OpenEMR installation. Click on the Click here to start using OpenEMR at the bottom left.

OpenEMR installed successfully

You will be taken to the login page. Provide your username password and click on Login.

Login

Once the authentication has been successful, you will be taken to the OpenEMR dashboard.

OpenEMR

The OpenEMR installation will now be complete.

Conclusion

In this guide, you have successfully installed and configured OpenEMR on your ubuntu 20,04 server.

For more information on how to use OpenEMR, please visit the official documentation page.