How to install UniFi controller on Raspberry Pi 4



If you are a user of Ubiquity network devices, then this article is for you! Using my example, we will consider how to install a UniFi controller on a Raspberry Pi and see how convenient it is to use devices that are part of the same ecosystem.

UniFi devices are configured using the UniFi controller. Currently, controllers can be cloud (Official UniFi Hosting), hardware (UniFi CloudKey) and software. Since generating reports, logging, collecting statistics and other operations with devices require 24/7 access to the controller, installing it on a personal computer does not make sense. The Raspberry Pi 4 mini-computer will come to the rescue, which does not take up much space and can be placed next to the router.

In this article, I will describe step-by-step how to quickly and easily install a UniFi controller and give some caveats that can ruin all the work!

All subsequent commands will be executed in the terminal under superuser

1. Checking the operating system and updating it

Raspberry Pi 4 must have the latest version of Raspberry Pi OS 64 bit installed. Otherwise, you need to install the 64-bit version of the operating system.

uname -a

We get the following result

Linux raspberrypi 6.1.0-rpi7-rpi-v8 #1 SMP PREEMPT Debian 1:6.1.63-1+rpt1 (2023-11-24) aarch64 GNU/Linux

Next, you need to update the list of packages and install them using the following commands.

sudo apt-get update
sudo apt-get upgrade

2. Installing Java

The second step will be to install Java. The UniFi controller requires a Java version of at least 11, but we will install a more recent version – version 17.

sudo apt-get install openjdk-17-jdk

3. Installing MongoDB

The last preparatory stage will be the installation of the MongoDB service. There are also certain restrictions for the UniFi controller, namely the version must be at least 3.6 and no more than 5.0. Since the Raspberry Pi 4 is built on the ARM v8 architecture, the developer of MongoDB itself limited the use of the core.

Given the peculiarity of the architecture, the only working version of MongoDB is 4.4.18. All other versions will not start correctly, because the Unifi controller will not start as a result.

wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
ls -l /etc/apt/sources.list.d/
sudo apt-get update
sudo apt-get install -y mongodb-org=4.4.18 mongodb-org-server=4.4.18 mongodb-org-shell=4.4.18 mongodb-org-mongos=4.4.18 mongodb-org-tools=4.4.18

In order to prevent future updates of the operating system or MongoDB packages from being updated, the names of these packages must be added to the list of retained ones, i.e. so that they are not updated. The following command must be executed

sudo apt-mark hold mongodb-org mongodb-org-mongos mongodb-org-server mongodb-org-shell mongodb-org-tools

To check if everything is installed correctly, you need to start the service, activate it to start automatically after restarting the Raspberry Pi and finally check the status

sudo systemctl start mongod
sudo systemctl status mongod
sudo systemctl enable mongod

As you can see below, the service is active and running.

4. Installing Unifi software

To begin with, you need to download the distribution from the official website. In the firmware section, look for UniFi Network Application. At the time of writing this article, the latest version was 8.0.28, and we download it for Debian/Ubuntu.

By default, the file will be saved in the “Downloads” directory. Go to this directory and install the deb package using the following commands.

cd Downloads/
sudo dpkg -i unifi_sysvinit_all.deb

The installation will take a few minutes, after which you can check the status of the unifi service by executing the following command

sudo systemctl status unifi

As you can see below, the service is active and running.

● unifi.service - unifi
     Loaded: loaded (/lib/systemd/system/unifi.service; enabled; preset: enabled)
     Active: active (running) since Fri 2024-01-26 22:38:36 EET; 2 weeks 6 days ago
   Main PID: 75605 (java)
      Tasks: 120 (limit: 8734)
        CPU: 9h 7min 42.845s

5. Check Result

To check the result, you need to know the IP address used by the Raspberry Pi. To do this, you need to execute the command

hostname -I

The UniFi service is available at the same address on port 8443. To do this, enter the following in the browser line:

https://ip-address:8443

agree to the terms of the absence of a certificate, and after that the site will be displayed from the configuration page!