Install UniFi Controller on Ubuntu 18.04 / Debian 9

Posted on 133 views

In this article we provide the steps for installing UniFi Network Application / UniFi Controller on Ubuntu 18.04 / Debian 9 Linux system. Ubiquiti offers a wide range of Access Points, Switches, Firewall devices, Routers, Cameras, among many other appliances which are managed from a single point. The commonly used management interface is provided by UniFi Dream Machine Pro.

The UniFi Network Application (formerly UniFi Controller), is a wireless network management software solution from Ubiquiti Networks™. This tools provides the capability to manage multiple UniFI networks devices from a web browser. UniFi Network Application can be installed on Windows, macOS and Linux operating systems. In the guide that we did earlier, we covered installation process on macOS:

For running in Docker see guide in the link below:

Below are the installation requirements for UniFi Network Application;

  • A DHCP-enabled network
  • Linux, Mac OS X, or Microsoft Windows 7/8 – Running controller software.
  • Java Runtime Environment 8
  • Web Browser: Mozilla Firefox, Google Chrome, or Microsoft Internet Explorer 8 (or above)

For UniFi Network Application installation on Linux, supported operating systems as of this article update are;

  • Ubuntu 18.04 and 16.04
  • Debian 9 / Debian 8

Software versions requirements:

  • Java 8 (My test with Java 17 and Java 11 failed).
  • MongoDB <=4.0, but >=3.6 (We’ll install MongoDB 4.0)

Before you proceed further query OS details through contents in /etc/os-release file to ensure OS version requirement is met.

$ cat /etc/os-release
NAME="Ubuntu"
VERSION="18.04.6 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.6 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

From the output we can see this installation is on Ubuntu 18.04 (Bionic Beaver), which is supported.

Add UniFi and MongoDB APT repositories

It’s always a good recommendation to keep your system updated. Run the commands below to update your OS.

sudo apt update && sudo apt -y full-upgrade

After the update perform a reboot if it’s required.

[ -f /var/run/reboot-required ] && sudo reboot -f

Install software packages required to configure UniFi and MongoDB APT repositories.

sudo apt install curl gpg gnupg2 software-properties-common apt-transport-https lsb-release ca-certificates

Add UniFi APT repository

Import repository GPG key used in signing UniFi APT packages.

sudo wget -O /etc/apt/trusted.gpg.d/unifi-repo.gpg https://dl.ui.com/unifi/unifi-repo.gpg 

Add UniFi APT repository by executing commands below in your terminal.

echo 'deb https://www.ui.com/downloads/unifi/debian stable ubiquiti' | sudo tee /etc/apt/sources.list.d/ubnt-unifi.list

Add MongoDB APT repository

Start by adding GPG key to your system keyring.

wget -qO - https://www.mongodb.org/static/pgp/server-4.0.asc | sudo apt-key add -

You should get a message in the output that says “OK” if this was successful. Next add repository to your system.

### Ubuntu 18.04 ###
echo "deb https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list

### Debian 9 ###
echo "deb https://repo.mongodb.org/apt/debian stretch/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list

Once all the repositories have beed added, test if they are functional.

### Ubuntu 18.04 ###
$ sudo apt update
Get:1 http://mirrors.digitalocean.com/ubuntu bionic InRelease [242 kB]
Ign:2 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 InRelease
Hit:3 https://repos-droplet.digitalocean.com/apt/droplet-agent main InRelease
Get:4 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 Release [2989 B]
Hit:6 http://mirrors.digitalocean.com/ubuntu bionic-updates InRelease
Hit:7 http://security.ubuntu.com/ubuntu bionic-security InRelease
Get:8 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 Release.gpg [801 B]
Hit:9 http://mirrors.digitalocean.com/ubuntu bionic-backports InRelease
Get:5 https://dl.ubnt.com/unifi/debian stable InRelease [3038 B]
Get:10 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0/multiverse amd64 Packages [18.4 kB]
Get:11 https://dl.ubnt.com/unifi/debian stable/ubiquiti amd64 Packages [732 B]
Fetched 268 kB in 1s (319 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done

### Debian 9 ###
$ sudo apt update
Hit:1 http://security.debian.org stretch/updates InRelease
Ign:2 http://mirrors.digitalocean.com/debian stretch InRelease
Hit:3 http://mirrors.digitalocean.com/debian stretch-updates InRelease
Hit:4 http://mirrors.digitalocean.com/debian stretch Release
Ign:5 https://repo.mongodb.org/apt/debian stretch/mongodb-org/4.0 InRelease
Hit:6 https://repos-droplet.digitalocean.com/apt/droplet-agent main InRelease
Get:8 https://repo.mongodb.org/apt/debian stretch/mongodb-org/4.0 Release [1490 B]
Get:9 https://repo.mongodb.org/apt/debian stretch/mongodb-org/4.0 Release.gpg [801 B]
Get:7 https://dl.ubnt.com/unifi/debian stable InRelease [3038 B]
Get:11 https://dl.ubnt.com/unifi/debian stable/ubiquiti amd64 Packages [732 B]
Fetched 6061 B in 1s (5707 B/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done

Install Java 8 on Ubuntu 18.04 / Debian 9

Restrict Ubuntu and your Debian system from automatically installing Java 11 / Java 17:

sudo apt-mark hold openjdk-11-*
sudo apt-mark hold openjdk-17-*

Install Java 8 from OS default APT repositories.

sudo apt install openjdk-8-jdk openjdk-8-jre

Remove any newer version of Java installed – Java 11 or Java 17.

sudo apt remove openjdk-11-* openjdk-17-*
sudo apt install openjdk-8-jdk openjdk-8-jre

Confirm installed Java version with the command java -version , it should show openjdk 1.8

$ java -version
openjdk version "1.8.0_312"
OpenJDK Runtime Environment (build 1.8.0_312-8u312-b07-0ubuntu1~18.04-b07)
OpenJDK 64-Bit Server VM (build 25.312-b07, mixed mode)

Install UniFi Network Application on Ubuntu 18.04 / Debian 9

We can now install UniFi Network Application on Ubuntu 18.04 / Debian 9 once Java 8 is confirmed to be the default Java version in the system.

Run the commands below to install the latest release of UniFi Network Application (UniFi Controller).

sudo apt install unifi

Accept installation prompt as requested.

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  binutils binutils-common binutils-x86-64-linux-gnu ca-certificates-java fontconfig-config fonts-dejavu-core java-common jsvc libasound2 libasound2-data libavahi-client3 libavahi-common-data
  libavahi-common3 libbinutils libboost-filesystem1.65.1 libboost-iostreams1.65.1 libboost-program-options1.65.1 libboost-system1.65.1 libcommons-daemon-java libcups2 libfontconfig1
  libgoogle-perftools4 libgraphite2-3 libharfbuzz0b libjpeg-turbo8 libjpeg8 liblcms2-2 libnspr4 libnss3 libpcrecpp0v5 libpcsclite1 libsnappy1v5 libstemmer0d libtcmalloc-minimal4 libyaml-cpp0.5v5
  mongo-tools mongodb-clients mongodb-server mongodb-server-core openjdk-17-jre-headless
Suggested packages:
  binutils-doc default-jre libasound2-plugins alsa-utils java-virtual-machine cups-common liblcms2-utils pcscd libnss-mdns fonts-dejavu-extra fonts-ipafont-gothic fonts-ipafont-mincho
  fonts-wqy-microhei | fonts-wqy-zenhei fonts-indic
The following NEW packages will be installed:
  binutils binutils-common binutils-x86-64-linux-gnu ca-certificates-java fontconfig-config fonts-dejavu-core java-common jsvc libasound2 libasound2-data libavahi-client3 libavahi-common-data
  libavahi-common3 libbinutils libboost-filesystem1.65.1 libboost-iostreams1.65.1 libboost-program-options1.65.1 libboost-system1.65.1 libcommons-daemon-java libcups2 libfontconfig1
  libgoogle-perftools4 libgraphite2-3 libharfbuzz0b libjpeg-turbo8 libjpeg8 liblcms2-2 libnspr4 libnss3 libpcrecpp0v5 libpcsclite1 libsnappy1v5 libstemmer0d libtcmalloc-minimal4 libyaml-cpp0.5v5
  mongo-tools mongodb-clients mongodb-server mongodb-server-core openjdk-17-jre-headless unifi
0 upgraded, 41 newly installed, 0 to remove and 57 not upgraded.
Need to get 280 MB of archives.
After this operation, 724 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

Manually installing UniFi Network Application on Ubuntu 18.04 / Debian 9

If you prefer to manually download a .deb package, visit the download the UniFi Controller software from the Ubiquiti Networks website.

Choose “Debian / Ubuntu Linux and UniFi Cloud Key” from software list.

unifi-network-application-debian-ubuntu-01-1024x182

Click the “Download” button that shows up after selecting.

unifi-network-application-debian-ubuntu-02-1024x89

Use “Download File” button or copy Direct URL and use command line downloaders to get the file in your local system.

unifi-network-application-debian-ubuntu-03-1024x211

Downloading the file with wget:

wget https://dl.ui.com/unifi//unifi_sysvinit_all.deb

Installation of .deb package can be done with apt while passing dowloaded file path as an argument.

$ sudo apt install ./unifi_sysvinit_all.deb
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'unifi' instead of './unifi_sysvinit_all.deb'
The following additional packages will be installed:
  binutils binutils-common binutils-x86-64-linux-gnu ca-certificates-java fontconfig-config fonts-dejavu-core java-common jsvc libasound2 libasound2-data libavahi-client3 libavahi-common-data
  libavahi-common3 libbinutils libboost-filesystem1.65.1 libboost-iostreams1.65.1 libboost-program-options1.65.1 libboost-system1.65.1 libcommons-daemon-java libcups2 libfontconfig1
  libgoogle-perftools4 libgraphite2-3 libharfbuzz0b libjpeg-turbo8 libjpeg8 liblcms2-2 libnspr4 libnss3 libpcrecpp0v5 libpcsclite1 libsnappy1v5 libstemmer0d libtcmalloc-minimal4 libyaml-cpp0.5v5
  mongo-tools mongodb-clients mongodb-server mongodb-server-core openjdk-17-jre-headless
Suggested packages:
  binutils-doc default-jre libasound2-plugins alsa-utils java-virtual-machine cups-common liblcms2-utils pcscd libnss-mdns fonts-dejavu-extra fonts-ipafont-gothic fonts-ipafont-mincho
  fonts-wqy-microhei | fonts-wqy-zenhei fonts-indic
The following NEW packages will be installed:
  binutils binutils-common binutils-x86-64-linux-gnu ca-certificates-java fontconfig-config fonts-dejavu-core java-common jsvc libasound2 libasound2-data libavahi-client3 libavahi-common-data
  libavahi-common3 libbinutils libboost-filesystem1.65.1 libboost-iostreams1.65.1 libboost-program-options1.65.1 libboost-system1.65.1 libcommons-daemon-java libcups2 libfontconfig1
  libgoogle-perftools4 libgraphite2-3 libharfbuzz0b libjpeg-turbo8 libjpeg8 liblcms2-2 libnspr4 libnss3 libpcrecpp0v5 libpcsclite1 libsnappy1v5 libstemmer0d libtcmalloc-minimal4 libyaml-cpp0.5v5
  mongo-tools mongodb-clients mongodb-server mongodb-server-core openjdk-17-jre-headless unifi
0 upgraded, 41 newly installed, 0 to remove and 57 not upgraded.
Need to get 280 MB of archives.
After this operation, 724 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

Successful installation output;

Note, selecting 'unifi' instead of './unifi_sysvinit_all.deb'
unifi is already the newest version (7.1.66-17875-1).
0 upgraded, 0 newly installed, 0 to remove and 57 not upgraded.

Access UniFi Network Application on Web browser

To restart the service run the following commands:

sudo systemctl restart unifi.service

Confirm that the status is running:

$ systemctl status unifi.service
● unifi.service - unifi
   Loaded: loaded (/lib/systemd/system/unifi.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2022-07-11 23:46:08 UTC; 18s ago
  Process: 12237 ExecStop=/usr/lib/unifi/bin/unifi.init stop (code=exited, status=0/SUCCESS)
  Process: 12307 ExecStart=/usr/lib/unifi/bin/unifi.init start (code=exited, status=0/SUCCESS)
 Main PID: 12375 (jsvc)
    Tasks: 101 (limit: 2314)
   CGroup: /system.slice/unifi.service
           ├─12375 unifi -cwd /usr/lib/unifi -home /usr/lib/jvm/java-8-openjdk-amd64 -cp /usr/share/java/commons-daemon.jar:/usr/lib/unifi/lib/ace.jar -pidfile /var/run/unifi.pid -procname unifi -ou
           ├─12377 unifi -cwd /usr/lib/unifi -home /usr/lib/jvm/java-8-openjdk-amd64 -cp /usr/share/java/commons-daemon.jar:/usr/lib/unifi/lib/ace.jar -pidfile /var/run/unifi.pid -procname unifi -ou
           ├─12378 unifi -cwd /usr/lib/unifi -home /usr/lib/jvm/java-8-openjdk-amd64 -cp /usr/share/java/commons-daemon.jar:/usr/lib/unifi/lib/ace.jar -pidfile /var/run/unifi.pid -procname unifi -ou
           ├─12397 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -Dfile.encoding=UTF-8 -Djava.awt.headless=true -Dapple.awt.UIElement=true -Dunifi.core.enabled=false -Xmx1024M -XX:+ExitOnOutOfMemor
           └─12449 bin/mongod --dbpath /usr/lib/unifi/data/db --port 27117 --unixSocketPrefix /usr/lib/unifi/run --logRotate reopen --logappend --logpath /usr/lib/unifi/logs/mongod.log --pidfilepath

Jul 11 23:45:51 unifi-controller systemd[1]: Stopped unifi.
Jul 11 23:45:51 unifi-controller systemd[1]: Starting unifi...
Jul 11 23:45:51 unifi-controller unifi.init[12307]:  * Starting Ubiquiti UniFi Network application unifi
Jul 11 23:46:08 unifi-controller unifi.init[12307]:    ...done.
Jul 11 23:46:08 unifi-controller systemd[1]: Started unifi.

Services should be available on port 8080 and port 8443.

[email protected]:~$ ss -tunelp | egrep '8080|8443'
tcp   LISTEN  0       100                           *:8443               *:*     uid:112 ino:47897 sk:a v6only:0 <->
tcp   LISTEN  0       100                           *:8080               *:*     uid:112 ino:47891 sk:e v6only:0 <->

Access UniFi Network Application on a web browser using the server IP address an port 8443.

https://172.20.30.20:8443/

You’ll get SSL warnings while trying to access the portal.

unifi-network-application-debian-ubuntu-04-1024x486

Click “Advanced” and “Proceed” to the portal.

unifi-network-application-debian-ubuntu-05-1024x571

From your clients (UniFi devices), ping UniFi controller IP address to validate network connectivity.

U6-LR-BZ.6.0.21# ping 172.20.30.20 -c 2
PING 172.20.30.20 (172.20.30.20): 56 data bytes
64 bytes from 172.20.30.20: seq=0 ttl=63 time=0.883 ms
64 bytes from 172.20.30.20: seq=1 ttl=63 time=0.885 ms

--- 172.20.30.20 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 0.883/0.884/0.885 ms

Pointing UniFi Devices to new Network Application (UniFi Controller)

if this setup is new, your Network Application will discover all UniFi network devices in your network. Check out initial UniFi Network Application configuration in our recent macOS guide:

If you’re replacing an old Controller, then login to your UniFi devices and set inform address to the new server address and port. See below example.

set-inform http://172.20.30.20:8080/inform

Give it sometime and status should reflect the recent update we populated.

US-16-150W-US.6.2.14# info

Model:       US-16-150W
Version:     6.2.14.13855
MAC Address: 98:8a:20:fd:ea:94
IP Address:  192.168.1.116
Hostname:    US-16-150W
Uptime:      992330 seconds

Status:      Connected (http://172.20.30.20:8080/inform)

Your uniFi devices will be available for administration from Web browser once they’re enrolled / imported for management via UniFi Network Application.

unifi-network-application-debian-ubuntu-06-1024x127

Log Files Location

UniFi Network Application have log files that are essential for any troubleshooting required. Logs files available are;

  • /usr/lib/unifi/logs/server.log
  • /usr/lib/unifi/logs/mongod.log

We’re working on more articles around UniFi network infrastructure and other integrations. Stay tuned for updates.

coffee

Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.