Installing the UniFi Controller on Ubuntu

This tutorial will show you how to install the Unifi controller to the Ubuntu operating system.

Ubuntu UniFi Controller

Ubiquiti offers an affordable lineup of robust mesh wireless access points, switches, cameras, and plenty more. Of all the products Ubiquiti offers, their network devices are one of the most popular.

To control all of the network devices and maintain an effective mesh network, they need something to control them. The software that manages all of this is called the UniFi network controller.

One of the best things about Ubiquiti is that they don’t force you to use their hardware to run the controller. Instead, you can install the UniFi network controller to any supported operating system such as Ubuntu.

Please note that you will run the following steps within the Ubuntu terminal. If you run a desktop flavor of Ubuntu, you can open the terminal quickly by pressing CTRL + ALT + T on your keyboard.

Installing the UniFi Controller on Ubuntu

This section will walk you through preparing your Ubuntu system to install the UniFi controller.

Over the next few steps, we will install the required software and add the official UniFi repository.

1. Before we get started, we will need to update the package list of the Ubuntu system.

The package list is a cache of all packages we can install and where apt can download them.

sudo apt update

2. Our first task is to install some packages we will rely on to add the package repositories we require as well as run the UniFi network controller.

Use the following command to install the “wget“, “gpg“, “openjdk-8-jre-headless“, and “havegd” packages to Ubuntu.

sudo apt install curl haveged gpg openjdk-8-jre-headless
  • curl – We will be using curl to download the GPG keys for both MongoDB and the UniFi controller to Ubuntu.
  • haveged – This package allows us to generate extra entropy that the UniFi controller needs during startup to help guarantee security.
  • gpg – We need to ensure this package is installed as we will need to “dearmor” the MongoDB GPG key before we save it to our system.
  • openjdk-8-jre-headless – As the UniFi controller is built upon Java we will need to install the java runtime environment. At the time of publishing UniFi still relies on Java 8.

Adding the UniFi Repository to Ubuntu

3. Our first step is to download the UniFi GPG key to our system. This key helps tell the package manager that the packages are valid and have been signed by the repository.

Download this key to your system using the following command within the terminal.

curl https://dl.ui.com/unifi/unifi-repo.gpg | sudo tee /usr/share/keyrings/ubiquiti-archive-keyring.gpg >/dev/null

4. With the UniFi GPG key saved to our Ubuntu device, we can now add the repository to our sources list.

Adding UniFi to the “apt” sources list is as straightforward as using the following command.

echo 'deb [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 > /dev/null

Adding the MongoDB Repository

5. With the UniFi repository added to our Ubuntu system, we can move on to adding the one for MongoDB 3.6.

Before adding the MongoDB repository, our first step is to download its GPG key using the command below.

curl https://pgp.mongodb.com/server-3.6.asc | sudo gpg --dearmor | sudo tee /usr/share/keyrings/mongodb-org-server-3.6-archive-keyring.gpg >/dev/null

6. Once the GPG key has been added, our next step is to add the MongoDB 3.6 repository to our Ubuntu device.

As the UniFi controller relies on an older version of MongoDB, we can’t just rely on a version provided through the Ubuntu repository.

Use the command below in your terminal to add the MongoDB 3.6 repository to the sources list on your system.

echo 'deb [signed-by=/usr/share/keyrings/mongodb-org-server-3.6-archive-keyring.gpg] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/3.6 multiverse' | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list > /dev/null

Installing MongoDB 3.6 to Ubuntu

7. As we changed our sources list, we will need to perform a package list update.

If we don’t perform an update, the apt package manager won’t be aware of any of our newly added repositories.

sudo apt update

8. We can now install the final piece of software we require to install and run the UniFi controller on Ubuntu.

This final piece of software is called “MongoDB” and is the database server that UniFi requires.

You can install the MongoDB server to Ubuntu by running the command below in the terminal.

sudo apt install -y mongodb-org-server

9. After installing MongoDB, we want to ensure that its service is enabled to start at boot.

Run the command below to ensure that the MongoDB server is set to start at boot.

sudo systemctl enable mongod

10. Finally, we can ensure that the MongoDB server is running by using the following command in the terminal.

This command will start up MongoDB on your Ubuntu device immediately.

sudo systemctl start mongod

Installing the UniFi Network Controller

11. Finally, now that everything is in place, we can install the UniFi controller to Ubuntu by using the following command.

With this command, the apt package manager will download UniFi from the official repository that we added in an earlier step.

sudo apt install unifi

12. At this point, you will finally have the UniFi controller up and running on your Ubuntu device.

Over the next section we will show you how to access this interface and go through the initial setup steps.

Using the UniFi Controller Web Interface

Within this section, we will be showing you how to access your freshly installed UniFi controller’s web interface.

The following steps should work fine in whatever web browser you choose to utilize.

Accessing the Ubuntu UniFi Controller

1. Before we continue, you will need to know the IP address of your Ubuntu device.

One of the easiest ways to get the IP address assigned to the device is to utilize the hostname command as shown below.

hostname -I

2. With the IP address in hand, you will want to go to the following address in your favorite web browser.

Make sure that you replace “IPADDRESS” with the IP of your device. From this, you can see that the UniFi controller will operate its web interface on port 8443.

https://IPADDRESS:8443

First Run of the UniFi Controller

3. After heading to the UniFi controller for the first time, you will be greeted by the following screen.

For these first steps, you must assign your Ubuntu UniFi controller a name (1.).

Next, to utilize this controller, you will be required to agree to the Ubiquiti end-user license agreement and their terms of service.

Once you have read through both documents and agree to them, click the checkbox (2.)

Finally, to proceed with the setup steps, you will need to click the “Next” button (3.).

Setting the UniFi Network Controller Name on Ubuntu

4. To proceed further you will need to log in to your Ubiquiti account (1.).

If you don’t have an account, you must register for one by going to the official Ubiquiti website.

With your login details entered, click the “Next” button (2.).

Sign into Ubiquiti Account

5. You will be asked if you want to configure any basic options for your UniFi Network controller on Ubuntu.

The only option available to us during setup was the “Enable Auto Backup” option (1.).

When you are happy with your chosen options, click the “Next” button to proceed (2.).

Basic network config settings

6. At this point, if you have any Ubiquiti network devices awaiting adoption (1.), you will get the chance to adopt them to your network controller.

Once you are ready, you can proceed through the setup process by clicking the “Next” button (2.).

Devices Ready to adopt

7. You can now configure the Wi-Fi network that the UniFi network controller will create on any of your attached network devices.

At this point, you can enter an SSID and password for your network (1.). However, it is possible to skip this process.

In the bottom-right of the page, you will see both the “Skip” and “Next” options (2.). Click the appropiate option to proceed.

WiFi Settings

8. Before the setup process is complete, you will get a chance to review all of the options you just configured (1.).

Additionally, you can also set the country/territory and timezone (2.) for the UniFi network controller to utilize on your Ubuntu system.

If you are happy with everything, you can click the “Finish” button (3.) to complete the setup.

Review UniFi Network Controller Settings

9. You should now have the UniFi network controller successfully installed on your Ubuntu system.

If you haven’t yet adopted any network devices, you will end up with a screen similar to the one shown below.

Unifi Controller running

Conclusion

Throughout this tutorial, we have shown you how you can install and run the UniFi network controller on Ubuntu.

The UniFi controller allows you to easily control all of your Ubiquiti network devices from one central interface.

Please comment below if you have questions about running the UniFi controller on Ubuntu.

Be sure to check out our many other Ubuntu tutorials. Alternatively, we have plenty of general Linux guides that are well worth a read.

3 Comments

  1. Avatar for Jon
    Jon on

    Thanks Emmet! Much appreciated again!! Long live Mongo

    [URLSNIPPED]

  2. Avatar for Jon
    Jon on

    Thanks a ton for posting this! Very helpful. Almost there, but getting the errors

    _______

    $ sudo apt install unifi
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    Some packages could not be installed. This may mean that you have
    requested an impossible situation or if you are using the unstable
    distribution that some required packages have not yet been created
    or been moved out of Incoming.
    The following information may help resolve the situation:
    
    The following packages have unmet dependencies:
     unifi : depends: mongodb-server (< 1:4.0.0) but it is not installable or
                      mongodb-10gen (< 4.0.0) but it is not installable or
                      mongodb-org-server (< 4.0.0) but 6.0.2 is to be installed
    E: Unable to correct problems, you have held broken packages.

    ——————

    Have confirmed Mongo is installed and running (and reinstalled) Also getting a notificating during apt update

    —————

    Hit:2 http://security.ubuntu.com/ubuntu jammy-security InRelease
    Hit:1 https://dl.ubnt.com/unifi/debian stable InRelease                      
    Hit:3 http://ca.archive.ubuntu.com/ubuntu jammy InRelease                      
    Hit:4 http://ca.archive.ubuntu.com/ubuntu jammy-updates InRelease
    Hit:5 http://ca.archive.ubuntu.com/ubuntu jammy-backports InRelease
    Ign:6 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/3.6 InRelease
    Ign:7 https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 InRelease
    Hit:8 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/3.6 Release
    Hit:10 https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 Release
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    All packages are up to date.
    W: https://repo.mongodb.org/apt/ubuntu/dists/focal/mongodb-org/6.0/Release.gpg: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.

    ——–

    Any thoughts are greatly appreciated.

    thanks again!

    1. Avatar for Emmet
      Emmet on
      Editor

      Hi Jon,

      It looks like you have a newer version of MongoDB installed (6.0) on your Ubuntu system.

      The problem here is that the UniFi controller relies on a much older version of MongoDB (3.6). I am not aware if you are actually able to run two versions of MongoDB alongside each other.

      The only solution would be to uninstall MongoDB 6.0 from your system and remove the repository providing that version of MongoDB.

      Cheers,
      Emmet

Leave a Reply

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