-
-
Save davecoutts/5ccb403c3d90fcf9c8c4b1ea7616948d to your computer and use it in GitHub Desktop.
# 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 |
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!
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
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.
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.
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 ...
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?
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
Thanks so much for the detailed reply @davecoutts. This is exactly the help I needed.
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)
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": []
}
thank you it works.
Any help in linking digital ocean with unifi
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
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! 👍
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.
@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
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.
what is default admin username and password of mongodb ?
Off the back of @ficematt using https://glennr.nl/s/unifi-network-controller make the process alot easier 👍
Unfortunately the URL - https://www.ui.com/downloads/unifi/debian is now broken.
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.
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?
Hi all, I have had the issue that # apt update
gave an error like E: The repository 'https://www.ui.com/downloads/unifi/debian stable InRelease' is not signed.
I've tried to add the key, but still had no success. Until I came across this thread.
Because of your comment @davecoutts, I changed /etc/apt/sources.list.d/100-ubnt-unifi.list to: deb https://dl.ui.com/unifi/debian stable ubiquiti
and it seems to work. Maybe there was a redirect before, that isn't there anymore? Can someone confirm if this works?
Hi all, I have had the issue that
# apt update
gave an error likeE: The repository 'https://www.ui.com/downloads/unifi/debian stable InRelease' is not signed.
I've tried to add the key, but still had no success. Until I came across this thread. Because of your comment @davecoutts, I changed /etc/apt/sources.list.d/100-ubnt-unifi.list to:deb https://dl.ui.com/unifi/debian stable ubiquiti
and it seems to work. Maybe there was a redirect before, that isn't there anymore? Can someone confirm if this works?
It was likely my bad or bad timing. It looks like https://www.ui.com/downloads/unifi/debian is now forwarded to https://dl.ui.com/unifi/debian/
@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.
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.
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
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.