How To Install Unifi Controller On A Raspberry Pi

UniFi is a range of networking equipment made by Ubiquiti, with various models of routers, switches, WAPs (wireless access points), security cameras, VoIP phones, and more!

The UniFi range sits between enterprise-grade and more cost-effective home networking equipment. It offers users more flexibility and features but lacks the expense and complexity of true enterprise solutions.

In this article, we cover everything you need to know to learn how to install the UniFi Controller on the Raspberry Pi, and have created a step-by-step process for you to follow.

How To Install Unifi Controller On A Raspberry Pi

What You Need Before You Get Started

Optional Things To Make Your Life Easier

How To Install UniFi Controller On A Raspberry Pi

Follow this in-depth but simple and step-by-step guide to installing the UniFi controller on your Raspberry Pi and you will be up and running in no time!

Part 1 – Preparing The Raspberry Pi For The UniFi Controller

1. Make sure the Raspberry Pi is running all the correct, up-to-date packages. Update all the packages with this command:

sudo apt update and sudo apt upgrade.

2. Install rng-tools to improve the UniFi controller software startup speed. This package will be utilized:

sudo apt install rng-tools

3. The rng-tools configuration needs to be changed slightly. Start editing by running this command:

sudo nano /etc/default/rng-tools-debian

4. Inside this file, find this line #HRNGDEVICE=/dev/hwrng and replace it with: #HRNGDEVICE=/dev/hwrng

5. After the change has been made, you will need to save the file. Do this by pressing CTRL + X then Y, followed by ENTER

6. Restart the rng-tools service. Do this by running this command:

sudo systemctl restart rng-tools

7. After the service has completed the restarting process, it should be safe enough to continue onto the next section (part 2).

Part 2 – Raspberry Pi Bullseye Extra Steps

There’s a good chance that you will run into some issues with the mongodb package when trying to install the UniFi controller.

It may say that the package is unavailable. You can work around this issue by adding the old stretch repository as a source, then pin it to ensure that it won’t take preference.

In an ideal world, mongodb will already be available from the official repository. However, we will need to work around the issue for the time being.

1. Create a preferences file for the apt package manager. Doing this will allow you to change the priority of the repository that you will be adding. Do this by doing this command:

sudo nano /etc/apt/preferences.d/99stretch-mongodb.pref

2. In this file, type in these lines next: #Never Prefer packages from Stretch

#Never Prefer packages from Stretch 
Package: * 
Pin: release n=stretch 
Pin-Priority: 1 

3. When the changes have been made, save and exit by pressing CTRL + X then Y, followed by ENTER

4. The preferences file has now been created, and we can add the repository that includes mongodb.

Before this, we will need to download the GPG key for the Raspbian repository. This will aid in the authentication of the packages that belong to that repository.

5. Download the key to your own Raspberry Pi via this command in the terminal:

curl -L | gpg --dearmor | sudo tee /usr/share/keyrings/raspbian-archive-keyring.gpg >/dev/null

6. Now the older Raspbian repository can be added to the sources list. Create a file called “stretch_mongodb.list” within the “/etc/apt/sources.list.d/” directory.

7. Use the following command to add the repository directly into the file:

echo "deb [signed-by=/usr/share/keyrings/raspbian-archive-keyring.gpg] stretch main" | sudo tee /etc/apt/sources.list.d/stretch_mongodb.list

8. Now, you will need to update the package list. Simply input this command to do so:

sudo apt update 
Install Unifi Controller On A Raspberry Pi

Part 3 – Installing The UniFi Controller

Now, we are going to need to install the UniFi Controller! Follow the steps laid out below to do this easily.

1. First, we will need to add the UniFi repository to the sources list. Do this by typing in the following command:

echo 'deb [signed-by=/usr/share/keyrings/ubiquiti-archive-keyring.gpg] stable ubiquiti' | sudo tee /etc/apt/sources.list.d/100-ubnt-unifi.list

2. Add the repositories GPG key. Use this command to do it:

curl | sudo tee /usr/share/keyrings/ubiquiti-archive-keyring.gpg >/dev/null

3. Update the repository by running this command: sudo apt update

4. Now you can install version 9 of the OpenJDK runtime. Do this using this command:

sudo apt install openjdk-8-jre-headless unifi

Part 4 – Booting The UniFi Controller On The Raspberry Pi

This section will focus on all the important initial configuration that you will need to do, step by step. Let’s go through what you need to know:

  1. The first thing you are going to need to do is to retrieve Your Raspberry Pi’s local IP address. You can use the following command if you have terminal access to the PI: hostname -I
  2. Once you have your Raspberry’s IP address at hand, you will need to go to this web address in the browser of your choosing: https://[IPADDRESS] :8443
  3. Don’t worry if you run into a certificate error, as you already know which device you are connecting to.
  4. Name your Raspberry Pi powered UniFi controller, agree to the terms and conditions, and end-user license agreement, then click the checkbox. Click “next”.
  5. Now, you need to sign in to your Ubiquiti account or register at the official Ubiquiti website. After this is done, click “next”.
  6. Make any changes to the settings page so that it suits your needs, and you are happy with it. Once done, click “next”.
  7. Connect your Pi UniFi Network controller to any of the other devices on the network, then click “next”.
  8. Name your new Wi-Fi network and give it a strong password to make it secure. Once this has been done, click “next”.
  9. On the last screen, you will see all of your settings and be able to review them. Make sure that you set the country and timezone before you do anything else.
  10. Once necessary changes have been made, click “finish”.
  11. You’re done!
buy raspberry pi accessories

Final Thoughts

You should now be all set up and ready to go! Hopefully you found this article useful and can now use your devices as you hope.

To get more of a look at setting up the UniFi controller on a Raspberry Pi, check out the video below by the guys over at CrazyLogic.

Erik D

Leave a Comment

Your email address will not be published. Required fields are marked *

Hey! I'm Pi Bot. Need a hand?
AI Chatbot Avatar
⚠️ This is still experimental. Raspians is not held accountable for any answers you may receive. Pi Bot's knowledgebase only goes as far as 2021. While he can definitely be helpful, just be aware that he may also say some crazy stuff and be off the mark sometimes - so play around, have fun, experiment and don't always take him at his word!