Install UniFi Controller on CentOS 7

This guide is for installing the Ubiquiti UniFi Controller software on a fresh CentOS 7 server. This guide has been updated, by request, to run the UniFi controller as a non-root user (called ubnt) and configure firewalld, and I will be installing as root. However, we'll be disabling SELinux for simplicity sake. You may choose to enable SELinux in your production environment (my SELinux skills are lacking).

***Last update on 04/12/2017, to UniFi version 5.4.12.

Let's Get Started!

0.) Disable SELinux and update server:
sed -i /etc/selinux/config -r -e 's/^SELINUX=.*/SELINUX=disabled/g'
yum -y update
systemctl reboot
1.) Install EPEL Repo:
yum -y install epel-release
2.) Prerequisites:
useradd -r ubnt
yum -y install mongodb-server java-1.8.0-openjdk unzip wget
3.) Download and Extract UniFi Controller v5.4.12:
cd ~ && wget
unzip -q -d /opt
chown -R ubnt:ubnt /opt/UniFi
4.) Create Startup Script with Systemd:
vi /etc/systemd/system/unifi.service
# Systemd unit file for UniFi Controller

Description=UniFi AP Web Controller

ExecStart=/usr/bin/java -Xmx1024M -jar /opt/UniFi/lib/ace.jar start
ExecStop=/usr/bin/java -jar /opt/UniFi/lib/ace.jar stop

5.) Configure Firewalld

Firewalld is new to me, as it's a recent addition to EL7. Sure, I can disable firewalld, and install iptables, but I figure I should get used to firewalld since it's now the default. Truth be told, working with firewalld is not difficult. In short, you have zones, and you apply "services" to these zones. These firewalld services are XML formatted configs listing the ports that need to be opened. In the case of UniFi, we are creating a unifi service, applying that to the "home" zone, and setting the "home" zone as default. With a reboot, it all applies.

systemctl stop firewalld.service
vi /etc/firewalld/services/unifi.xml
<?xml version="1.0" encoding="utf-8"?>
<service version="1.0">
    <description>UniFi Controller</description>
    <port port="8081" protocol="tcp"/>
    <port port="8080" protocol="tcp"/>
    <port port="8443" protocol="tcp"/>
    <port port="8880" protocol="tcp"/>
    <port port="8843" protocol="tcp"/>
    <port port="10001" protocol="udp"/>
    <port port="3478" protocol="udp"/>

systemctl start firewalld.service
firewall-cmd --set-default-zone=home  # You can use one of the other zones, if you like.  I prefer using home instead of the default "public", just adjust accordingly below.
firewall-cmd --permanent --zone=home --change-interface=eth0  # I only have one active interface on my UniFi server, eth0.  This should be the interface that UniFi will be using.
firewall-cmd --permanent --zone=home --add-service=unifi
6.) Enable on Startup
systemctl enable unifi.service
7.) Cleanup
rm -rf ~/
systemctl reboot

To access the webUI, browse to https://IP_OF_SERVER:8443 and follow the simple setup wizard. Pretty easy install, and seems to work great on CentOS 7.

Hope you enjoyed, and please contact me if you have any feedback!

Related Posts

Share on: Twitter | Facebook | Google+ | Email

comments powered by Disqus