Binary Deployment of Zabbix on Linux Systems

1. System Requirements

  • CentOS 7/8 or Ubuntu 18.04+

  • At least 2GB of RAM

  • 10GB of available disk space

2. Install Dependencies

CentOS/RHEL:

yum update -y
yum install -y epel-release
yum install -y gcc gcc-c++ make pcre-devel libxml2-devel \
    net-snmp-devel libevent-devel openssl-devel \
    sqlite-devel openldap-devel libssh2-devel \
    mysql-devel postgresql-devel curl wget

Ubuntu/Debian:

apt update
apt install -y build-essential libpcre3-dev libxml2-dev \
    libsnmp-dev libevent-dev libssl-dev \
    libsqlite3-dev libldap2-dev libssh2-1-dev \
    libmysqlclient-dev libpq-dev curl wget

Database Installation and Configuration

3. Install MySQL/MariaDB

CentOS:

yum install -y mariadb-server mariadb
systemctl start mariadb
systemctl enable mariadb

Ubuntu:

apt install -y mariadb-server
systemctl start mysql
systemctl enable mysql

4. Configure Database

# Security settings
mysql_secure_installation

# Create Zabbix database and user
mysql -u root -p

# Execute the following commands in MySQL:
CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;
CREATE USER 'zabbix'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Zabbix Server Deployment

5. Create Zabbix User

groupadd --system zabbix
useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix

6. Download and Compile Zabbix Server

cd /usr/src
wget https://cdn.zabbix.com/zabbix/sources/stable/6.4/zabbix-6.4.0.tar.gz
tar -zxvf zabbix-6.4.0.tar.gz
cd zabbix-6.4.0

# Configure compilation options
./configure \
    --enable-server \
    --enable-agent \
    --with-mysql \
    --with-net-snmp \
    --with-libcurl \
    --with-libxml2 \
    --with-openssl \
    --with-ldap \
    --with-ssh2

# Compile and install
make install

7. Import Database Schema

cd /usr/src/zabbix-6.4.0/database/mysql
mysql -u zabbix -p zabbix < schema.sql
mysql -u zabbix -p zabbix < images.sql
mysql -u zabbix -p zabbix < data.sql

8. Configure Zabbix Server

mkdir -p /etc/zabbix
cp /usr/src/zabbix-6.4.0/conf/zabbix_server.conf /etc/zabbix/

# Edit configuration file
vi /etc/zabbix/zabbix_server.conf

Main configuration items:

LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=your_password
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000

9. Create Necessary Directories and Set Permissions

mkdir -p /var/log/zabbix /var/run/zabbix /usr/lib/zabbix/{alertscripts,externalscripts}
chown -R zabbix:zabbix /var/log/zabbix /var/run/zabbix /usr/lib/zabbix

Zabbix Agent Deployment

10. Compile and Install Zabbix Agent

cd /usr/src/zabbix-6.4.0
./configure --enable-agent
make install

11. Configure Zabbix Agent

cp /usr/src/zabbix-6.4.0/conf/zabbix_agentd.conf /etc/zabbix/
vi /etc/zabbix/zabbix_agentd.conf

Main configuration items:

PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=Zabbix server
Include=/etc/zabbix/zabbix_agentd.d/

Start Services

12. Create Startup Scripts

# Create systemd service files
cat > /etc/systemd/system/zabbix-server.service << EOF
[Unit]
Description=Zabbix Server
After=syslog.target
After=network.target

[Service]
Environment="CONFFILE=/etc/zabbix/zabbix_server.conf"
EnvironmentFile=-/etc/sysconfig/zabbix-server
Type=forking
Restart=on-failure
PIDFile=/var/run/zabbix/zabbix_server.pid
KillMode=control-group
ExecStart=/usr/local/sbin/zabbix_server -c $CONFFILE
ExecReload=/bin/kill -HUP $MAINPID
TimeoutSec=10

[Install]
WantedBy=multi-user.target
EOF

cat > /etc/systemd/system/zabbix-agent.service << EOF
[Unit]
Description=Zabbix Agent
After=syslog.target
After=network.target

[Service]
Environment="CONFFILE=/etc/zabbix/zabbix_agentd.conf"
EnvironmentFile=-/etc/sysconfig/zabbix-agent
Type=forking
Restart=on-failure
PIDFile=/var/run/zabbix/zabbix_agentd.pid
KillMode=control-group
ExecStart=/usr/local/sbin/zabbix_agentd -c $CONFFILE
ExecReload=/bin/kill -HUP $MAINPID
TimeoutSec=10

[Install]
WantedBy=multi-user.target
EOF

13. Start Services

systemctl daemon-reload
systemctl start zabbix-server
systemctl start zabbix-agent
systemctl enable zabbix-server
systemctl enable zabbix-agent

Web Interface Deployment

14. Install Web Server and PHP

CentOS:

yum install -y httpd php php-mysqlnd php-gd php-bcmath \
    php-mbstring php-ldap php-xml

Ubuntu:

apt install -y apache2 php php-mysql php-gd php-bcmath \
    php-mbstring php-ldap php-xml

15. Deploy Zabbix Web Frontend

mkdir -p /var/www/html/zabbix
cp -r /usr/src/zabbix-6.4.0/ui/* /var/www/html/zabbix/
chown -R apache:apache /var/www/html/zabbix/  # CentOS
# or
chown -R www-data:www-data /var/www/html/zabbix/  # Ubuntu

16. Configure PHP

Edit <span>/etc/php.ini</span> or <span>/etc/php/7.x/apache2/php.ini</span>:

max_execution_time = 300
memory_limit = 128M
post_max_size = 16M
upload_max_filesize = 2M
max_input_time = 300
date.timezone = Asia/Shanghai

17. Start Web Services

systemctl start httpd    # CentOS
systemctl start apache2  # Ubuntu
systemctl enable httpd
systemctl enable apache2

Installation Complete

18. Access Web Interface

Open your browser and visit:<span>http://your_server_ip/zabbix</span>

Follow the web wizard to complete the installation:

  1. Check prerequisites

  2. Configure database connection

  3. Set server details

  4. Complete installation

19. Default Login Information

  • Username: Admin

  • Password: zabbix

Verify Installation

# Check service status
systemctl status zabbix-server
systemctl status zabbix-agent

# Check port listening
netstat -tlnp | grep zabbix

# View logs
tail -f /var/log/zabbix/zabbix_server.log

Binary Deployment of Zabbix on Linux Systems

Leave a Comment