How to install Zabbix monitor on Ubuntu Server 18.04

If you need to keep tabs on your Ubuntu Server instances, install the open source Zabbix monitor and you'll have all of the information you need.

Connection network in dark servers data center room storage systems 3D rendering

 

Image: Getty Images/iStockphoto

Your business most likely relies on Linux for some of your servers, services, and software. In fact, you probably have a few Linux-powered units in your data center racks, which might deploy containers, cloud services, serve up email, or a host of other possibilities.

Because of this, you need to know what's going on with these servers. For that, you can always turn to the open source Zabbix, a tool for monitoring network services, network hardware, servers, database systems, and even applications.

Unfortunately, Zabbix has yet to release a repository for Ubuntu 20.04, so I'm going to have to stick with our tried and true Ubuntu 18.04.

If your Ubuntu Servers are still running 16.04, you can follow the How to install the Zabbix enterprise-grade monitor on Ubuntu Server 16.04 tutorial for instructions.

SEE: How to become a database administrator: A cheat sheet (TechRepublic)

What you'll need

In order to make this work, you'll need the following:

  • A running, updated instance of Ubuntu Server 18.04

  • A user with sudo privileges

How to install the LAMP server

The first thing we'll do is make sure the Linux server has Apache MySQL and PHP installed. Fortunately, Ubuntu makes this incredibly simple. Log in to your server and issue the command:

sudo apt-get install lamp-server^

When this command completes, you should have a fully functioning LAMP server ready.

How to install the dependencies

There are a few dependencies that must be installed. Do that with the command:

sudo apt-get install php-cli php-common php-dev php-pear php-gd php-mbstring php-mysql php-xml php-bcmath libapache2-mod-php -y

With all of the PHP bits installed, let's go ahead and take care of this configuration. The PHP configurations are made in the files:

/etc/php/7.2/apache2/php.ini
/etc/php/7.2/cli/php.ini

First issue the command:

sudo nano /etc/php/7.2/apache2/php.ini

In that file, you'll want to make the following changes:

date.timezone = Your/Time/Zone
max_execution_time = 600
max_input_time = 600
memory_limit = 256M
post_max_size = 32M
upload_max_filesize = 16M

Where Your/Time/Zone is the timezone of the server's location.

Next, issue the following command and make the same edits:

sudo nano /etc/php/7.2/cli/php.ini

Restart Apache with the command:

sudo systemctl restart apache2

How to create the database

Before we get to the creation of the database, it's important that you secure the MySQL server. Do that by issuing the command:

sudo mysql_secure_installation

When you finish with that, access the MySQL console with the command:

sudo mysql -u root -p

At the MySQL console, create the necessary database, create a new user, and grant the new user permission to access the database with the the SQL statements:

create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@'localhost' identified by 'PASSWORD';
flush privileges;
exit

Where PASSWORD is a strong, unique password.

How to install and configure Zabbix

Because Zabbix isn't found in the standard repositories, we have to add one with the following commands:

wget https://repo.zabbix.com/zabbix/4.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.4-1+bionic_all.deb
sudo dpkg -i zabbix-release_4.4-1+bionic_all.deb

Now we can install Zabbix with the commands:

sudo apt-get update
sudo apt-get install zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-agent -y

With Zabbix installed, import the database schema with the command:

sudo zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix

Next, we'll configure Zabbix. Issue the command:

sudo nano /etc/zabbix/zabbix_server.conf

In that file, look for the lines:

#DBHost = localhost
#DBPassword =

Uncomment them out (removing the # characters) and then add the password you created for the Zabbix user in the MySQL console.

Start and enable the Zabbix server and agent with the commands:

sudo systemctl start zabbix-server
sudo systemctl enable zabbix-server
sudo systemctl start zabbix-agent
sudo systemctl enable zabbix-agent

Finally, restart Apache again with the command:

sudo systemctl apache2 restart

How to complete the installation

Open a web browser and point it to http://SERVER_IP/zabbix (where SERVER_IP is the IP address of the hosting server). You will be greeted by the web-based installer (Figure A).

Figure A

zabbixa.jpg

The Zabbix web-based installer.

Click Next Step until you find yourself at the database configuration window (Figure B).

Figure B

zabbixb.jpg

The Zabbix database configuration window.

You should only have to fill out the Password field, using the password you created at the MySQL console. Click Next Step and you will be prompted to fill out the Zabbix server details (Figure C).

Figure C

zabbixc.jpg

Filling out the Zabbix server details.

Change localhost to the IP address of the server and give the server an optional name--such as Zabbix Server. Click Next Step and, in the resulting window, review your configuration. If all is okay, click Next Step and you're done. Click Finish and you'll be prompted to log in. The default credentials are Admin/zabbix.

Once you've logged in, you should immediately change the Admin password (click the profile icon in the upper right corner, and then click Change Password). After changing the administrator password, you can start using Zabbix to monitor that server in ways that would have been seriously challenging from the command line.

Enjoy the fresh new scent of information.

Also see