Installing Unifi Controller on a Raspberry Pi in 5 min
I have some domotica stuff at home and one of things I wanted to do is readout the connected WiFi devices. So I needed a device to run the Unifi Controller on, something small, cheap and with low running costs. That’s where the Raspberry Pi comes in.
In the guide below I will explain how you can install and run the Unifi Controller on a Raspberry Pi. To get start you need a Pi of course and install Raspbian (lite) on it. We will be using Noobs for the installation and run Raspbian Lite on it to save resources. (we don’t need the desktop 😉 )
What do we need?
To get started you need some items. If you already have a Raspberry Pi you can skip this part and continue on installing Raspbian or straight through installing the Unifi Controller. I had a Pi 1 Model B lying around, which is working fine. But if you have to buy one, get yourself a Pi 3 Model B.
- Raspberry Pi Model 3
- Power Supply
- 16Gb Micro Sd card with adapter
- HDMI Cable
- Mouse and keyboard
- Or the complete package
Getting the Raspberry Pi up and running
The most easy way to install Raspbian on the Pi is by using Noobs and connect the Pi to you TV and wire connected it to the internet. First we have to prepare the SDCard by formatting it using the SD Association’s Formating tool
- Download the SD Memory Card formatter from SDCard.org
- Install the SD Card formatter and start it up
- Insert the SD Card in your computer and do a quick format
One the SD Card is prept we can download and unpack Noobs Lite on it. Noobs lite requires the Pi to be connected with the internet. If that is not an option for you, just download Noobs (which is a online and offline installer).
- Download Noobs Lite from Raspberrypi.org
- Extract all the files to the formatted SDcard
Now it’s time to install the Pi:
- Insert the SD card in the Pi
- Make sure the keyboard (and optional mouse) is connected
- Plugin the HDMI cable to you monitor or TV
- Connect to power
Noobs will start up and let you choose which OS you want to install. Because we are only using the CLI, we can pick Raspbian lite to save resources of the Pi. When completed the Pi will reboot and will ask you to login:
Connecting with SSH
To make working on the Pi a bit easier, so we don’t need to plugin a keyboard and screen every time, lets enable SSH. This way we can work on it from our Desktop remotely:
Type the following command to open the settings page:
- Select Advanced options
- Scroll down to SSH and press enter to enable it
- When down press ESC to exit the settings page.
Settings a static ip address
By default the Pi is using DHCP to get an Ip address. This means that a reboot can cause it to get a new Ip address, which will make it hard to manage it with SSH or to open the Unifi Controller.
So we are going to set an static Ip Address on the network interface:
- First let’s check what the current address is, type:
In the result below you will see eth0 and in that block inet: 192.168.x.x. This is the current ip address.
- Type: sudo nano /etc/dhcpcd.conf to edit the config file
- Enable to following lines by remove the # from it and set ip address to a fixed valueIn this case we set the ip address to 192.168.1.210 and the address of the internet router is 192.168.1.1. You also need to set the domain_name_servers, by default entering the routers address is enough.123456#Static IP configuration:interface eth0static ip_address=192.168.1.210/24#static ip6_address=fd51:42f8:caae:d92e::ff/64static routers=192.168.1.1static domain_name_servers=192.168.1.1 18.104.22.168 fd51:42f8:caae:d92e::1
Which ip address should you pick? If you don’t know your network layout, keep the first 3 parts of the address the same and choose value between the 200 and 240 at the end.
- When done save and close the file by pressing ctrl + x and choose Y to save it.
- Now we need to restart the network interface to apply to new settings:12sudo ifconfig eth0 down <enter>sudo ifconfig eth0 up <enter>
Connecting to the Pi with SSH
So we are now ready to remotely manage the Raspberry Pi over SSH. You will need a client for this, I suggest Putty is the best tool for the job.
- Download Putty
- After installing Putty start it and enter the Ip Address from you Pi in the address bar.
- Click on Open, the prompt will ask you to login (pi and raspberry)
You can unplug your Tv now, so the rest of the family can use it. We will be working with Putty for the rest of the installation.
Updating you Raspberry
The last step before we can begin to install the Unifi Controller, make sure the Raspberry it up-to-date. First we will update the firmware:
sudo apt-get install rpi-update && echo Y | sudo rpi-update
This may take a while, just sit back and grep a coffee.
When done we will update Raspbian:
sudo apt-get update && sudo apt-get upgrade -y
When complete we can start with the next step, installing the controller.
Installing the Unifi Controller on the Raspberry Pi
Because we are using Raspbian Lite we need to make sure that the Oracle Java SDK is installed:
sudo apt-get -y install oracle-java8-jdk
All Linux distros comes with a source list, repository, of available packages to install. Unifi Controller is not listed in the default repositories, so we need to add it first:
echo 'deb http://www.ubnt.com/downloads/unifi/debian stable ubiquiti' | sudo tee -a /etc/apt/sources.list.d/100-ubnt.list > /dev/null
To install the Unifi Controller software we need to authenticate the software that it’s the real software from Ubiquiti. This is done by validating a key with the key server.
First we need to install a certificate management service:
sudo apt-get -y install dirmngr
Then we can add the key to our Raspberry Pi
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 06E85760C0A52C50
We now have added the software to our list of available software and have the ability to check its authenticity. So lets download the software and install the Unifi Controller on the Raspberry Pi
sudo apt-get update
sudo apt-get install unifi -y
The installation may take a couple of minutes to complete. When done we need to remove the default database that comes with MongoDb instance. This would only waist resources of our Pi, so we get rid of it:
sudo systemctl stop mongodb
sudo systemctl disable mongodb
Only step left is to reboot the Pi
After the reboot you can login to the Raspberry Pi with your browser. Goto the Ip address you set earlier:
The setup wizard page will be displayed allowing you the create a new site or restore a backup. Check this post on some tips how to optimize your controller or how to add the access points.