How to Install Consul on Ubuntu 24.04

Estimated reading: 2 minutes 14 views

Introduction

Consul by HashiCorp is a powerful tool for service discovery, configuration, and orchestration in distributed systems. This guide shows you how to install and configure Consul on an Ubuntu 24.04 server.


Step 1: Update Your System

Run the commands below to make sure your system packages are up to date:

sudo apt update
sudo apt upgrade -y


Step 2: Install Required Packages

Install dependencies needed for Consul:

sudo apt install -y gnupg software-properties-common unzip wget


Step 3: Download Consul

Download the latest stable Consul release (replace version if newer available):

wget https://releases.hashicorp.com/consul/1.15.0/consul_1.15.0_linux_amd64.zip

 


Step 4: Install Consul

Unzip and move the Consul binary to /usr/local/bin:

unzip consul_1.15.0_linux_amd64.zip
sudo mv consul /usr/local/bin/

Verify Consul is installed:

consul --version


Step 5: Create Consul User and Directories

Create a dedicated user and directories for Consul:

sudo useradd --system --home /etc/consul.d --shell /bin/false consul 
sudo mkdir -p /opt/consul 
sudo mkdir -p /etc/consul.d 
sudo chown -R consul:consul /opt/consul /etc/consul.d /usr/local/bin/consul


Step 6: Create Consul Configuration File

Create a basic Consul config file with UI enabled:

sudo nano /etc/consul.d/consul.hcl

Add the following content:

data_dir = "/opt/consul"
client_addr = "0.0.0.0"
bind_addr = "127.0.0.1"
advertise_addr = "127.0.0.1"
server = true
bootstrap_expect = 1
ui = true

Save and exit the editor.


Step 7: Create Systemd Service for Consul

Create a systemd service file:

sudo nano /etc/systemd/system/consul.service

Add:

[Unit]
Description=Consul Service
Documentation=https://www.consul.io/docs
After=network.target

[Service]
ExecStart=/usr/local/bin/consul agent -bind=127.0.0.1 -config-dir=/etc/consul.d
User=consul
Group=consul
Restart=on-failure
LimitNOFILE=65536
LimitNPROC=65536

[Install]
WantedBy=multi-user.target

Save and close the file.


Step 8: Start and Enable Consul Service

Reload systemd, start Consul, and enable it on boot:

sudo systemctl daemon-reload
sudo systemctl start consul
sudo systemctl enable consul

Check status:

sudo systemctl status consul


Step 9: Access the Consul Web UI

Open your browser and visit:

http://your_server_ip:8500

You should see the Consul dashboard.


Conclusion

Consul is now installed and running on your Ubuntu 24.04 server. You can use it to manage service discovery, configuration, and more in your infrastructure.

Share this Doc

How to Install Consul on Ubuntu 24.04

Or copy link

CONTENTS