Skip to content
IT // Adventures

UniFi Controller Installation

Installing the UniFi Controller software as a service on Windows Server 2019 with AdoptOpenJDK.

2 min read

Preparation

To prepare, download all the necessary components:

  • UniFi Network Controller 5.x.y for Windows (Link)
  • AdoptOpenJDK Version 8, LTS, Hotspot (Link)
  • Apache Commons Daemon (Link)

Problem

Setting up the controller as a Windows service is made a bit harder by the architecture and the use of AdoptOpenJDK 64-bit.

  1. Problem: the UniFi service controller (Apache Commons Daemon Service Runner) ships with a service config that doesn’t cope with the 64-bit JVM automatically.
  2. Problem: the UniFi setup routine installs the controller directory in the user profile of the executing user! Unfortunately, the support entry in the UniFi knowledge base is only of limited help here: Run the Controller as Windows Service

Solution

The cleanest service installation is therefore…

  1. Install AdoptOpenJDK and enable the option “Oracle Java Registry Keys” in the wizard.
  2. Extract the Apache Commons Daemon binaries to the directory <C:\Program Files\Apache Commons Daemon\>.
  3. Install the UniFi Controller and do the basic configuration.
  4. Stop the controller and move the entire “Ubiquiti UniFi” directory from the user profile to <C:\Program Files\>.
  5. Create the UniFi Controller service (see script below)
  6. Extract the current binaries for the Apache Commons Daemon and the zip file to the directory <C:\Program Files\Apache Commons Daemon>.
    • The directory contains the service configuration tool “prunmgr.exe”
  7. Call the configuration tool prunmgr.exe with the parameter //ES//UniFi and, on the tab
    • “Java”, set the Java Virtual Machine in the AdoptOpenJDK directory <C:\Program Files\AdoptOpenJDK\jdk-8.0.x.y.z-hotspot\jre\bin\server\jvm.dll> (see screenshot below).
    • “Log on”, set the user “Local Service”. (Security, so that the controller process doesn’t run as “Local System”.)

UniFi Controller service properties

Here are a few more commands that make the process described above easier:

// Install service
cd "C:\Program Files\Ubiquiti UniFi\"
java.exe -jar lib\ace.jar installsvc

// Uninstall service
cd "C:\Program Files\Ubiquiti UniFi\"
java.exe -jar lib\ace.jar uninstallsvc
​
// Open the Apache Daemon service configuration tool
cd "C:\Program Files\Apache Commons Daemon\"
prinmgr.exe //ES//UniFi

Update installation

For an update, the UniFi setup expects the installation to be located in the user profile (of the current user). We therefore link the UniFi directory there via a symbolic link:

New-Item -ItemType SymbolicLink -Path "$($env:USERPROFILE)\Ubiquiti UniFi" -Target "$($env:ProgramFiles)\Ubiquiti UniFi\"