Skip to content

Instantly share code, notes, and snippets.

@davecoutts
Last active February 20, 2024 12:06
Star You must be signed in to star a gist
Save davecoutts/5ccb403c3d90fcf9c8c4b1ea7616948d to your computer and use it in GitHub Desktop.
Install Ubiquiti Unifi Controller on Ubuntu 20.04
# Install Ubiquiti Unifi Controller on Ubuntu 20.04.
# As tested on a fresh install of ubuntu-20.04.1-live-server, August 22nd 2020.
# Thanks to https://gist.github.com/tmuncks for posting the updated install steps.
sudo apt update
sudo apt install --yes apt-transport-https
echo 'deb https://www.ui.com/downloads/unifi/debian stable ubiquiti' | sudo tee /etc/apt/sources.list.d/100-ubnt-unifi.list
sudo wget -O /etc/apt/trusted.gpg.d/unifi-repo.gpg https://dl.ui.com/unifi/unifi-repo.gpg
sudo apt update
sudo apt install --yes openjdk-8-jre-headless unifi
sudo apt clean
sudo systemctl status --no-pager --full mongodb.service unifi.service
# Now log into https://unifi_controller_hostname:8443/
## ------------------------------------------------------------------------------------------------------------------------
## Previous install steps from when unifi still required mongodb-server <= 3.4.
## unifi has since been updated to work with mongodb-server 3.6. Which is available from the Ubuntu 20.04 main repository.
## ------------------------------------------------------------------------------------------------------------------------
#
# sudo apt install --yes ca-certificates apt-transport-https
# echo 'deb https://www.ui.com/downloads/unifi/debian stable ubiquiti' | sudo tee /etc/apt/sources.list.d/100-ubnt-unifi.list
# sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 06E85760C0A52C50
# wget -qO - https://www.mongodb.org/static/pgp/server-3.4.asc | sudo apt-key add -
# echo 'deb https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse' | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
# sudo apt-mark hold openjdk-11-*
# sudo apt update
# # mongodb 3.4 dependency
# wget http://security.ubuntu.com/ubuntu/pool/main/o/openssl1.0/libssl1.0.0_1.0.2n-1ubuntu5.3_amd64.deb -P /tmp
# sudo apt install --yes /tmp/libssl1.0.0_1.0.2n-1ubuntu5.3_amd64.deb
# rm /tmp/libssl1.0.0_1.0.2n-1ubuntu5.3_amd64.deb
# sudo apt install --yes mongodb-org
# sudo apt install --yes unifi
@davecoutts
Copy link
Author

davecoutts commented Jul 21, 2022

@lamixer you are welcome.

I feel your dependency hell pain.

The software stack versions for unifi are starting to become a problem with newer operating systems.
The issues I have found are,

  • mongodb has been dropped from the stable Debian and Ubuntu repositories.
  • unifi requires mongodb 3.x, which requires libssl1.1, which Ubuntu 22.04 depreciated in favor of libssl3.
  • Debian stable has dropped openjdk 8. unifi dependencies states it can use openjdk 11. Yet unifi fails to run without modifying the openjdk 11 installation.

I do hope Ubiquity is planning to update unifi to make it easier to install on current Linux operating systems.

If you would like to try Debian again I found that the following install steps worked on Debian 10 and 11.

# unifi 7 Debian 10 & 11 installation.
#
# https://gist.github.com/davecoutts
#
# mongodb installed from www.mongodb.org 

sudo apt update
sudo apt install --yes gnupg wget haveged

# unifi repository

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

echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/unifi-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

# mongodb-org repository

wget -qO- https://www.mongodb.org/static/pgp/server-3.6.asc \
| sudo gpg --dearmor -o /usr/share/keyrings/mongodb-org-server-3.6-archive-keyring.gpg > /dev/null

echo "deb [arch=$(dpkg --print-architecture) 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

# set JAVA_HOME environment variable for the unifi service

sudo mkdir /etc/systemd/system/unifi.service.d

printf "[Service]\nEnvironment=\"JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64\"\n" \
| sudo tee /etc/systemd/system/unifi.service.d/10-override.conf > /dev/null

# Install openjdk 11

sudo apt update
sudo apt install --yes openjdk-11-jre-headless

# Workaround issue where jsvc expects to find libjvm.so at lib/amd64/server/libjvm.so
sudo ln -s /usr/lib/jvm/java-11-openjdk-amd64/lib/ /usr/lib/jvm/java-11-openjdk-amd64/lib/amd64

# Install and enable mongodb 3.6

sudo apt install --yes mongodb-org-server

sudo systemctl enable mongod.service
sudo systemctl start mongod.service

# Install unifi

sudo apt install --yes unifi
sudo apt clean

# Post installation checks

systemctl status --no-pager --full mongod.service unifi.service

wget --no-check-certificate -qO- https://localhost:8443/status | python3 -m json.tool

sudo journalctl --no-pager --unit unifi.service

sudo cat /usr/lib/unifi/logs/server.log

sudo cat /usr/lib/unifi/logs/mongod.log

@lukehoersten
Copy link

All - thank you for all the comments and discussion here.

With this post and some extra work, I was able to get Unifi working on Ubuntu Jammy on a Raspberry Pi arm64. Especially thanks to @dbosk for pointing to the armhf Unifi repo.

I wrote up a description and ansible role for those wanting a script and explainer of what worked for me.

@thien154
Copy link

what is default admin username and password of mongodb ?

@gmhabchi
Copy link

Off the back of @ficematt using https://glennr.nl/s/unifi-network-controller make the process alot easier 👍

@jcgit1
Copy link

jcgit1 commented Oct 3, 2023

Unfortunately the URL - https://www.ui.com/downloads/unifi/debian is now broken.

@rakhbari
Copy link

rakhbari commented Oct 3, 2023

@jcgit1

Unfortunately the URL - https://www.ui.com/downloads/unifi/debian is now broken.

I don't have any first-hand knowledge, but it's fair to say that UBNT is no longer interested in maintaining a Linux UniFi download, especially not after their "Dream Machine" and Cloud Key offerings have been available for a while. I had gone through all the hassle and trouble of getting UniFi server working on a local Debian box I have here, but I simply got tired of the constant churn and issues that came up every time they make code changes. So I bit the bullet and bought a Cloud Key Gen2 Plus and it's been working flawlessly ever since. Yeah, it's $200, but it's self-maintained and well worth it. Of course now they're out of stock on it so you'll have to wait until they back-fill, but I highly recommend it.

@davecoutts
Copy link
Author

Hi @jcgit1

I'm not seeing an issue with the unifi repository located at https://www.ui.com/downloads/unifi/debian

root@unifi:~# cat /etc/apt/sources.list.d/100-ubnt-unifi.list 
deb https://www.ui.com/downloads/unifi/debian stable ubiquiti

root@unifi:~# apt update
Hit:1 http://ftp.debian.org/debian bullseye InRelease
Hit:2 http://deb.debian.org/debian bookworm InRelease                    
Hit:3 http://deb.debian.org/debian bookworm-updates InRelease            
Get:4 http://security.debian.org bookworm-security InRelease [48.0 kB]   
Hit:5 https://dl.ui.com/unifi/debian stable InRelease                          
Fetched 48.0 kB in 0s (115 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
root@unifi:~# 

What do you see when you attempt an install or update using that repository?

@lukehoersten
Copy link

lukehoersten commented Oct 12, 2023

@davecoutts the issue could be architectures. Looks like the latest stable release dropped ARM support:
N: Skipping acquire of configured file 'ubiquiti/binary-armhf/Packages' as repository 'https://www.ui.com/downloads/unifi/debian stable InRelease' doesn't support architecture 'armhf'

Guessing it's working for you on amd64 or something?

Edit: one can change the release from stable to unifi-7.4 to stick to the explicit release snapshot that still has ARM binaries.

@lymatas
Copy link

lymatas commented Oct 13, 2023

Yes it was the same situation on ubuntu 20.04 64-bit:
N: Skipping acquire of configured file 'ubiquiti/binary-i386/Packages' as repository 'https://www.ui.com/downloads/unifi/debian stable InRelease' doesn't support architecture 'i386'

Fixed it by editing /etc/apt/sources.list.d/100-ubnt-unifi.list file, and defined the architecture:
deb [arch=amd64] https://www.ui.com/downloads/unifi/debian stable ubiquiti

Now the updates are working correctly.

@shahkamran
Copy link

I have tested the code that I have published in my git repository below and works fine for me.
https://github.com/shahkamran/unifi-network-ubuntu-server/blob/main/unifi_ubuntu_22.04.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment