Add Unifi Controller to CentOS 7

I’m in the process of testing a Unifi AP (Nano), and need a controller to set it up. As its a temporary setup I choose the old faithful CentOS 7…

There are many excellent guides for setting up a Unifi Controller on CentOS 7, three that helped me:

https://community.spiceworks.com/how_to/128121-installing-unifi-controller-on-centos

https://nivethan.dev/devlog/setting-up-unifi-controller-on-centos-7.html

https://binhminhitc.com/networks-solutions/how-to-installing-unifi-controller-on-centos/

However since these were penned there are a few changes in the setup that need to be worked around:

Workarounds

UniFi.unix.zip Download Link

Unifi have stopped advertising the Unix files on the downloads, instead opting to show only the .deb Debian package. To get a file suitable for CentOS…

Navigate to https://www.ui.com/download/unifi/ and choose the download for Unifi Network Application for Debian:

Clicking download icon gives the following link…

Make note of the version number (here 7.1.66) and edit into the the following link:

https://www.ubnt.com/downloads/unifi/7.1.66/UniFi.unix.zip

MongoDB

MongoDB is no longer included in the default CentOS or EPEL repositories, so its own repository needs to be added to your system for prerequisites

Source: https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-red-hat/#install-mongodb-community-edition

Create a new file at /etc/yum.repos.d/mongodb-org-5.0.repo

Insert the following into the file:

[mongodb-org-5.0]name=MongoDB Repositorybaseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/5.0/x86_64/gpgcheck=1enabled=1gpgkey=https://www.mongodb.org/static/pgp/server-5.0.asc

Installation is now via:

yum install -y mongodb-org

Installation Guide

Disable SELinux, reboot for changes to take effect

sed -i /etc/selinux/config -r -e 's/^SELINUX=.*/SELINUX=disabled/g'
reboot

Create file to include MongoDB repositories

nano /etc/yum.repos.d/mongodb-org-5.0.repo

Add the following to the new file

 [mongodb-org-5.0]name=MongoDB Repositorybaseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/5.0/x86_64/gpgcheck=1enabled=1gpgkey=https://www.mongodb.org/static/pgp/server-5.0.asc 

Install prerequisites

yum install -y mongodb-org java-1.8.0-openjdk unzip wget

Download Unifi Controller

wget https://www.ubnt.com/downloads/unifi/7.1.66/UniFi.unix.zip

Unzip files to /opt directory

unzip -q UniFi.unix.zip -d /opt

Create data folder within Unifi directory

mkdir /opt/UniFi/data

Add new user to run service

useradd -r ubnt

Assign ubnt ownership of Unifi directory

chown -R ubnt:ubnt /opt/UniFi

Create firewall rules to allow access to Controller

nano /etc/firewalld/zones/public.xml

Add the following to the file…

  <port protocol="tcp" port="8081"/>
  <port protocol="tcp" port="8080"/>
  <port protocol="tcp" port="8443"/>
  <port protocol="tcp" port="8880"/>
  <port protocol="tcp" port="8843"/>
  <port protocol="tcp" port="27117"/>
  <port protocol="udp" port="3478"/>

Reload firewall for changes to take

firewall-cmd --reload

Enable MongoDB to start with the system, start it for first time and check its running

systemctl enable mongod
systemctl start mongod
systemctl status mongod

Create the service for Unfi Controller

nano /etc/systemd/system/unifi.service

Enter the following in the new file

[Unit]
Description=UniFi AP Web Controller
After=syslog.target network.target

[Service]
Type=simple
User=ubnt
WorkingDirectory=/opt/UniFi
ExecStart=/usr/bin/java -jar /opt/UniFi/lib/ace.jar start 
ExecStop=/usr/bin/java -jar /opt/UniFi/lib/ace.jar stop
SuccessExitStatus=143

[Install]
WantedBy=multi-user.target

Enable Controller to start with system

systemctl enable unifi

Start the Unifi Controller

systemctl start unifi

Controller should now be available for setup by browsing to
https://{IP ADDRESS}:8443/

Unifi Testing

I need the Unifi Controller in order to test the Nano HD AP, why? This is the only Unifi AP in stock in the UK at the moment, all other more preferred AP’s like the Pro, LR and HD are unobtainium along with the Cloud Key. Therefore in desperation its time to test if these will make a worthy substitute.

Its early days at present, but should testing go well and I choose to adopt Unifi as my home Wifi solution, I’d be deploying a slim VM running Rocky 8 to manage the infrastructure.

So far for testing; the AP is positioned a foot away from a Draytek 2927ac, at moderate distances the Unifi Nano is showing a 10db advantage over the Draytek on 2.4Ghz range, but curiously a 10db disadvantage on the 5Ghz range. And while devices report a better signal strength on the Unifi, bandwidth speed tests yield poor results.

I would hope that the Pro’s performance would be an improvement on the Nano, but for now that is entirely speculation since getting hands on one is impossible without paying scalper prices.