How to Install HedgeDoc on Elementary OS Latest

HedgeDoc (formerly known as HackMD) is an open-source, collaborative markdown editor that is designed to facilitate note-taking and writing tasks. In this tutorial, we will guide you through the installation process of HedgeDoc on Elementary OS Latest.

Prerequisites

Before we begin, make sure you have the following prerequisites:

Step 1 - Update and Upgrade System Packages

Before we install any new packages, let's update and upgrade our system packages to ensure that we have the latest version available.

Type the following command in your terminal emulator to update and upgrade the system packages:

sudo apt update
sudo apt upgrade -y

Step 2 - Install Node.js

HedgeDoc requires Node.js to run. To install Node.js, execute the following commands one by one in your terminal:

curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get update
sudo apt-get install -y nodejs

Verify that Node.js is installed by typing node -v in your terminal emulator. If Node.js is successfully installed, you should see the version of Node.js printed on the screen.

Step 3 - Install PostgreSQL

HedgeDoc requires a relational database management system (RDBMS) to store its data, and PostgreSQL is the recommended RDBMS for HedgeDoc. To install PostgreSQL, execute the following command in your terminal emulator:

sudo apt-get install postgresql postgresql-client -y

PostgreSQL is now installed on your system. We will configure it in the next step.

Step 4 - Configure PostgreSQL

By default, PostgreSQL only allows local connections. To allow remote connections and create a new database and user for HedgeDoc, follow these steps:

  1. Change the authentication method used by PostgreSQL:

    sudo nano /etc/postgresql/13/main/pg_hba.conf
    
  2. Replace peer with md5 for the following two lines under IPv4 local connections:

    # "local" is for Unix domain socket connections only
    local   all             all                                     md5
    # IPv4 local connections:
    host    all             all             127.0.0.1/32            md5
    
  3. Restart the PostgreSQL service:

    sudo systemctl restart postgresql
    
  4. Login to the PostgreSQL interactive terminal:

    sudo su postgres
    psql
    
  5. Create a new user and database for HedgeDoc:

    CREATE USER hedge WITH PASSWORD 'your-password';
    CREATE DATABASE hedgedoc WITH OWNER hedge;
    

    Replace your-password with a strong password of your choice.

  6. Quit the PostgreSQL interactive terminal:

    \q
    exit
    

Step 5 - Install HedgeDoc

Now that we have installed and configured all the necessary prerequisites, we can finally install HedgeDoc. Follow these steps:

  1. Clone the HedgeDoc repository:

    git clone https://github.com/hedgedoc/hedgedoc.git
    
  2. Navigate to the cloned repository:

    cd hedgedoc/
    
  3. Install the dependencies:

    npm install
    
  4. Copy the sample config file:

    cp .env.sample .env
    
  5. Edit the .env file:

    nano .env
    

    Update the following configuration options:

    DATABASE_URL=postgresql://hedge:your-password@localhost/hedgedoc
    ENVIRONMENT=production
    

    Replace your-password with the password you chose in Step 4. Save your changes and exit.

  6. Build the app:

    npm run build
    
  7. Start the app:

    NODE_ENV=production npm start
    

    If everything was successful, you should see a message letting you know that the HedgeDoc server has started.

Step 6 - Access HedgeDoc

By default, HedgeDoc will listen on port 3000. To access HedgeDoc from a web browser, navigate to http://your-server-ip:3000 (replacing your-server-ip with the IP address of your Elementary OS Latest machine).

You should now have a working installation of HedgeDoc. Enjoy collaborative markdown editing!

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!