Installing Unifi Controller on a Raspberry Pi in 5 min

I have some smart products at home and one of the things I wanted to do is read out the connected WiFi devices. To do this I need to Unifi Controller to be running 24/7, 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 this article, I will help you installing the Unifi Controller on the Raspberry Pi step-by-step in 5 minutes.

To get started you need a Raspberry 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.

Part list

Step 1 – Getting the Raspberry Pi up and running

The easiest way to install Raspbian on the Pi is by using Noobs and connect the Pi to your TV and wire connected it to the internet. First, we have to prepare the SDCard by formatting it using the SD Association’s Formatting 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

Once the SD Card is prepped 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 an 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 your 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

Step 2 – Connecting with SSH

To make working on the Raspberry Pi a bit easier, so we don’t need to plug in a keyboard and screen every time, let’s enable SSH. This way we can work on it from our computer 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 a 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 router’s 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 a 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.

Step 3 – Installing the Unifi Controller on the Raspberry Pi

  1. All Linux distros come 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:
  2. 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:
  3. Then we can add the key to our Raspberry Pi
  4. We now have added the software to our list of available software and have the ability to check its authenticity. So let’s download the software and install the Unifi Controller on the Raspberry Pi together with the required Java software.
  5. 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 waste resources of our Pi, so we get rid of it:
  6. The only step left is to reboot the Pi
Unifi Controller Raspberry Pi

Wrapping up

After the reboot, you can log in 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 on how to optimize your controller or how to add the access points.

Keeping the Unifi Controller up to date

It’s important to keep your network products up-to-date. New firmware contains important security fixes, fixes bugs in the software and can enhance the performance of a device. Check out this post on how to update the Unifi Controller and signup to the newsletter. I will drop you an email when there is a new version available!

See also:

Get more stuff like this

IT, Office365, Smart Home, PowerShell and Blogging Tips

I hate spam to, so you can unsubscribe at any time.

Comments

  1. I have followed så many guides to install Unifi controller on Raspberry. They all work, but the controller allways stops working after some time. Needs to be restartet daily. After some time its completely broken and you need to start all over reinstalling everything. I have done this fve times now 🙁

    I guess Raspberry Pi cant handle this?

  2. Thanks a bunch, really useful guide you have there, especially for someone thats new to the command line like me.

    However, I did encounter an error whereby I was not able to update after adding the key. Error message as below:

    [email protected]:~ $ sudo apt-get update
    Hit:1 http://archive.raspberrypi.org/debian stretch InRelease
    Hit:2 http://raspbian.raspberrypi.org/raspbian stretch InRelease
    Get:3 http://www.unbt.com/downloads/unifi/debian stable InRelease
    Err:3 http://www.unbt.com/downloads/unifi/debian stable InRelease
    Clearsigned file isn’t valid, got ‘NOSPLIT’ (does the network require authentication?)
    Fetched 59 B in 1s (29 B/s)
    Reading package lists… Done
    E: Failed to fetch http://www.unbt.com/downloads/unifi/debian/dists/stable/InRelease Clearsigned file isn’t valid, got ‘NOSPLIT’ (does the network require authentication?)
    E: Some index files failed to download. They have been ignored, or old ones used instead.

    Any idea how to go about this?
    Thanks again!

  3. You can simplify installation somewhat and avoid cluttering up your Pi with openjdk by rearranging the command order:

    echo ‘deb http://www.ubnt.com/downloads/unifi/debian stable ubiquiti’ | sudo tee -a /etc/apt/sources.list.d/100-ubnt.list > /dev/null
    sudo apt-get -y install dirmngr
    sudo apt-key adv –keyserver keyserver.ubuntu.com –recv 06E85760C0A52C50
    sudo apt-get update
    sudo apt-get install unifi oracle-java8-jdk -y
    sudo systemctl stop mongodb
    sudo systemctl disable mongodb
    sudo reboot

    Apt happily resolves the dependencies of the unifi package and allows installation without grabbing the full openjdk package.

  4. Is it possible to install the Unifi Video controller software as well into the PI along side the Unifi controller software?

  5. Brilliant article thank you!!! Worked perfect first time and saved me alot of typing (by using SSH putty paste) and alot of possible hassle since I am no Linux pro whatsoever (I am an IT Windows guy). I did a for more updates and upgrades than in your article just because but also your command to update the firmware – brilliant.

  6. Thanks for sharing. I followed all the steps and everything seems going fine up to the last step, except that when I go the IP address of the Raspberry, port 8443, it shows a blank page and there’s an error logged in the browser console:

    Uncaught Error: [$injector:modulerr] Failed to instantiate module app-unifi-wizard due to:

    Error: [$injector:nomod] Module ‘app-unifi-wizard’ is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

    Never had a similar issue?

    • In this case I would just reboot and run the install and update steps again. Just to be sure you have the latest versions.

      First try update only:
      sudo apt-get update && sudo apt-get upgrade -y

      Run the install again:
      sudo apt-get install unifi -y

      Of nothing works, then format the SD and start over.

          • Just updating and installing didin’t work, I repeated all the steps except for the initial ones, as I directly flashed a Raspbian Lite image to the SSD (instead of using NOOBS). It initially gave me the same error, but after a few minutes it worked fine, showing the wizard. I’m not sure if it could have worked even the first time, if I only had waited a few more minutes.

  7. I agree great guide. Easy to follow. Thanks a lot.

    Just one thing: to enable SSH in raspi-config you have to go to “Interfacing Options” not “Advanced Options”.

    And don’t forget to do updates!

Leave a Comment