With this tutorial, we will be showing you the process of installing the UniFi Controller on a Raspberry Pi
UniFi is a range of network devices created by Ubiquiti. These devices range from Wi-Fi access points to security gateways and switches.
Setting up the UniFi software on a Raspberry Pi is a fairly straightforward process as it just relies on the multi-platform Java runtime to run.
Using the UniFi network controller, you can manage all the UniFi devices that are a part of your network. You will also be able to use this dashboard to see the statistics of your UniFi network.
Please note that before proceeding you will need to be running a 64-bit version of Raspberry Pi OS for this tutorial to work. Recent changes to UniFi have broken support for 32-bit operating systems.
Below is a list of the equipment that you will need to set up the Unifi Network Controller software on your Raspberry Pi
This tutorial on setting up the UniFi Network Controller was tested on a Raspberry Pi 4 running the latest version of Raspberry Pi OS Bullseye 64-bit.
Preparing your Raspberry Pi for the UniFi Controller
In this section, we will prepare the operating system to run the UniFi software. These steps mainly revolve around getting the database server UniFi requires installed on your Raspberry Pi.
1. The first thing you should do is ensure that your Raspberry Pi is running up to date packages.
To update all packages, you will be required to run the following command.
sudo apt update sudo apt upgrade
Adding Entropy using rng-tools
2. To improve the startup speed of the UniFi controller software on our Raspberry Pi, we need to install
We will utilize this package to ensure the Raspberry Pi has enough entropy for the random number generation that the UniFi software uses.
sudo apt install rng-tools
3. We now need to make a slight change to the rng-tools configuration.
Begin editing the config file by running the following command.
sudo nano /etc/default/rng-tools-debian
4. Within this file, find and uncomment the following line.
By uncommenting this line, we are adding to the amount of entropy (The amount of randomness) that the system has available.
The Raspberry Pi features an integrated random number generator that we can utilize to increase the entropy pool.
5. Once you have made the change, save the file by pressing CTRL + X, then Y, followed by ENTER.
6. Finally, restart the
rng-tools service by running the command below.
sudo systemctl restart rng-tools
Once the service has finished restarting, it should now be safe to proceed to the next section of this guide.
Installing an Older Release of LibSSL
7. Due to the version of MongoDB that we will be utilizing, we will need to install an older release of LibSSL to our Raspberry Pi.
In particular, we will be installing LibSSL 1.0. You can download this old release by using the following command.
wget http://ports.ubuntu.com/pool/main/o/openssl/libssl1.0.0_1.0.2g-1ubuntu4_arm64.deb -O libssl1.0.deb
8. Once the package has been downloaded, all we need to do to install it is to run the command below.
sudo dpkg -i libssl1.0.deb
Installing MongoDB to your Raspberry Pi for the UniFi Controller
9. To use the UniFi Controller on your Raspberry Pi, we will need to install MongoDB.
This is the database server that UniFi uses to store all of its data. As we can’t rely on the package repository, we will need to follow some additional steps.
For this first step, we will download the latest available version of MongoDB 3.6 to our Pi. We are installing 3.6 as this is currently the only supported release for the UniFi Controller.
wget https://repo.mongodb.org/apt/ubuntu/dists/xenial/mongodb-org/3.6/multiverse/binary-arm64/mongodb-org-server_3.6.22_arm64.deb -O mongodb.deb
10. Once the package is downloaded, install it by using the following command within the terminal.
sudo dpkg -i mongodb.deb
11. Now that we have installed the MongoDB server, set it to start when your Raspberry Pi boots using the command below.
sudo systemctl enable mongod
12. Finally, start MongoDB by running the command shown below in the terminal.
This will start the server immediately, so we won’t have to wait till our device restarts.
sudo systemctl start mongod
Installing the UniFi Controller to the Raspberry Pi
1. Our first task is to add the UniFi repository to our sources list.
We can achieve this by running the command below.
echo 'deb [arch=armhf signed-by=/usr/share/keyrings/ubiquiti-archive-keyring.gpg] https://www.ui.com/downloads/unifi/debian stable ubiquiti' | sudo tee /etc/apt/sources.list.d/100-ubnt-unifi.list
2. We now need to add the repositories GPG key by using the following command.
curl https://dl.ui.com/unifi/unifi-repo.gpg | sudo tee /usr/share/keyrings/ubiquiti-archive-keyring.gpg >/dev/null
The GPG key is what helps tell the package manager it is downloading the correct package.
3. As we made changes to the repositories, we need to now update the package list by running the command below.
sudo apt update
4. Now finally, we can install version 8 of the OpenJDK runtime as well as the Unifi Controller software itself to our Raspberry Pi by running the following command.
sudo apt install openjdk-11-jre-headless unifi
Installing UniFi through this method will automatically set up a service. This service will automatically start the UniFi software at boot.
Additionally, we are installing version 11 of the Java runtime environment as it is currently the only version supported by the UniFi controller.
First Boot of the UniFi Controller on your Raspberry Pi
In this section, we are going to walk you through the initial configuration steps of the UniFi software.
1. First, retrieve the local IP address for your Raspberry Pi.
If you have terminal access to your Pi, you can use the following command.
2. With your Raspberry Pi’s IP address handy, go to the following web address in your favorite web browser.
If you run into a certificate error, it is safe to ignore it as we know what device we are connecting to.
3. The first step requires you to give a name for your Raspberry Pi powered UniFi controller (1.).
You are also required to agree to the end-user license agreement and terms of service from UniFi, once you have read through them, click the checkbox (2.).
Once all done, click the “Next” button (3.) to proceed.
4. Next, you will need to sign in to your Ubiquiti account (1.).
If you don’t already have an account, you can register at the Ubiquiti website.
Once you have entered your login details, proceed by clicking the “Next” button.
5. Tweak the settings on this page that best suits your needs.
Once configured, click the “Next” button.
6. Use this screen to connect your Pi UniFi Network controller to the devices on your network.
To proceed, click the “Next” button.
7. Now give your new Wi-Fi network a name and a password.
Once you have configured your WiFi details (1.), click the “Next” button to proceed (2.).
8. This final screen will get you to review all your settings.
You will also be able to use this screen to set both the country and timezone (1.). Make sure you set these before continuing.
Once you have verified everything is correct, you can now click the “Finish” button (2.) to finish the setup process.
7. At this point, you should now have successfully set up the UniFi network controller on your Raspberry Pi.
Hopefully, at this point in the tutorial, you will now have the UniFi controller installed and running on your Raspberry Pi.
The Pi is a great base for your network controller as it can run 24/7 with little power.
If you have run into any issues setting up the UniFi software, feel free to comment below.
Check out our many other Raspberry Pi tutorials to learn more about this versatile system.
Just wanna say you’re an absolute legend and the new script works amazingly on my new Pi. Thanks a million man – got a donation link?
I’m only using my Pi as a Unifi controller – so I was wondering if you have any tips for power consumption? Could I theoretically install your script on the lite version of 64bit Raspberry OS? I think that might use even less energy, right? Currently I’m just letting it run on the desktop version and pull out off the accessories after setup.
Really glad to hear that it has all worked out for you! Always a huge relief when a tutorial works fine for others. We don’t have a donation link but we do offer an ad-free subscription.
The Raspberry Pi isn’t super power hungry to begin with, but using Raspberry Pi OS Lite might help a little since it has significantly less packages/software set up on it from the get-go. The guide will work perfectly on the lite version of Raspberry Pi OS and that is how I typically test it out.
Will this new method work with the Raspberry Pi 3B which only has 1GB of ram or does 64 but OS/ Unifi Controller 7.4/ MongoDB 3.6 require more ram than that if so can you create a ram pool in the SD card?
The Unifi Controller should continue to work on your Raspberry Pi 3B even if it only has 1 GB of RAM. While there is a slight increase in RAM consumption moving from a 32-bit to 64-bit system it shouldn’t be large enough to make it unusable.
You can increase the size of the swap file to reduce the chance of running into out-of-memory errors. But please note that the swap is significantly slower than RAM.
hi @Emmet thank you for the prompt reply. I am pretty sure I have 64bit system installed by running `uname -m` gives me `Linux raspberrypi 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 GNU/Linux` however when I try to install arm64 packages I get an error “`package architecture (arm64) does not match system (armhf)
That error message would indicate that you are running a 32-bit release of Raspberry Pi OS so that is a little string.
If you run the following command within the terminal, what do you see?
You should see “arm64” if you are running the 64-bit flavor of Raspberry Pi OS.
Thanks so much! I was just in the middle of using the old one haha…
Will try to change my os to 64bit now… Any quick suggestions on how to do this?
Thanks so much!
The cleanest / quickest way to do this is to just flash the 64-bit version of Raspberry Pi OS instead of the 32-bit one.
I thank you for this tutorial.
I was able to install Unifi a few weeks ago without any problems. I’ve just tried again this morning but I get an error at the last stage (97%).
Could you help me ?
It looks like the Unifi team pushed a release that broke how the original tutorial worked. I have updated the tutorial to work now but you will need to be running a 64-bit operating system on your Raspberry Pi.
Please try the updated tutorial and let me know whether you are still running into issues.