Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Installing Ubiquiti UniFi Controller 5 on Raspberry Pi.
# Mirror of the instructions available here:
# http://www.lowefamily.com.au/2016/06/02/installing-ubiquiti-unifi-controller-5-on-raspberry-pi/
#
# These commands CANNOT be run in a script.
# They're just for reference.
# Install on Raspbian Jessie, or upgrade from Wheezy.
# Make sure all packages are upgraded (update && upgrade).
# Update firmware.
sudo rpi-update
# Add the UniFi repository to the sources list, using the following commands
echo 'deb http://www.ubnt.com/downloads/unifi/debian unifi5 ubiquiti' | sudo tee -a /etc/apt/sources.list.d/ubnt.list > /dev/null
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv C0A52C50
sudo apt-get update
# Install unifi.
sudo aptitude install unifi
# Disable the default MongoDB database instance, using the following commands.
#
# Without making this small configuration change, you will have two separate
# instances of MongoDB running; an unused default database instance, and the
# UniFi database instance. This is obviously not desirable on a device with
# limited resources, such as the Raspberry Pi.
echo 'ENABLE_MONGODB=no' | sudo tee -a /etc/mongodb.conf > /dev/null
# For Raspberry Pi 1 devices:
#
# The latest UniFi Controller software requires some additional tweaking before
# it will run on ARMv6 devices, such as the original Raspberry Pi (RPi1).
# Remove the UniFi Cloud Library, using the following command:
sudo rm /usr/lib/unifi/lib/native/Linux/armhf/libubnt_webrtc_jni.so
# Update the Snappy Java Library, using the following commands:
cd /usr/lib/unifi/lib
sudo rm snappy-java-1.0.5.jar
sudo wget http://central.maven.org/maven2/org/xerial/snappy/snappy-java/1.1.2/snappy-java-1.1.2.jar
sudo ln -s snappy-java-1.1.2.jar snappy-java-1.0.5.jar
# Oracle Java 8 (Optional)
#
# The UniFi package automatically installs and configures
# OpenJDK Java 7. However, if you would prefer to use
# Oracle Java 8, perform the following steps.
# If needed (Raspbian Lite):
sudo aptitude install oracle-java8-jdk
# Copy the UniFi service controller template, using the following command:
sudo cp /lib/systemd/system/unifi.service /etc/systemd/system/
# Add the `JAVA_HOME` environment variable for Java 8 to the UniFi
# service controller, using the following command:
sudo sed -i '/^\[Service\]$/a Environment=JAVA_HOME=/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt' /etc/systemd/system/unifi.service
# If you wish to switch back to Java 7 at any point, execute the following commands:
sudo rm /etc/systemd/system/unifi.service
sudo reboot
# Once completed, reboot your Raspberry Pi.
# When the reboot is complete, use a web browser to view HTTPS port 8443 on your Raspberry Pi:
# https://<raspberrypi>:8443
# Be sure there is enough disk space!
# If the server never starts up, try checking the log files:
#
# - /usr/lib/unifi/logs/mongod.log
# - /usr/lib/unifi/logs/server.log
#
# I had an issue where the disk was filled up before the DB could first be created.
# The symptom was mongodb logs indicated it wanted to upgrade the DB and exited.
# Removing the DB files and freeing up disk space fixed it after restarting unifi:
# sudo service unifi stop
# sudo rm /var/lib/unifi/db/*
# sudo service unifi start
@kisspandur

This comment has been minimized.

Copy link

@kisspandur kisspandur commented Jan 8, 2017

All works fine,

only one comment:
In my Raspbian mini (MINIBIAN https://minibianpi.wordpress.com/) edition,
Line 64: ---> /etc/systemd/system/unifi.service does not exist.
instead: /etc/systemd/system/multi-user.target.wants/unifi.service wich is pointing to: /lib/systemd/system/unifi.service

@outrun0506

This comment has been minimized.

Copy link

@outrun0506 outrun0506 commented Mar 13, 2017

Still works. Thanks a lot!

@alatalo

This comment has been minimized.

Copy link

@alatalo alatalo commented Jul 5, 2017

With UniFi Controller 5.4.18 updating Snappy library is not needed anymore as it includes Snappy 1.1.2.6.

Thanks for the great setup instructions, I've been running UniFi on my Pi for a few months now :)

@salgua

This comment has been minimized.

Copy link

@salgua salgua commented Oct 3, 2017

If you use Raspbian Stretch, please add before apt-key the following instruction:

sudo apt-get install dirmngr

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