Cybersecurity Updates & Tools

Install Zabbix on Ubuntu 18.04: Server Setup with MySQL Backend

Zabbix is a mature open-source infrastructure monitoring platform that collects metrics from network devices, servers, virtual machines, and applications. It supports both agent-based monitoring and agent-less monitoring via SNMP, IPMI, and JMX. The Zabbix agent is lightweight and runs on Linux, UNIX, macOS, and Windows.

This guide covers how to install Zabbix on Ubuntu 18.04 using MySQL as the database backend. It also covers installing the Zabbix agent on a remote host with PSK encryption and registering that host in the Zabbix web interface.

<strong>Prerequisite:</strong>&nbsp;You need sudo access and MySQL already installed on your server.

Install Zabbix on Ubuntu: Create the MySQL Database and Add the Official Repository

Create the Zabbix database. Log in to MySQL and create the database using utf8_bin collation. Binary collation is case-sensitive, which Zabbix requires for its internal schema:

bashsudo mysql
sqlCREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;GRANT ALL ON zabbix.* TO 'zabbix'@'localhost' IDENTIFIED BY 'change-with-strong-password';EXIT;

Add the official Zabbix repository. The Ubuntu repositories ship outdated Zabbix versions. Install the Zabbix 4.0 repo package and update the package index:

bashwget https://repo.zabbix.com/zabbix/4.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.0-2+bionic_all.debsudo apt install ./zabbix-release_4.0-2+bionic_all.debsudo apt updatesudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-agent

This installs the Zabbix server, the PHP web frontend, and the local agent. It also pulls in Apache and the required PHP modules automatically.

Set the PHP timezone. Open /etc/apache2/conf-enabled/zabbix.conf and set the date.timezone value to your time zone. Leaving the line commented out causes the Zabbix frontend prerequisites check to fail. After editing, restart Apache:

bashsudo systemctl restart apache2

Import the MySQL Schema, Configure the Server, and Complete the Web Wizard

Import the database schema. The Zabbix package includes a compressed SQL dump with the initial schema and data:

bashzcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql -uzabbix -p zabbix

Enter the zabbix database user password when prompted.

Set the database password in the Zabbix config. Open /etc/zabbix/zabbix_server.conf, find the DBPassword directive, uncomment it, and add the database password you created earlier. Start and enable both services:

bashsudo systemctl restart zabbix-server zabbix-agentsudo systemctl enable zabbix-server zabbix-agent

Complete the web setup wizard. Open http://your_domain_or_ip/zabbix in a browser. The wizard steps through:

  1. Prerequisites check – all rows must be green before proceeding
  2. Database connection – enter the zabbix database name, username, and password
  3. Server name – optional, but useful when running multiple Zabbix servers
  4. Summary and finish

After completing setup, log in with the defaults: username Admin, password zabbix. Change this password immediately from the user profile page.

Install and Configure the Zabbix Agent and Add a Host to Monitor

On the remote host you want to monitor, install the Zabbix 4.0 agent:

bashwget https://repo.zabbix.com/zabbix/4.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.0-2+bionic_all.debsudo apt install ./zabbix-release_4.0-2+bionic_all.debsudo apt update &amp;&amp; sudo apt install zabbix-agent

Generate a PSK key to encrypt all communication between the agent and server:

bashopenssl rand -hex 32 | sudo tee /etc/zabbix/zabbix_agentd.psk

Edit /etc/zabbix/zabbix_agentd.conf and set the following directives:

  • Server= — your Zabbix server IP address
  • TLSConnect=psk and TLSAccept=psk
  • TLSPSKIdentity=PSK 001
  • TLSPSKFile=/etc/zabbix/zabbix_agentd.psk

Start the agent, enable it at boot, and open the Zabbix agent port:

bashsudo systemctl start zabbix-agentsudo systemctl enable zabbix-agentsudo ufw allow proto tcp from &lt;zabbix_server_ip&gt; to any port 10050

Port 10050 is the default TCP port the Zabbix server uses to poll agents. Restricting UFW access to only the Zabbix server IP prevents unauthorized polling attempts.

Register the host in the Zabbix web interface. Go to Configuration > Hosts > Create host. Enter the hostname and IP address, assign the host to the Linux Servers group, and add the Template OS Linux template on the Templates tab. Switch to the Encryption tab, select PSK for both connection directions, set the PSK identity to PSK 001, and paste the key from /etc/zabbix/zabbix_agentd.psk into the PSK value field. Click Add to save.

Zabbix 4.0 is now monitoring your Ubuntu 18.04 server and collecting data from the remote agent. Explore the dashboards, configure triggers for alert thresholds, and add notification actions for email or Slack. Leave a comment below if you run into any issues.