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!
# 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 https://www.ubnt.com/downloads/unifi/5.10.23/UniFi.unix.zip
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 UniFi.unix.zip -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.
Now we need to open some ports so that the UniFi Controller can communicate across the network.
/etc/firewalld/zones/public.xml
<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.
Now we need to write out systemd script that will run our UniFi Server on startup.
/etc/systemd/system/unfi.service
## Systemd unit file for UniFi Controller#
[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
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 192.168.7.41:8443 and we should see our UniFi Controller login page!
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 UniFi.unix.zip -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 192.168.7.41:8443 we should see our intial set up screen.
We can now choose the restore from backup option and use the back up we downloaded.