cheatsheets devlog projects search

Setting Up UniFi Controller on CentOS 7


In this chapter we’re going to set up our UniFi Controller on our server as that will make it much easier to manager. I had the controller on my PC before but my PC doesn’t stay on the entire time so there was always weirdness with the network being down or messy when I restarted my PC. This was only visual, the actual network was perfectly fine.

However now that I have a server, it makes sense to consolidate these things so let’s get started!

Installing the UniFi Controller

# useradd -r ubnt

First we need to create the ubnt user.

# yum -y install mongodb-server java-1.8.0-openjdk

The UniFi Controller software is a java server so we’ll need to install java.Here we installed java and mongodb as that is what the UniFi controller uses as a backend.

# wget

Next we need to grab the linux version of the server. The version number can be replaced with whatever the current version is.

# unzip -q -d /opt

This command will extract the zip to /opt and with that we have the UniFi Controller installed!

# mkdir /opt/UniFi/data
# chown -R ubnt:ubnt /opt/UniFi

We need to create a specific folder inside UniFi as it expects the data folder to be there. We then set the ownership of the folder to the user we created above.

Setting Up the Firewall

Now we need to open some ports so that the UniFi Controller can communicate across the network.


  <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"/>

Here we add the ports that UniFi needs to our firewall.

# firewall-cmd --reload

Voila! We restart our firewall and our UniFi server is now ready to communicate on the network.

Enabling and Starting the UniFi Controller

Now we need to write out systemd script that will run our UniFi Server on startup.


## Systemd unit file for UniFi Controller#

Description=UniFi AP Web Controller

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


Now we can do systemctl enable unifi so that it will run on start up.

# service unifi start

With that we have started our server!

Navigate to and we should see our UniFi Controller login page!

Upgrading the Controller / Restoring a Back Up

First download a backup from the UniFi Controller.

Settings -> System Settings -> Maintenance -> Backup/Restore -> Download Backup

Once we have our backup we can now do the same steps during the installation to upgrade our server.

# service unifi stop
# rm -rf /opt/UniFi/
# unzip -d /opt/
# mkdir /opt/UniFi/data
# chown -R ubnt:ubnt /opt/UniFi
# service unifi start

We stop our unfi controller and we then remove the old installation and install the new UniFi Controller. Once we’ve done that we start the UniFi Controller again and now if we navigate to we should see our intial set up screen.

We can now choose the restore from backup option and use the back up we downloaded.