How to Install OpenEMR on Debian 12

Introduction

OpenEMR is a free and open-source electronic health records and medical practice management software. This guide will walk you through the process of installing OpenEMR manually and using Ansible on Debian 12.

Prerequisites

Before you begin, ensure you have:

  1. A Debian 12 server or desktop system
  2. Root or sudo privileges

Manual Installation

Step 1: Install Dependencies

Update the package index and install required dependencies:

sudo apt update
sudo apt install -y apache2 mariadb-server php php-mysql libapache2-mod-php php-gd php-xml php-mbstring php-json php-zip php-bcmath php-curl unzip

Step 2: Download OpenEMR

Download the latest OpenEMR release from the official website or GitHub repository.

Step 3: Extract OpenEMR

Extract the downloaded OpenEMR archive:

unzip openemr-X.Y.Z.zip

Replace X.Y.Z with the version number.

Step 4: Configure Apache

Copy the extracted OpenEMR files to the Apache document root:

sudo cp -r openemr-X.Y.Z /var/www/html/openemr

Change the ownership of the OpenEMR directory:

sudo chown -R www-data:www-data /var/www/html/openemr

Step 5: Configure MySQL

Create a MySQL database and user for OpenEMR:

sudo mysql -u root -p
CREATE DATABASE openemr;
CREATE USER 'openemruser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON openemr.* TO 'openemruser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Step 6: Complete Installation

Access OpenEMR in your web browser and follow the on-screen instructions to complete the installation.

Ansible Installation

Step 1: Install Ansible

Install Ansible on your local machine:

sudo apt update
sudo apt install -y ansible

Step 2: Create Ansible Playbook

Create a playbook to install OpenEMR:

nano install_openemr.yml

Add the following content to the playbook:

---
- hosts: all
  become: true
  tasks:
    - name: Install dependencies
      apt:
        name: "{{ item }}"
        state: present
      with_items:
        - apache2
        - mariadb-server
        - php
        - php-mysql
        - libapache2-mod-php
        - php-gd
        - php-xml
        - php-mbstring
        - php-json
        - php-zip
        - php-bcmath
        - php-curl
        - unzip

    - name: Download OpenEMR
      get_url:
        url: "https://github.com/openemr/openemr/releases/download/vX.Y.Z/openemr-X.Y.Z.zip"
        dest: "/tmp/openemr-X.Y.Z.zip"

    - name: Extract OpenEMR
      unarchive:
        src: "/tmp/openemr-X.Y.Z.zip"
        dest: "/var/www/html/openemr"
        remote_src: yes
        creates: "/var/www/html/openemr"

    - name: Change ownership of OpenEMR directory
      file:
        path: "/var/www/html/openemr"
        owner: www-data
        group: www-data
        recurse: yes
        state: directory

Replace X.Y.Z with the desired OpenEMR version.

Step 3: Run Ansible Playbook

Run the Ansible playbook to install OpenEMR:

ansible-playbook install_openemr.yml -i localhost,

Conclusion

Congratulations! You have successfully installed OpenEMR on Debian 12 manually and using Ansible. You can now use OpenEMR for electronic health records and medical practice management.

Was this answer helpful? 0 Users Found This Useful (0 Votes)