Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
@crayz9000
Copy link

crayz9000 commented Apr 21, 2021

hola buen dia, instale satisfactoriamente, me estaba funcionando bien pero de un momento a otro no me abre por web, no conozco del tema podrian ayudarme por favor

Trate de usar sudo chown -R unifi:unifi /usr/lib/unifi y sudo systemctl restart unifi

@earenasr
Copy link

earenasr commented Apr 21, 2021

hola buen dia, instale satisfactoriamente, me estaba funcionando bien pero de un momento a otro no me abre por web, no conozco del tema podrian ayudarme por favor

Trate de usar sudo chown -R unifi:unifi /usr/lib/unifi y sudo systemctl restart unifi

nada no me funciona, no se que mas hacer tengo 200 equipos que se validan en ese cloud, usted sabe de alguien que pueda revisarlo y pago sus servicios ?

@davecoutts
Copy link
Author

davecoutts commented Apr 21, 2021

With a fresh Ubuntu 20.04 install, the script worked to install UniFi 6.1.71-15061-1, except the web interface wouldn't start, and this message was reported by systemctl status:

unifi[36574]: WARN Unable to load properties from '/usr/lib/unifi/data/system.properties' - /usr/lib/unifi/data/system.properties (No such file or directory)

Checking the permissions on /usr/lib/unifi showed that everything was owned root:root, while all processes were running under user unifi. Running chown -R unifi:unifi /usr/lib/unifi allowed the service to restart successfully.

Hi @crayz9000

I believe the /usr/lib/unifi/data/system.properties (No such file or directory) error only occurs the first time the unifi application starts, following the installation.
I don't know the unifi application post installation initialisation process, but it could be that the system.properties file needs time to be generated.

If you check soon after application start, you will see the system.properties file in directory /var/lib/unifi, which is soft linked from /usr/lib/unifi/data.

dave@uni02:~$ ls -l /usr/lib/unifi/data
lrwxrwxrwx 1 root root 14 Apr 21 22:16 /usr/lib/unifi/data -> /var/lib/unifi

dave@uni03:~$ sudo ls -l /var/lib/unifi
total 36
drwxr-x--- 3 unifi unifi  4096 Apr 21 22:17 backup
drwxr-x--- 4 unifi unifi 20480 Apr 21 22:19 db
-rw-r----- 1 unifi unifi  2248 Apr 21 22:17 keystore
-rw-r----- 1 unifi unifi  1322 Apr 21 22:17 system.properties
-rw-r----- 1 unifi unifi  1322 Apr 21 22:17 system.properties.bk

I don't believe you need to change the ownership of /usr/lib/unifi.
To check this you could try restarting the unifi application without changing the /usr/lib/unifi directory ownership, and see if the system.properties error reoccurs. In my case I didn't see the system.properties error on restarting the unifi application.

sudo systemctl restart unifi.service
systemctl status --no-pager --full unifi.service
journalctl -u unifi.service --no-pager
journalctl -u unifi.service --no-pager

-- Logs begin at Wed 2021-04-21 22:10:45 BST, end at Wed 2021-04-21 23:08:02 BST. --
Apr 21 23:05:51 uni03 systemd[1]: Starting unifi...
Apr 21 23:05:51 uni03 unifi.init[2470]:  * Starting Ubiquiti UniFi Controller unifi
Apr 21 23:05:52 uni03 unifi[2543]: 2021-04-21 23:05:52,764 main ERROR Error processing element InMemoryAppender ([Appenders: null]): CLASS_NOT_FOUND
Apr 21 23:05:52 uni03 unifi[2543]: WARN Unable to load properties from '/usr/lib/unifi/data/system.properties' - /usr/lib/unifi/data/system.properties (No such file or directory)
Apr 21 23:05:53 uni03 unifi[2543]: 2021-04-21 23:05:53,130 main ERROR Unable to locate appender "InMemoryAppender" for logger config "root"
Apr 21 23:06:05 uni03 unifi.init[2470]:    ...done.
Apr 21 23:06:05 uni03 systemd[1]: Started unifi.
Apr 21 23:07:45 uni03 systemd[1]: Stopping unifi...
Apr 21 23:07:45 uni03 unifi.init[4307]:  * Stopping Ubiquiti UniFi Controller unifi
Apr 21 23:07:49 uni03 unifi.init[4307]:    ...done.
Apr 21 23:07:49 uni03 systemd[1]: unifi.service: Succeeded.
Apr 21 23:07:49 uni03 systemd[1]: Stopped unifi.

Apr 21 23:07:49 uni03 systemd[1]: Starting unifi...
Apr 21 23:07:49 uni03 unifi.init[4376]:  * Starting Ubiquiti UniFi Controller unifi
Apr 21 23:07:50 uni03 unifi[4443]: 2021-04-21 23:07:50,174 main ERROR Error processing element InMemoryAppender ([Appenders: null]): CLASS_NOT_FOUND
Apr 21 23:07:50 uni03 unifi[4443]: 2021-04-21 23:07:50,552 main ERROR Unable to locate appender "InMemoryAppender" for logger config "root"
Apr 21 23:08:02 uni03 unifi.init[4376]:    ...done.
Apr 21 23:08:02 uni03 systemd[1]: Started unifi.

@ganter799
Copy link

ganter799 commented Jun 29, 2021

Just wanna thanks for your guide. Had some problems installing on Ubuntu 21.04 and switch to my Raspberry4 with Raspberry PI OS lite. Had to install ufw and open port 8443/tcp. Don't know if the last step was really necessary but it worked. Maybe I was too stupid and mixed up the IP. Now everything works like charm.

@AHrubik
Copy link

AHrubik commented Jul 16, 2021

Thanks for this - got me pointed in the right direction with install - had to edit JRE path before unifi service successfully launched - see here:

https://community.ui.com/questions/Java-Home-Directory-Fail-Issue-on-Ubuntu-RESOLVED/1faea5fd-6eda-4be9-a12f-676ef6be2529

This is still required using Ubuntu 20.04-2.

@warybyte
Copy link

warybyte commented Jul 23, 2021

This also works on my configuration of 18.04. Thanks so much!

5.4.0-77-generic #86~18.04.1-Ubuntu

@dbosk
Copy link

dbosk commented Aug 10, 2021

On a Raspberry Pi 4 (arm64), I needed to modify one line:

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

@larrydevops
Copy link

larrydevops commented Aug 15, 2021

Works perfectly. Tried on Ubuntu 20.04.02

@Thijxx
Copy link

Thijxx commented Aug 26, 2021

Does not work (anymore) as it currently fails a mongodb dependency check unfortunately.

I'm working with Ubuntu 21.04, that is probably the problem. Manually installed Mongo but unifi keeps nagging about it missing no matter what I do.

@emulated24
Copy link

emulated24 commented Aug 27, 2021

Does not work (anymore) as it currently fails a mongodb dependency check unfortunately.

I'm working with Ubuntu 21.04, that is probably the problem. Manually installed Mongo but unifi keeps nagging about it missing no matter what I do.

I did this on Ubuntu Server 21.04 on arm64 RPi4b, works fine, mongodb 3.6.3 gets installed:

1. Add Unifi source list:

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

2. Add Unifi GPG keys:

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

3. Add MongoDB GPG keys:

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

4. Add MongoDB source list:

echo "deb https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
sudo apt update

5. Add Ubuntu Server 18.04 sources:

sudo cp /etc/apt/sources.list /etc/apt/sources.list.orig
sudo vi /etc/apt/sources.list

# Ubuntu Server 18.04 sources
deb http://ports.ubuntu.com/ubuntu-ports bionic main restricted
deb http://ports.ubuntu.com/ubuntu-ports bionic-updates main restricted
deb http://ports.ubuntu.com/ubuntu-ports bionic universe
deb http://ports.ubuntu.com/ubuntu-ports bionic-updates universe
deb http://ports.ubuntu.com/ubuntu-ports bionic multiverse
deb http://ports.ubuntu.com/ubuntu-ports bionic-updates multiverse
deb http://ports.ubuntu.com/ubuntu-ports bionic-backports main restricted universe multiverse
deb http://ports.ubuntu.com/ubuntu-ports bionic-security main restricted
deb http://ports.ubuntu.com/ubuntu-ports bionic-security universe
deb http://ports.ubuntu.com/ubuntu-ports bionic-security multiverse


sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32
sudo apt update

6. Install Unifi Controller:

sudo apt install -f unifi

@Thijxx
Copy link

Thijxx commented Aug 30, 2021

I used the pre-installed Raspberry Pi image for Ubuntu 21.04, maybe there is a difference there? Otherwise I cannot explain why it did not work out for me. I've moved to the LinuxServer docker container with Unifi.

@emulated24
Copy link

emulated24 commented Aug 31, 2021

I used the pre-installed Raspberry Pi image for Ubuntu 21.04, maybe there is a difference there? Otherwise I cannot explain why it did not work out for me. I've moved to the LinuxServer docker container with Unifi.

Not sure what went wrong, but I used this image for installation: ubuntu-21.04-preinstalled-server-arm64+raspi.img.xz
Then did what's above, twice already, no problem at all. :)

@RocketLR
Copy link

RocketLR commented Sep 13, 2021

For me, this is all that was needed on a clean 20.04 install:

sudo apt-get update
sudo apt-get install --yes ca-certificates apt-transport-https wget

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

Jupp thanks man. This worked flawlessly.

@ficematt
Copy link

ficematt commented Oct 2, 2021

I have followed these steps but can seem to access the Unifi console. When I check the unifi.service status bellow is the output.
● unifi.service - unifi
Loaded: loaded (/lib/systemd/system/unifi.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2021-10-01 23:04:39 CDT; 3min 13s ago
Process: 1001 ExecStart=/usr/lib/unifi/bin/unifi.init start (code=exited, status=0/SUCCESS)
Main PID: 1196 (jsvc)
Tasks: 37 (limit: 43313)
Memory: 313.0M
CGroup: /system.slice/unifi.service
├─1196 unifi -cwd /usr/lib/unifi -home /usr/lib/jvm/java-8-openjdk-amd64 -cp /usr/share/java/commo>
├─1199 unifi -cwd /usr/lib/unifi -home /usr/lib/jvm/java-8-openjdk-amd64 -cp /usr/share/java/commo>
└─1200 unifi -cwd /usr/lib/unifi -home /usr/lib/jvm/java-8-openjdk-amd64 -cp /usr/share/java/commo>

Oct 01 23:03:36 dvr1 systemd[1]: Starting unifi...
Oct 01 23:03:36 dvr1 unifi.init[1001]: * Starting Ubiquiti UniFi Controller unifi
Oct 01 23:04:39 dvr1 unifi.init[1001]: ...fail!
Oct 01 23:04:39 dvr1 systemd[1]: Started unifi.
lines 1-16/16 (END)

The third line up from the bottom is the one that has me worried. I have tried looking online for a solution, but have come up empty handed.
Also, when I check the open ports with sudo lsof -nP -iTCP -sTCP:LISTEN I don't see where the port 8443 is listening and open. I do not have UFW active. I have not had an issue with getting portainer and cockpit running. Those ports are shown listening when I ran the above command.

@Starkstromkonsument
Copy link

Starkstromkonsument commented Oct 2, 2021

I have followed these steps but can seem to access the Unifi console. When I check the unifi.service status bellow is the output. ● unifi.service - unifi Loaded: loaded (/lib/systemd/system/unifi.service; enabled; vendor preset: enabled) Active: active (running) since Fri 2021-10-01 23:04:39 CDT; 3min 13s ago Process: 1001 ExecStart=/usr/lib/unifi/bin/unifi.init start (code=exited, status=0/SUCCESS) Main PID: 1196 (jsvc) Tasks: 37 (limit: 43313) Memory: 313.0M CGroup: /system.slice/unifi.service ├─1196 unifi -cwd /usr/lib/unifi -home /usr/lib/jvm/java-8-openjdk-amd64 -cp /usr/share/java/commo> ├─1199 unifi -cwd /usr/lib/unifi -home /usr/lib/jvm/java-8-openjdk-amd64 -cp /usr/share/java/commo> └─1200 unifi -cwd /usr/lib/unifi -home /usr/lib/jvm/java-8-openjdk-amd64 -cp /usr/share/java/commo>

Oct 01 23:03:36 dvr1 systemd[1]: Starting unifi... Oct 01 23:03:36 dvr1 unifi.init[1001]: * Starting Ubiquiti UniFi Controller unifi Oct 01 23:04:39 dvr1 unifi.init[1001]: ...fail! Oct 01 23:04:39 dvr1 systemd[1]: Started unifi. lines 1-16/16 (END)

The third line up from the bottom is the one that has me worried. I have tried looking online for a solution, but have come up empty handed. Also, when I check the open ports with sudo lsof -nP -iTCP -sTCP:LISTEN I don't see where the port 8443 is listening and open. I do not have UFW active. I have not had an issue with getting portainer and cockpit running. Those ports are shown listening when I ran the above command.

Same problem here. After enforcing some debugging in /etc/init.d/unifi I get a lot of Java-Output and this line:

[...] main ERROR Unable to create file logs/server.log java.io.IOException: Could not create directory /logs

Any ideas anybody? The logging paths semm to be set up correctly. Why is it trying to create that directory? /var/log/unifi is present and writable by the user in question. Some more debugging data:

OS: Ubuntu Server 20.04.3 LTS (focal)

+-- DUMPING PARSED COMMAND LINE ARGUMENTS --------------
| Detach:          True
| Show Version:    No
| Show Help:       No
| Check Only:      Disabled
| Stop:            False
| Wait:            0
| Run as service:  No
| Install service: No
| Remove service:  No
| JVM Name:        "null"
| Java Home:       "/usr/lib/jvm/java-8-openjdk-amd64"
| PID File:        "/var/run/unifi.pid"
| User Name:       "unifi"
| Extra Options:   8
|   "-Djava.class.path=/usr/share/java/commons-daemon.jar:/usr/lib/unifi/lib/ace.jar"
|   "-Dunifi.datadir=/var/lib/unifi"
|   "-Dunifi.logdir=/var/log/unifi"
|   "-Dunifi.rundir=/var/run/unifi"
|   "-Dunifi.core.enabled=false"
|   "-Xmx1024M"
|   "-Djava.awt.headless=true"
|   "-Dfile.encoding=UTF-8"
| Class Invoked:   "com.ubnt.ace.Launcher"
| Class Arguments: 1
|   "start"
+-------------------------------------------------------

Thank you!

@ficematt
Copy link

ficematt commented Oct 3, 2021

I got the Unifi application running. I uninstalled the Unifi application. Then I ran the script found HERE.

Be sure you are running the latest script. You have to scroll down and copy the link from further down in the post. Below is the command you need to run. Refer to the post linked above for the most current information.

apt-get update; apt-get install ca-certificates wget -y
wget https://get.glennr.nl/unifi/install/unifi-6.4.54.sh
bash unifi-6.4.54.sh

@ynadji
Copy link

ynadji commented Oct 10, 2021

Oct 01 23:03:36 dvr1 systemd[1]: Starting unifi... Oct 01 23:03:36 dvr1 unifi.init[1001]: * Starting Ubiquiti UniFi Controller unifi Oct 01 23:04:39 dvr1 unifi.init[1001]: ...fail! Oct 01 23:04:39 dvr1 systemd[1]: Started unifi. lines 1-16/16 (END)

Same problem here. After enforcing some debugging in /etc/init.d/unifi I get a lot of Java-Output and this line:

Also had the same problem . I ran the first Java process shown when looking at the systemd status and had the following output:

¡ /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:+ExitOnOutOfMemoryError -XX:+CrashOnOutOfMemoryError -XX:ErrorFile=/usr/lib/unifi/logs/hs_err_pid%p.log -jar /usr/lib/unifi/lib/ace.jar start
WARN Unable to load properties from '/usr/lib/unifi/data/system.properties' - /usr/lib/unifi/data/system.properties (Permission denied)
Port 8080 not available

Turns out I had something running on port 8080 and apparently this needs it as well. I moved the other service and restarted unifi with sudo service unifi restart and I'm up and running now. Installed through the UniFi apt repo.

@desdougan
Copy link

desdougan commented Oct 29, 2021

I followed this and found I also had to install openjdk-8-jdk to get it running. Thanks for putting this together - it helped greatly.

@Starkstromkonsument
Copy link

Starkstromkonsument commented Nov 1, 2021

Hi, thank you for your feedback. It turned out to be my own fault, because I had set the parameter unifi.https.port=443 without granting the permission to bind to a privileged port. The IOExceptions are still there but unifi works fine anyway ...

@USMA56795
Copy link

USMA56795 commented Nov 8, 2021

How do you get MongoDB 3.6.x installed on Ubuntu 20.x? MongoDB < 4.x is EOL. Is it just a matter of adding the 3.6 repo?

@davecoutts
Copy link
Author

davecoutts commented Nov 8, 2021

Hi @USMA56795
If you run apt install --dry-run mongodb-server it will simulate installing mongodb-server and show you the version that would have been installed.
You should find that mongodb-server version 3.6.9 is the current default version for Ubuntu 20.04.3 LTS.

Equally you can check package versions and dependencies with the apt-cache command, as per the examples below.
You will see that the current unifi package has a mongodb-server version dependency of >= 2.4.10 << 4.0.0

uni01:~$ lsb_release -d
Description: Ubuntu 20.04.3 LTS

uni01:~$ apt-cache policy mongodb-server
mongodb-server:
  Installed: 1:3.6.9+really3.6.8+90~g8e540c0b6d-0ubuntu5.3
  Candidate: 1:3.6.9+really3.6.8+90~g8e540c0b6d-0ubuntu5.3
  Version table:
 *** 1:3.6.9+really3.6.8+90~g8e540c0b6d-0ubuntu5.3 500
        500 http://gb.archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages
        500 http://gb.archive.ubuntu.com/ubuntu focal-security/universe amd64 Packages
        100 /var/lib/dpkg/status
     1:3.6.9+really3.6.8+90~g8e540c0b6d-0ubuntu5 500
        500 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 Packages

uni01:~$ apt-cache show unifi
Package: unifi
Version: 6.4.54-16067-1
Architecture: all
Depends: binutils, coreutils, adduser, libcap2, curl,
 mongodb-server (>= 2.4.10) | mongodb-10gen (>= 2.4.14) | mongodb-org-server (>= 2.6.0),
 mongodb-server (<< 1:4.0.0) | mongodb-10gen (<< 4.0.0) | mongodb-org-server (<< 4.0.0),
 java8-runtime-headless | java11-runtime-headless, jsvc (>=1.0.8), logrotate
Pre-Depends: debconf (>= 0.5) | debconf-2.0
Conflicts: unifi-controller
Provides: unifi-controller
Replaces: unifi-controller
Installed-Size: 225095

@USMA56795
Copy link

USMA56795 commented Nov 8, 2021

Thanks so much for the detailed reply @davecoutts. This is exactly the help I needed.

@userthirtytwo
Copy link

userthirtytwo commented Nov 10, 2021

Thanks for this! Also- how can I tell which version (unifi version) installed via CLI? (I cant access the webui yet since I need to wait for a pause in production)

@davecoutts
Copy link
Author

davecoutts commented Nov 10, 2021

Hi @userthirtytwo

Running either of the commands below on the server unifi is installed on should give you the version information.

Version reported by the installed unifi package meta data.

uni01:~$ dpkg -s unifi | grep -i version
Version: 6.4.54-16067-1

Version reported by the running unifi web server API interface.

uni01:~$ curl -ks https://localhost:8443/status | python3 -m json.tool
{
    "meta": {
        "rc": "ok",
        "up": true,
        "server_version": "6.4.54",
        "uuid": "53023d6c-06fd-4ef3-86a5-fad7dafcf280"
    },
    "data": []
}

@emilholic
Copy link

emilholic commented Jan 11, 2022

thank you it works.

@kagawa-sagawa
Copy link

kagawa-sagawa commented Jan 14, 2022

Any help in linking digital ocean with unifi

@helmist
Copy link

helmist commented Mar 9, 2022

For those wanting to allow all the ports used by the controller from UI's Documentation, the below adds every port except for the ports used by AP-EDU broadcasting. you might also want to ad an explicit ssh-over-tcp rule with sudo ufw allow 22/tcp.

sudo ufw enable
sudo ufw allow 3478/udp
sudo ufw allow 5514/udp
sudo ufw allow 8080/tcp
sudo ufw allow 8443/tcp
sudo ufw allow 8880/tcp
sudo ufw allow 8843/tcp
sudo ufw allow 6789/tcp
sudo ufw allow 27117/tcp
sudo ufw allow 10001/udp
sudo ufw allow 1900/udp
sudo service unifi restart

@rakhbari
Copy link

rakhbari commented Jul 20, 2022

For me, this is all that was needed on a clean 20.04 install:

sudo apt-get update
sudo apt-get install --yes ca-certificates apt-transport-https wget

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

Jupp thanks man. This worked flawlessly.

@RocketLR Thanks for these simple instructions. It worked perfectly for me as well. Cheers! 👍

@lamixer
Copy link

lamixer commented Jul 20, 2022

Yes, thank you for this! I love Debian, but I wasted over an hour fighting with Debian 11 and mongodb versions and other apt problems; I lost. This just works, I installed at Unifi version 7.1.66. I spun up an Ubuntu 20.04 Linux container in Proxmox, updated and (since I was logged in as root, removed sudo, and I like to type Y so):

apt-get install ca-certificates apt-transport-https wget

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

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

apt update

apt install openjdk-8-jre-headless unifi

Thanks Dave and everyone.

@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

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