LazyAdmin

Tips from an other Admin

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 ūüėČ )

Contents

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.

Part list

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

  1. Download the SD Memory Card formatter from SDCard.org
  2. Install the SD Card formatter and start it up
  3. 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).

  1. Download Noobs Lite from Raspberrypi.org
  2. Raspberry Pi install NoobsExtract all the files to the formatted SDcard

Now it’s time to install the Pi:

  1. Insert the SD card in the Pi
  2. Make sure the keyboard (and optional mouse) is connected
  3. Plugin the HDMI cable to you monitor or TV
  4. 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:

Username: pi
Password: raspberry

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:

  1. First let’s check what the current address is, type: ifconfig In the result below you will see eth0 and in that block inet: 192.168.x.x. This is the current ip address.
    Set static ip address on Raspberry Pi
  2. Type:  sudo nano /etc/dhcpcd.conf  to edit the config file
  3. Enable to following lines by remove the # from it and set ip address to a fixed value
    In 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.

    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.

  4. When done save and close the file by pressing ctrl + x and choose Y to save it.
  5. Now we need to restart the network interface to apply to new settings:

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.

  1. Download Putty
  2. After installing Putty start it and enter the Ip Address from you Pi in the address bar.
  3. 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:

This may take a while, just sit back and grep a coffee.
When done we will update Raspbian:

When complete we can start with the next step, installing the controller.

Unifi Controller on Raspberry Pi

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:

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:

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:

Then we can add the key to our Raspberry Pi

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

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:

Only step left is to reboot the Pi

Wrapping up

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.