{"id":10275,"date":"2021-09-05T08:50:08","date_gmt":"2021-09-05T05:50:08","guid":{"rendered":"https:\/\/kifarunix.com\/?p=10275"},"modified":"2024-03-18T14:11:19","modified_gmt":"2024-03-18T11:11:19","slug":"install-zabbix-server-from-source-on-debian-11","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-zabbix-server-from-source-on-debian-11\/","title":{"rendered":"Install Zabbix Server from Source on Debian 11"},"content":{"rendered":"\n
In this guide, we are going to learn how to install Zabbix Server from source on Debian 11. Zabbix<\/a> is an enterprise class monitoring solution for any kind of IT infrastructure, services, applications, cloud resources.<\/p>\n\n\n\n Zabbix can be built from the source code or can be installed from Zabbix repository.<\/p>\n\n\n\n As of this writing, Zabbix has not released the APT repos for the Debian 11. Hence, we will install Zabbix from the source.<\/p>\n\n\n\n In this tutorial, we will use LAMP Stack. Follow the guide below to install LAMP Stack on Debian 11.<\/p>\n\n\n\n Install LAMP Stack on Debian 11<\/a><\/p>\n\n\n\n Once the installation of LAMP Stack is done, proceed to install additional PHP extensions and other required dependencies for the successful build of Zabbix<\/p>\n\n\n\n Login to MariaDB server and create a database and a database user for Zabbix. The database user should have all the privileges on the zabbix database.<\/p>\n\n\n\n A Zabbix system account is required for running Zabbix daemons. Hence you can create it by running the command below;<\/p>\n\n\n\n Navigate to Zabbix download page<\/a> and download the latest and stable Zabbix source archive. You can simply get the download link and use wget<\/strong> command download it.<\/p>\n\n\n\n Navigate to the directory in which you downloaded Zabbix source code and extract it.<\/p>\n\n\n\n Navigate to extracted Zabbix source directory and run the configure script to adapt Zabbix to the system. This step may fail if one of the required dependencies is not installed. In this guide, we are going to configure Zabbix server and agent and enable support for MariaDB database backend.<\/p>\n\n\n\n If the configure script completes successfully, you should see a summary of configuration.<\/p>\n\n\n\n Next, run the command below to compile and install Zabbix<\/p>\n\n\n\n Zabbix configuration files will be installed on \/usr\/local\/etc<\/strong> directory.<\/p>\n\n\n\n To begin with, configure Zabbix database connection details.<\/p>\n\n\n\n Open the configuration file, By default, Zabbix writes its log file to \/tmp<\/strong> directory. Change it on the configuration file such that it writes it to \/var\/log<\/strong>.<\/p>\n\n\n\n Save and exit the configuration file ( Now, create this log file and set the ownership to Zabbix user.<\/p>\n\n\n\n The Zabbix default MySQL database and initial data for each kind of database backend is located under the database<\/strong> subdirectory on the Zabbix source directory,<\/p>\n\n\n\n Begin by importing the database schema, Images.sql and then data.sql.<\/p>\n\n\n\n Create a systemd service for Zabbix server.<\/p>\n\n\n\n Create a systemd service for Zabbix agent<\/p>\n\n\n\n Reload systemd configuration<\/p>\n\n\n\n Start and enable Zabbix server,agent deamon to run on system start.<\/p>\n\n\n\n If firewall is running, open TCP port 10051 for remote connection.<\/p>\n\n\n\n To install Zabbix Frontend, copy Zabbix PHP configuration files under ui\/php\/<\/strong> subdirectory on the source code directory to Zabbix web server root directory.<\/p>\n\n\n\n Create Zabbix Web root directory.<\/p>\n\n\n\n Next, copy Zabbix PHP files.<\/p>\n\n\n\n Set the user and group ownership of the Zabbix directory to www-data<\/strong>.<\/p>\n\n\n\n There are some known compatibility issues between Zabbix 4.x and PHP 7.3 Opcache. Hence, disable Opcache by running the command below.<\/p>\n\n\n\n Next, open the PHP configuration file and make the following changes;<\/p>\n\n\n\n Restart Apache and Proceed to finalize Zabbix Frontend configuration.<\/p>\n\n\n\n Access Zabbix on your browser to finalize the frontend configuration using the address, http:\/\/<server-IP\/zabbix<\/strong>y<\/p>\n\n\n\n To complete Zabbix installation, navigate to the browser and access your Zabbix server via the address http:\/\/<server-IP>\/zabbix<\/strong>.<\/p>\n\n\n\n When access the address above, the first page you land on is Zabbix welcome page.<\/p>\n\n\n\n Click Next Step to verify if all the Zabbix requirements have been met.<\/p>\n\n\n\n Configure Zabbix database connection using the connection details set before.<\/p>\n\n\n\n Setup the Zabbix server details. You can leave the default settings.<\/p>\n\n\n\n On the Pre-installation summary, verify if all the configurations are fine.<\/p>\n\n\n\n If all is well, click Next step to finish the installation. If all is well, you should see Zabbix installation congratulatory message.<\/p>\n\n\n\n You have successfully setup Zabbix Frontend. Click Finish<\/strong> to get to Zabbix login interface.<\/p>\n\n\n The default login credentials are:<\/p>\n\n\n\n When you successfully login to Zabbix, you should land on the default dashboard.<\/p>\n\n\n\n Well, there you go.<\/p>\n\n\n\n Read More on Documentation page<\/a>.<\/p>\n\n\n\n Other Tutorials<\/p>\n\n\n\nInstalling Zabbix Server from Source on Debian 11<\/h2>\n\n\n\n
Install LAMP\/LEMP Stack<\/h3>\n\n\n\n
Install Additional Packages<\/h3>\n\n\n\n
apt install build-essential libmariadb-dev sudo libxml2-dev snmp libsnmp-dev libcurl4-openssl-dev php-gd php-xml php-bcmath php-mbstring vim libevent-dev libpcre3-dev libxml2-dev libmariadb-dev libapache2-mod-php libopenipmi-dev pkg-config php-ldap php-mysql -y<\/code><\/pre>\n\n\n\n
Create Zabbix Database<\/h3>\n\n\n\n
mysql -u root -p<\/code><\/pre>\n\n\n\n
create database zabbixdb character set utf8 collate utf8_bin;<\/code><\/pre>\n\n\n\n
grant all on zabbixdb.* to zabbixadmin@localhost identified by 'P@SSw0RD';<\/code><\/pre>\n\n\n\n
flush privileges;\nquit<\/code><\/pre>\n\n\n\n
Create Zabbix User System Account<\/h3>\n\n\n\n
sudo useradd -r -d \/var\/lib\/zabbix -s \/sbin\/nologin -M zabbix<\/code><\/pre>\n\n\n\n
mkdir -m u=rwx,g=rwx,o= -p \/var\/lib\/zabbix<\/code><\/pre>\n\n\n\n
chown zabbix:zabbix \/var\/lib\/zabbix<\/code><\/pre>\n\n\n\n
Download Zabbix Source Code<\/h3>\n\n\n\n
wget https:\/\/cdn.zabbix.com\/zabbix\/sources\/stable\/5.4\/zabbix-5.4.4.tar.gz<\/code><\/pre>\n\n\n\n
Extract Zabbix Source Code<\/h3>\n\n\n\n
tar xzf zabbix-5.4.4.tar.gz<\/code><\/pre>\n\n\n\n
Configure Zabbix Sources<\/h3>\n\n\n\n
cd zabbix-5.4.4<\/code><\/pre>\n\n\n\n
.\/configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2<\/code><\/pre>\n\n\n\n
\nConfiguration:\n\n Detected OS: linux-gnu\n Install path: \/usr\/local\n Compilation arch: linux\n\n Compiler: cc\n Compiler flags: -g -O2 \n\n Library-specific flags:\n database: -I\/usr\/include\/mariadb -I\/usr\/include\/mariadb\/mysql \n libXML2: -I\/usr\/include\/libxml2\n Net-SNMP: -I\/usr\/local\/include -I\/usr\/lib\/x86_64-linux-gnu\/perl\/5.32\/CORE -I. -I\/usr\/include\n OpenIPMI: -I\/usr\/include\n\n Enable server: yes\n Server details:\n With database: MySQL\n WEB Monitoring: cURL\n SSL certificates: \/usr\/local\/share\/zabbix\/ssl\/certs\n SSL keys: \/usr\/local\/share\/zabbix\/ssl\/keys\n SNMP: yes\n IPMI: yes\n SSH: no\n TLS: no\n ODBC: no\n Linker flags: -L\/usr\/lib\/x86_64-linux-gnu -L\/usr\/lib\/x86_64-linux-gnu\/ -L\/usr\/lib -rdynamic \n Libraries: -lmariadb -lnetsnmp -lOpenIPMI -lOpenIPMIposix -lz -lpthread -levent -lcurl -lm -ldl -lresolv -lxml2 -lpcre \n Configuration file: \/usr\/local\/etc\/zabbix_server.conf\n External scripts: \/usr\/local\/share\/zabbix\/externalscripts\n Alert scripts: \/usr\/local\/share\/zabbix\/alertscripts\n Modules: \/usr\/local\/lib\/modules\n\n Enable proxy: no\n\n Enable agent: yes\n Agent details:\n TLS: no\n Modbus: no\n Linker flags: -rdynamic \n Libraries: -lz -lpthread -lcurl -lm -ldl -lresolv -lxml2 -lpcre \n Configuration file: \/usr\/local\/etc\/zabbix_agentd.conf\n Modules: \/usr\/local\/lib\/modules\n\n Enable agent 2: no\n\n Enable web service: no\n\n Enable Java gateway: no\n\n LDAP support: no\n IPv6 support: yes\n\n***********************************************************\n* Now run 'make install' *\n* *\n* Thank you for using Zabbix! *\n*
Compile and Install Zabbix 4.x from Sources on Debian 10 Buster<\/h3>\n\n\n\n
sudo make install<\/code><\/pre>\n\n\n\n
Configuring Zabbix<\/h3>\n\n\n\n
\/usr\/local\/etc\/zabbix_server.conf<\/code><\/strong>, and replace the values for DBName<\/strong>, DBUser<\/strong>, DBPassword<\/strong> with what you set while creating database. Uncomment the line
# DBHost=localhost<\/strong><\/code>.<\/p>\n\n\n\n
vim \/usr\/local\/etc\/zabbix_server.conf<\/code><\/pre>\n\n\n\n
...\nDBHost=localhost<\/strong>\n...\nDBName=zabbixdb\n<\/strong>...\nDBUser=zabbixadmin\n<\/strong>...\nDBPassword=P@SSw0RD\n<\/strong>...<\/code><\/pre>\n\n\n\n
Change Zabbix Server Log Directory<\/h3>\n\n\n\n
LogFile=\/var\/log\/zabbix_server.log<\/code><\/pre>\n\n\n\n
:wq! or ZZ<\/code><\/strong>).<\/p>\n\n\n\n
touch \/var\/log\/zabbix_server.log\nchown zabbix:zabbix \/var\/log\/zabbix_server.log<\/code><\/pre>\n\n\n\n
Import Zabbix Default Database and Initial Data<\/h3>\n\n\n\n
cd ~\/zabbix-5.4.4\/database\/mysql\/<\/code><\/pre>\n\n\n\n
ls -1 *.sql<\/code><\/pre>\n\n\n\n
data.sql\ndouble.sql\nimages.sql\nschema.sql<\/code><\/pre>\n\n\n\n
mysql -u zabbixadmin -p zabbixdb < schema.sql<\/code><\/pre>\n\n\n\n
mysql -u zabbixadmin -p zabbixdb < images.sql<\/code><\/pre>\n\n\n\n
mysql -u zabbixadmin -p zabbixdb < data.sql<\/code><\/pre>\n\n\n\n
Running Zabbix Server and Agent<\/h3>\n\n\n\n
\ncat > \/etc\/systemd\/system\/zabbix-server.service << EOL\n[Unit]\nDescription=Zabbix Server\nAfter=syslog.target network.target mariadb.service\n \n[Service]\nType=oneshot\nUser=zabbix\nExecStart=\/usr\/local\/sbin\/zabbix_server\nExecReload=\/usr\/local\/sbin\/zabbix_server -R config_cache_reload\nRemainAfterExit=yes\nPIDFile=\/var\/run\/zabbix\/zabbix_server.pid\n \n[Install]\nWantedBy=multi-user.target\nEOL\n<\/code><\/pre>\n\n\n\n
\ncat > \/etc\/systemd\/system\/zabbix-agent.service << EOL\n[Unit]\nDescription=Zabbix Agent\nAfter=syslog.target network.target\n \n[Service]\nType=oneshot\nUser=zabbix\nExecStart=\/usr\/local\/sbin\/zabbix_agentd\nRemainAfterExit=yes\nPIDFile=\/var\/run\/zabbix\/zabbix_agent.pid\n \n[Install]\nWantedBy=multi-user.target\nEOL\n<\/code><\/pre>\n\n\n\n
systemctl daemon-reload<\/code><\/pre>\n\n\n\n
systemctl enable --now zabbix-server zabbix-agent<\/code><\/pre>\n\n\n\n
ufw allow 10051\/tcp<\/code><\/pre>\n\n\n\n
Installing Zabbix Frontend<\/h3>\n\n\n\n
mkdir \/var\/www\/html\/zabbix<\/code><\/pre>\n\n\n\n
cp -a ~\/zabbix-5.4.4\/ui\/* \/var\/www\/html\/zabbix\/<\/code><\/pre>\n\n\n\n
chown -R www-data:www-data \/var\/www\/html\/zabbix\/<\/code><\/pre>\n\n\n\n
Configure Zabbix Frontend<\/h3>\n\n\n\n
echo \"opcache.enable=0\" >> \/etc\/php\/7.4\/mods-available\/opcache.ini<\/code><\/pre>\n\n\n\n
vim \/etc\/php\/7.4\/apache2\/php.ini<\/code><\/pre>\n\n\n\n
\n
sed -i '\/post_max_size\/s\/= 8M\/= 16M\/' \/etc\/php\/7.4\/apache2\/php.ini<\/code><\/pre>\n\n\n\n
\n
sed -i 's\/max_execution_time = 30\/max_execution_time = 300\/' \/etc\/php\/7.4\/apache2\/php.ini<\/code><\/pre>\n\n\n\n
\n
sed -i '\/max_input_time\/s\/= 60\/= 300\/' \/etc\/php\/7.4\/apache2\/php.ini<\/code><\/pre>\n\n\n\n
\n
sed -i 's\/;date.timezone =\/date.timezone = Asia\\\/Nicosia\/' \/etc\/php\/7.4\/apache2\/php.ini<\/code><\/pre>\n\n\n\n
systemctl restart apache2<\/code><\/pre>\n\n\n\n
Configure Zabbix Web User Interface<\/h3>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure><\/div>\n\n\n
\n
<\/figure>\n\n\n\n