Skip to content

Instantly share code, notes, and snippets.

@jimdigriz
Last active April 3, 2024 18:27
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jimdigriz/3a12e519e97f671c9df1174f203c8516 to your computer and use it in GitHub Desktop.
Save jimdigriz/3a12e519e97f671c9df1174f203c8516 to your computer and use it in GitHub Desktop.
Self-Hosting a UniFi Network Server on Debian "bookworm" 12

These instructions have been adapted from the official docs and avoid you have to run any lengthy scripts but you should still be able to get up and running within five minutes or so.

N.B. since the release of 7.5.x and 8.x there are no longer 32 bit releases (so no armhf) but someone noticed that the packages are architechiture neutral (ie. all) in amd64 so you can just pretend to be amd64 on arm64. When doing this, after the update you will still need to do the snappy fix described below.

I am targetting ARM64 but if you are using x86_64 (aka AMD64/amd64) then you should replace all occurances of arm64 (and armhf) with amd64.

Plumb in the Unifi packaging by running:

sudo curl -o /usr/share/keyrings/unifi-repo.gpg https://dl.ui.com/unifi/unifi-repo.gpg
# arm64 works with armhf here (as Unifi is just a bunch of Java) and this is all they publish
echo 'deb [arch=armhf signed-by=/usr/share/keyrings/unifi-repo.gpg] https://www.ui.com/downloads/unifi/debian stable ubiquiti' | sudo tee /etc/apt/sources.list.d/unifi.list >/dev/null

Fetch the dependencies (please note that these links were correct at the time of writing and likely now need updating by you; follow the package name link to find out the latest version suitable for your system and download and install that):

  • multiarch-support:

    curl -O -J http://security.debian.org/debian-security/pool/updates/main/g/glibc/multiarch-support_2.28-10+deb10u2_arm64.deb
    
  • libssl1.0.0

    curl -o libssl1.0.0_1.0.2l-1~bpo8+1_arm64.deb https://snapshot.debian.org/archive/debian/20170705T160707Z/pool/main/o/openssl/libssl1.0.0_1.0.2l-1~bpo8%2B1_arm64.deb
    
  • MongoDB 3.6 (Unifi only works with >=2.6 and <4.0):

    curl -O -J https://repo.mongodb.org/apt/ubuntu/dists/xenial/mongodb-org/3.6/multiverse/binary-arm64/mongodb-org-server_3.6.23_arm64.deb
    

Now install the dependencies (this will complain of missing dependencies, but those should be resolved by the second command):

sudo dpkg -i multiarch-support_2.28-10+deb10u2_arm64.deb libssl1.0.0_1.0.2l-1~bpo8+1_arm64.deb mongodb-org-server_3.6.23_arm64.deb
sudo apt install -f

N.B. if any of this fails at this point it is likely because one or more of the cURL requests above failed (probably a '404 Not Found') and you missed it. Please go back, as the links may now be out of date, and figure out what you should be downloading and installing which is suitable for your system.

Start MongoDB:

sudo systemctl enable --now mongod

Now install Unifi:

sudo apt update
sudo apt install unifi

If everything is working, you should be able to see it running via:

sudo systemctl status unifi

You should now be able to access the Unifi service in your brower at https://localhost:8443/

Before you start adopting APs, you need to swap a library over otherwise you will see the following error appearing in /var/log/unifi/server.log:

[2023-08-18 10:20:46,220] <inform-4> ERROR [InformServlet] - Servlet.service() for servlet [InformServlet] in context with path [] threw exception
java.lang.UnsupportedOperationException: isValidCompressedBuffer is not supported in pure-java mode
        at org.xerial.snappy.pure.PureJavaSnappy.isValidCompressedBuffer(PureJavaSnappy.java:259)
        at org.xerial.snappy.Snappy.isValidCompressedBuffer(Snappy.java:331)
        at org.xerial.snappy.Snappy.isValidCompressedBuffer(Snappy.java:343)
        at com.ubnt.net.InformServlet.Ô00000(Unknown Source)

Use the following:

sudo apt install libsnappy-java
sudo mv /usr/lib/unifi/lib/snappy-java-1.1.8.4.jar /usr/lib/unifi/lib/snappy-java-1.1.8.4.jar.orig
sudo ln -s /usr/share/maven-repo/org/xerial/snappy/snappy-java/1.1.8.3/snappy-java-1.1.8.3.jar /usr/lib/unifi/lib/snappy-java-1.1.8.4.jar
sudo systemctl restart unifi

N.B. Debian supplies version 1.1.8.3 which seems to be close enough to just be dropped into place as masquerade as version 1.1.8.4

You may need to repeat this process if the Unifi gateway gets updated via apt upgrade.

@jzenzen
Copy link

jzenzen commented Sep 1, 2023

A great guide, but I do run into this, how did you solve it?
The following packages have unmet dependencies: unifi : Depends: openjdk-11-jre-headless but it is not installable

@jimdigriz
Copy link
Author

jimdigriz commented Sep 1, 2023

A great guide,

@jzenzen ...not that great a guide if I missed this :)

but I do run into this, how did you solve it?
The following packages have unmet dependencies: unifi : Depends: openjdk-11-jre-headless but it is not installable

I wrote this in the middle of upgrading my system from Debian 'bullseye' 11 to Debian 'bookworm' 12, the former has openjdk-11-jre-headless.

I have updated the above instructions on getting this extra dependency and including it. Thanks for reporting, hopefully this fixes it for you!

@kn4thx
Copy link

kn4thx commented Jan 5, 2024

I get a permission denied error on the unifi.list line using sudo echo deb [arch=armhf signed-by=/usr/share/keyrings/unifi-repo.gpg] https://www.ui.com/downloads/unifi/debian stable ubiquiti' > /etc/apt/sources.list.d/unifi.list

@jimdigriz
Copy link
Author

I get a permission denied error on the unifi.list line using sudo ...

@kn4thx Just run the commands as root, use sudo -s to become root, run the commands as described above, and then logout/Ctrl-D/exit to return back to your regular user.

The reason for this is sudo is running echo as root but the file redirection (... > /etc/apt/sources.list.d/unifi.list ) is still running as a non-root user. For reference in your learnings, what you could have done here instead is (note that sudo is running tee now as root instead of echo):

echo hello world | sudo tee /howdy >/dev/null

@Axelaar
Copy link

Axelaar commented Feb 7, 2024

I am trying to get unifi installed on a Pi 4B, when running the dpkg command there is no action, it immediately stops with this statement:
dpkg: error: cannot access archive 'libssl1.0.0_1.0.2l-1~bpo8+1_arm64.deb': No such file or directory

Running this command does not make me any smarter:
apt list libssl*
as the only response is:
Listing... Error!
E: input:0-39: error: Expected pattern
libssl1.0.0_1.0.2l-1~bpo8%2B1_arm64.deb
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Any suggestions?

@jimdigriz
Copy link
Author

jimdigriz commented Feb 7, 2024

I am trying to get unifi installed on a Pi 4B, when running the dpkg command there is no action, it immediately stops with this statement: dpkg: error: cannot access archive 'libssl1.0.0_1.0.2l-1~bpo8+1_arm64.deb': No such file or directory

The '-O' in the cURL command I provided looks to have mangled the local file, you will find it is called libssl1.0.0_1.0.2l-1~bpo8%2B1_arm64.deb (with the %2B which should have been a +). I have updated the instructions, try again.

Running this command does not make me any smarter:
[snipped]

This is because the * is being shell expanded before running and you have a local file that matches the glob wildcarding; next time wrap the libssl* with single quotes to prevent this. For example:

alex@clearfog:~$ ls -l libssl1.0.0_1.0.2l-1~bpo8+1_arm64.deb 
-rw-r--r-- 1 alex alex 904874 Jul  5  2017 libssl1.0.0_1.0.2l-1~bpo8+1_arm64.deb

alex@clearfog:~$ apt list libssl*
Listing... Error!
E: input:0-37: error: Expected pattern
   libssl1.0.0_1.0.2l-1~bpo8+1_arm64.deb
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

alex@clearfog:~$ rm libssl1.0.0_1.0.2l-1~bpo8+1_arm64.deb 
alex@clearfog:~$ apt list libssl*
Listing... Done
libssl-dev/stable,stable-security 3.0.11-1~deb12u2 arm64
libssl-doc/stable,stable-security 3.0.11-1~deb12u2 all
libssl-ocaml-dev/stable 0.5.13-1 arm64
libssl-ocaml/stable 0.5.13-1 arm64
libssl-utils-clojure/stable 3.5.0-2 all
libssl1.0.0/now 1.0.2l-1~bpo8+1 arm64 [installed,local]
libssl3/stable,stable-security,now 3.0.11-1~deb12u2 arm64 [installed,automatic]

@kn4thx
Copy link

kn4thx commented Feb 7, 2024

A great guide,

@jzenzen ...not that great a guide if I missed this :)

but I do run into this, how did you solve it?
The following packages have unmet dependencies: unifi : Depends: openjdk-11-jre-headless but it is not installable

I wrote this in the middle of upgrading my system from Debian 'bullseye' 11 to Debian 'bookworm' 12, the former has openjdk-11-jre-headless.

I have updated the above instructions on getting this extra dependency and including it. Thanks for reporting, hopefully this fixes it for you!

I just wanted to comment that I appreciate your time n responding to the posts. I definitely learned something with that and have had it installed for a while now running great. Thank you!

@Axelaar
Copy link

Axelaar commented Feb 8, 2024

@jimdigriz : your update solved the issue. Thanks for your fast reply and help!

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