Hey guys! Today, we're diving into how to install the UniFi Controller on CentOS 7. If you're looking to manage your UniFi network devices, this guide will walk you through each step, making the process super easy and straightforward. Let's get started!

    Prerequisites

    Before we jump into the installation, make sure you have a few things covered:

    • A CentOS 7 server: You'll need a running CentOS 7 server with SSH access.
    • Root or sudo privileges: Ensure you have either root access or a user account with sudo privileges to execute administrative commands.
    • Basic understanding of Linux commands: A little familiarity with the Linux command line will be helpful.

    Step 1: System Update

    First things first, it's always a good idea to update your system to the latest packages. This ensures you have the latest security patches and dependencies. Open your terminal and run the following commands:

    sudo yum update -y
    

    This command updates all installed packages to their latest versions. The -y flag automatically answers "yes" to any prompts, making the process smoother. Keeping your system up-to-date is crucial for stability and security, especially before installing new software like the UniFi Controller.

    Step 2: Install Java

    The UniFi Controller requires Java to run. We'll install the OpenJDK version 8, which is compatible and widely used. Run the following command:

    sudo yum install java-1.8.0-openjdk-devel -y
    

    This command installs the Java Development Kit (JDK) version 8. After the installation, verify that Java is installed correctly by checking the version:

    java -version
    

    You should see output similar to:

    openjdk version "1.8.0_XXX"
    OpenJDK Runtime Environment (build 1.8.0_XXX-bXX)
    OpenJDK 64-Bit Server VM (build 25.XXX-bXX, mixed mode)
    

    If you don't see this, double-check that you've installed the correct package and that your system is properly configured to recognize the Java installation. A properly installed Java environment is essential for the UniFi Controller to function correctly.

    Step 3: Add the UniFi Repository

    Next, we need to add the UniFi repository to your system. This allows you to easily install and update the UniFi Controller software. Create a new repository file using your favorite text editor. Here, we'll use vi:

    sudo vi /etc/yum.repos.d/unifi.repo
    

    Add the following content to the file:

    [UniFi]
    name=UniFi Repo
    baseurl=http://www.ui.com/downloads/unifi/debian stable ubiquiti
    gpgcheck=0
    enabled=1
    

    Save the file and exit the editor. With the UniFi repository added, your system can now access the UniFi packages. This step is vital for getting the UniFi Controller directly from Ubiquiti's official source.

    Step 4: Install the UniFi Controller

    Now that we've added the repository, we can install the UniFi Controller. Run the following command:

    sudo yum install unifi -y
    

    This command downloads and installs the UniFi Controller along with its dependencies. Once the installation is complete, the UniFi Controller service should start automatically. If it doesn't, you can start it manually:

    sudo systemctl start unifi
    

    To ensure the UniFi Controller starts automatically on boot, enable the service:

    sudo systemctl enable unifi
    

    Verify the service is running:

    sudo systemctl status unifi
    

    You should see output indicating that the service is active and running. Ensuring the service is enabled guarantees that your UniFi Controller will be available after each reboot.

    Step 5: Adjust Firewall Settings

    To access the UniFi Controller from your web browser, you need to adjust your firewall settings to allow traffic on the necessary ports. UniFi uses several ports, but the most important one is 8443 for the web interface. Use the following commands to open this port:

    sudo firewall-cmd --permanent --add-port=8443/tcp
    sudo firewall-cmd --reload
    

    Optionally, you might also want to open ports 8080 (for device adoption) and 3478 (for STUN). The commands are:

    sudo firewall-cmd --permanent --add-port=8080/tcp
    sudo firewall-cmd --permanent --add-port=3478/udp
    sudo firewall-cmd --reload
    

    These commands configure the firewall to allow traffic on the specified ports. The --permanent flag ensures the settings persist across reboots, and --reload applies the changes immediately. Proper firewall configuration is critical for accessing the UniFi Controller from other devices on your network.

    Step 6: Access the UniFi Controller

    Now that the UniFi Controller is installed and the firewall is configured, you can access the web interface. Open your web browser and navigate to:

    https://your_server_ip:8443
    

    Replace your_server_ip with the actual IP address of your CentOS 7 server. You might see a security warning because of the self-signed certificate. You can safely proceed by adding an exception or trusting the certificate. Follow the on-screen instructions to complete the setup wizard. This includes creating an admin account and configuring your network settings. Completing the setup wizard is the final step in getting your UniFi Controller up and running.

    Step 7: Adopt Your UniFi Devices

    With the UniFi Controller up and running, the next step is to adopt your UniFi devices. Ensure your devices are on the same network as your UniFi Controller. In the UniFi Controller interface, go to the Devices section. Your devices should appear as