How to Install OpenEMR on CentOS and Rocky Linux

OpenEMR is the world’s leading open-source electronic medical record (EMR) and medical documentation system. OpenEMR aims to provide a better alternative to its proprietary competitors. It is secure, customizable, scalable, feature-rich, and designed to meet the needs of small to large healthcare organizations.

It has been used in over 200 countries/territories worldwide since 2002. The information below will help you better understand OpenEMR.

OpenEMR is used in well over 200 countries/territories worldwide in both small and large healthcare organizations, including hundreds of thousands of individual users in many parts of the United States. The latest data shows there are currently ~10 million patient encounters annually, up significantly from only 2 million patients five years ago.

There are many good reasons to choose OpenEMR as your medical records system, including:

  • It can be downloaded and installed locally in minutes.
  • It supports all US federal privacy laws (HIPAA) including HIPAA audit logging.
  • It has strong community support by an international developer team, thousands of contributors, hundreds of translators, tens of thousands of users, and hundreds of organizations.
  • It is scalable from small to very large healthcare organizations.
  • It has a responsive mobile web interface that can be used on almost all mobile devices, including iPhones, Android phones and tablets, Windows Mobile devices, and Blackberry smartphones.
  • There is no software licensing fees or annual service contracts required for OpenEMR installations because OpenEMR is open-source software.

This guide will walk you through downloading and installing OpenEMR. These instructions have been tested and work perfectly with CentOS 7 and 8 and Rocky Linux 8 and 9.


  • A fresh installation of an RHEL-based Linux distribution like AlmaLinux, RockyLinux or CentOS with root user access.
  • Ability to use the command-line interface (CLI) through SSH or monitor directly on the machine.

Step 1: Updating the OS

Yum is the default package manager tool in CentOS. On Rocky Linux, replace yum with dnf in the commands below. We need to update the system using the yum command before downloading and installing OpenEMR.

sudo yum update

Type Y and hit Enter when prompted.

Yum will now update all packages and dependencies, which may take a few minutes, depending on your internet connection speed.

Step 2: Installing Apache Web Server

Apache, informally known as Apache Web Server, this free and open-source cross-platform web server software was developed and maintained by the Apache Software Foundation, which is based in San Francisco.

Apache is a powerful and flexible HTTP server, notable for running in a high-performance mode on UNIX platforms by using an event-driven and threaded architecture with a low memory footprint.

This section will show you how to install the Apache Web Server in CentOS. If you already have Apache installed in your system, then skip to Step 3 below.

First, run the following command to update the local Apache httpd package index.

sudo yum update httpd

Next, install the Apache Web Server using the following command line.

sudo yum install httpd

This command will install your system’s latest version of Apache Web Server.

To check the status of your installation, run the service command using sudo.

sudo systemctl status httpd

The result should look something like this.

Install Apache web server

If the Apache service is not running, use the following command to start Apache Web Server.

sudo systemctl start httpd

To enable Apache Web Service at system boots, run the following command.

sudo systemctl enable httpd

The Apache service is up and running. However, the best way to test the server is to request a page from another computer on the network.

To do this, type your server IP address in a web browser on a different machine.


Where: server_IP_address is the actual IP address of the server. For example, to access your Apache installation using the IP address, you would type in your browser window on another computer. You should see the Apache default page similar to the screenshot below.

Web server is working fine

Step 3: Installing MariaDB

MariaDB is a derivative of the MySQL relational database management system created by the MySQL community to remain free forever. It is a robust, scalable, and reliable SQL server with rich features, including but not limited to virtual columns, triggers, stored procedures, and views.

Using the yum command, this section will help install and configure MariaDB on CentOS. MariaDB is available from the default CentOS software repositories, so there is no need for extra repositories or third-party sites.

You can install MariaDB Server by running the following command

sudo yum install mariadb-server

Once the installation is complete, please run the following command to start the MariaDB service and make it automatically start up at system boots.

sudo systemctl start mariadb
sudo systemctl enable mariadb

To secure your installation of MariaDB/MySQL, run the mysql_secure_installation command to set a root password, remove anonymous user accounts and disable remote root logins.


Enter Y when prompted to continue. You will first be asked to enter the current MariaDB root password, which is blank by default, so press Enter. Type Y and hit Enter again when prompted to remove anonymous users, as it is insecure unless enabled through the configuration file. Finally, type Y and hit Enter again if you are prompted to Disallow root login remotely, as it is insecure unless enabled through the configuration file.

Configure MariaDB

To access the MariaDB shell and run commands, log in to your server using SSH or open a command-line terminal on your CentOS desktop. Type the following command.

mysql -u root -p

Enter your root password when prompted.

MariaDB command prompt

Now that we have successfully installed MariaDB, let’s install PHP.

Step 4: Installing PHP

PHP is a server-side scripting language designed for web development but also used as a general-purpose programming language. There are lots of high-quality PHP frameworks and CMS that you can use with ease, such as Laravel, Phalcon, Joomla, WordPress , etc. This section will show you how to install PHP and some required modules for OpenEMR on CentOS using the YUM package manager.

To install PHP open up your terminal, run the following command.

sudo yum install php
sudo yum install php-common php-mysqlnd php-gd php-mcrypt php-cli php-curl php-opcache

After the installation is complete, type the following command into the terminal to restart the Apache Web Server,

sudo systemctl restart httpd.service

We will create a phpinfo() file in the Apache root directory to test the PHP installation.

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

Open your web browser and navigate to the URL http://server_IP_address/info.php, you should see a page similar to below screenshot after phpinfo() is successfully displayed.


For security reasons, displaying the phpinfo() file on the web server is not recommended as it provides important server and PHP settings. To disable it, delete the info.php file we just created after the testing is done.

Step 5: Creating a Database for OpenEMR

OpenEMR needs a database backend before it can be used. This section will show you how to create a MariaDB database for OpenEMR using the MariaDB shell.

mysql -u root -p

Enter your MariaDB password when prompted. Now let’s create a new database called openemr with UTF-8 encoding.


Next, we will create a new user called openemr-user to manage the database. Replace [email protected] with your desired password.

CREATE USER 'openemr-user'@'localhost' IDENTIFIED BY '<[email protected]>';

From now on, we will use this new user to manage the database. Grant privileges to the newly created user to manage all databases with GRANT statement.

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

Now, reload the grant tables using FLUSH PRIVILEGES command.


At this stage, you have successfully created a MariaDB database and user for OpenEMR. You can now exit out of the MariaDB shell using the following command.


Create database

Step 6: Downloading OpenEMR

In this step, we will download the OpenEMR zip file, extract the zip file, and change some ownership for the OpenEMR files.

sudo yum install wget -y


tar xvzf openemr*.tar.gz

mv openemr-6.0.0 /var/www/html/openemr

chown -R apache:apache /var/www/html/openemr

chmod 666 /var/www/html/openemr/sites/default/sqlconf.php

Step 7: Installing OpenEMR

Now that we have all the required elements to start running OpenEMR, let’s run the installation using the web browser.

Open your web browser, navigate to http://server_IP_address/openemr, and see a page like the screenshot below. Click Proceed to Step 1 button.

Directory permissions

You will be taken to the Select Database Setup page, select I have already created the database radio button, and click Proceed to Step 2 button.

Database already created

On the Database and OpenEMR Initial User Setup Details page, fill in all the details like Login Name and Password. Select the Enable 2FA checkbox if you’d like to use this option for the Initial User. Click on Create DB and User at the bottom left.

Create DB and user

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 the Proceed to Step 4 button.

First user created

You will be taken to Step 4 – Creating and Configuring Access Control List screen. Keep the default and click Proceed to Step 5 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.

In this step, we will proceed to configure the Apache Web Server for OpenEMR.

Now, return to your terminal, 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

Next, 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 "/var/www/html/openemr/sites">
AllowOverride None

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

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.

Configure PHP

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.

Configure Apache web server

Choose theme

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.

Installation successful

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

Login to OpenEMR

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

OpenEMR Dashboard

The OpenEMR installation will now be complete.


This guide taught you how to install OpenEMR on an RHEL-based system. For more information about OpenEMR, please visit its official website.