{"id":1503,"date":"2018-11-27T21:59:11","date_gmt":"2018-11-27T18:59:11","guid":{"rendered":"http:\/\/kifarunix.com\/?p=1503"},"modified":"2024-03-11T21:28:54","modified_gmt":"2024-03-11T18:28:54","slug":"how-to-install-and-configure-zabbix-4-0-from-source-on-fedora-29-fedora-28-centos-7","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/how-to-install-and-configure-zabbix-4-0-from-source-on-fedora-29-fedora-28-centos-7\/","title":{"rendered":"Install and Configure Zabbix 4.0 from Source on Fedora 29\/Fedora 28\/CentOS 7"},"content":{"rendered":"\n
In this guide, we are going to learn how to install and configure Zabbix 4.0 from source on Fedora 29\/Fedora 28\/CentOS 7.<\/p>\n\n\n\n
Zabbix is an enterprise class open-source monitoring solution designed for real time monitoring of networks, servers, virtual machines and cloud sources. It also m<\/span>onitors any possible server performance metrics and incidents such as CPU utilization, memory utilization, Network bandwidth usage, disk space utilization etc.<\/p>\n\n\n\n Zabbix metrics collection method include;<\/p>\n\n\n\n Zabbix has an handful of features which you can check them on Zabbix features page<\/a>.<\/p>\n\n\n\n You can also check out our previous article on Nagios availability monitoring<\/a>.<\/p>\n\n\n\n Zabbix is built around a modern Apache web server, leading database engines such as MySQL and PHP scripting language. Therefore ensure that you have LAMP stack installed before you can proceed.<\/p>\n\n\n\n You can check our previous articles on how to install LAMP stack on Fedora28\/29<\/a>. This will also apply to CentOS 7. If you follow this LAMP stack installation guide, install the following additional PHP extensions.<\/p>\n\n\n\n Disable or set SELinux in permissive mode.<\/p>\n\n\n\n or<\/p>\n\n\n\n Note that a system reboot is required in order to effect the SELinux changes.<\/p>\n\n\n\n Install the packages dependencies required to compile Zabbix from the source. Note that these dependencies depends on the option you choose to Zabbix from the source<\/p>\n\n\n\n Once your system has met the above minimums, as a best practise for securing Zabbix setup, you need to disable Apache web server information exposure. Edit Apache main configuration file, You can simplify the above the above process with the following single line’<\/p>\n\n\n\n Set the Apache Server name to your hostname.<\/p>\n\n\n\n Edit the There are four ways in which Zabbix can be installed and these include;<\/p>\n\n\n\n In this tutorial, we are going to install Zabbix 4.0 from the sources.<\/p>\n\n\n\n To download the latest Zabbix source archive, visit the Zabbix download page<\/a> and grab it there. Once you have downloaded the archive, extract it as follows;<\/p>\n\n\n\n An unprivileged user is required to run all Zabbix processes. Therefore, you need to create a This will automatically create a A database is required for managing and storing Zabbix data. Once the database is created, you are required to import the database schema and dataset as will be shown shortly.<\/p>\n\n\n\n To create Zabbix MySQL database, proceed as follows<\/p>\n\n\n\n Import the database schema and data set.<\/p>\n\n\n\n Once you are done with database creation, proceed to compile and install Zabbix. Note that you must specify the database type to be used when compiling the sources. For this procedure to succeed, you need to have installed the dependencies mentioned in the prerequisites.<\/p>\n\n\n\n If the compilation is successful, you should be able to see the configuration summary as shown below;<\/p>\n\n\n\n Run the command below to install the Zabbix daemon binaries (zabbix_server, zabbix_agentd, zabbix_proxy) in \/usr\/local\/sbin and the client binaries (zabbix_get, zabbix_sender) in \/usr\/local\/bin.<\/p>\n\n\n\n Now that Zabbix backend installation is done, you need to make a few configuration changes before you can start Zabbix server.<\/p>\n\n\n\n Edit the Zabbix server configuration file Create the custom log directory and set the proper ownership<\/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 The Zabbix backend configuration is done. Proceed to configure Zabbix frontend.<\/p>\n\n\n\n Zabbix frontend is written in PHP. Therefore, in order to do the installations, you need to copy the PHP files from Edit the Open the Zabbix ports for passive and active checks, 10050 and 10051 respectively, on firewall.<\/p>\n\n\n\n Restart Apache<\/p>\n\n\n\n You have completed the Zabbix server backend configuration. Login to Zabbix frontend to finalize the configurations. You can now access your Zabbix front using the URL in the format below;<\/p>\n\n\n\n This takes you to Zabbix welcome page.<\/p>\n\n\n Click Next to check on the PHP setup pre-requisites.<\/p>\n\n\n If everything is fine, click next to configure Database connections. Enter the database password you specified while creating database user above.<\/p>\n\n\n Click Next to Set the server details.<\/p>\n\n\n Click next to go through the configuration summary and and then next to set up Zabbix frontend. You have successfully setup Zabbix frontend.<\/p>\n\n\n Click Finish to proceed to login to your new Zabbix server.<\/p>\n\n\n\n The default login credentials are;<\/p>\n\n\n\n In order to monitor Zabbix Server itself, enable it for monitoring by navigating to Configuration <\/strong>> Hosts. <\/strong>Click on the Zabbix server status and you will be prompted whether to enable it. Click Ok.<\/p>\n\n\n\n\n
Installing Zabbix from Source on Fedora 29\/Fedora 28\/CentOS 7<\/h2>\n\n\n\n
Setup LAMP Stack<\/h3>\n\n\n\n
yum install php-{xml,bcmath,common,pear,gettext,ctype}<\/code><\/pre>\n\n\n\n
Disable SELinux<\/h3>\n\n\n\n
sed -i 's\/=enforcing\/=permissive\/' \/etc\/selinux\/config<\/code><\/pre>\n\n\n\n
sed -i 's\/=enforcing\/=disabled\/' \/etc\/selinux\/config<\/code><\/pre>\n\n\n\n
Install required Dependencies<\/h3>\n\n\n\n
sudo yum -y<\/span> install gcc make mariadb-<\/span>devel pcre* libevent-devel libxml2-<\/span>devel net-<\/span>snmp-<\/span>devel libcurl-<\/span>devel libssh2-<\/span>devel<\/code><\/pre>\n\n\n\n
Configure Apache Server<\/h3>\n\n\n\n
\/etc\/httpd\/conf\/httpd.conf<\/code>, and add the following lines at the end of the file.<\/p>\n\n\n\n
ServerSignature Off\nServerTokens Prod<\/code><\/pre>\n\n\n\n
echo -e \"ServerSignature Off\\nServerTokens Prod\" >> \/etc\/httpd\/conf\/httpd.conf<\/code><\/pre>\n\n\n\n
ServerName zabbix.example.com<\/strong><\/code><\/pre>\n\n\n\n
Set PHP Timezone<\/h3>\n\n\n\n
\/etc\/php.ini<\/code> file and set the appropriate timezone.<\/p>\n\n\n\n
sed -i 's\/^;date.timezone =\/date.timezone = Africa\\\/Nairobi\/' \/etc\/php.ini<\/code><\/pre>\n\n\n\n
Zabbix Server Backend Configuration<\/h2>\n\n\n\n
Install Zabbix 4.0 server<\/h2>\n\n\n\n
\n
Download Latest Zabbix Source Archive<\/h3>\n\n\n\n
tar xzf zabbix-4.0.1.tar.gz<\/code><\/pre>\n\n\n\n
Create Zabbix user account<\/h3>\n\n\n\n
zabbix<\/code> user account with
zabbix<\/code> group. The user should not have a home directory. This can be done as shown below;<\/p>\n\n\n\n
useradd -M zabbix<\/code><\/pre>\n\n\n\n
zabbix<\/code> group.<\/p>\n\n\n\n
id zabbix\nuid=1001(zabbix) gid=1001(zabbix<\/strong>) groups=1001(zabbix)<\/code><\/pre>\n\n\n\n
Create MySQL Database for Zabbix<\/h3>\n\n\n\n
mysql -u root -p\ncreate database zabbix character set utf8 collate utf8_bin;\ngrant all privileges on zabbix.* to zabbix@localhost identified by 'STRONGP@SSWORD';\nflush privileges;\nquit<\/code><\/pre>\n\n\n\n
cd zabbix-4.0.1\/database\/mysql\/\nmysql -u zabbix -p zabbix < schema.sql\nmysql -u zabbix -p zabbix < images.sql\nmysql -u zabbix -p zabbix < data.sql<\/code><\/pre>\n\n\n\n
Compile and Install the Zabbix source<\/h2>\n\n\n\n
cd ..\/..\/\n.\/configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2<\/code><\/pre>\n\n\n\n
\n...<\/strong>\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\/mysql -I\/usr\/include\/mysql\/mysql \n libXML2: -I\/usr\/include\/libxml2\n Net-SNMP: -I. -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 Native Jabber: no\n SNMP: yes\n IPMI: no\n SSH: no\n TLS: no\n ODBC: no\n Linker flags: -L\/usr\/lib64\/ -L\/usr\/lib64 -rdynamic \n Libraries: -lmariadb -lz -ldl -lm -lpthread -lssl -lcrypto -lxml2 -lnetsnmp -lz -lpthread -levent -lcurl -lm -ldl -lresolv -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 Linker flags: -rdynamic \n Libraries: -lz -lpthread -lcurl -lm -ldl -lresolv -lpcre \n Configuration file: \/usr\/local\/etc\/zabbix_agentd.conf\n Modules: \/usr\/local\/lib\/modules\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* <http:\/\/www.zabbix.com> *\n***********************************************************\n<\/code><\/pre>\n\n\n\n\n\n\n\n
Install Zabbix<\/h3>\n\n\n\n
make && make install<\/code><\/pre>\n\n\n\n
Initial Zabbix configuration<\/h2>\n\n\n\n
\/usr\/local\/etc\/zabbix_server.conf<\/code> and specify database connection settings; database name, user and password <\/strong>as defined above.<\/p>\n\n\n\n
vim \/usr\/local\/etc\/zabbix_server.conf<\/code><\/pre>\n\n\n\n
\n...\n<\/strong>### Option: ListenPort\n# Listen port for trapper.\n...\n<\/strong># Default:\nListenPort=10051<\/strong>\n...\n### Option: LogFile\n...\n<\/strong># LogFile=\/tmp\/zabbix_server.log\nLogFile=\/var\/log\/zabbix\/zabbix_server.log\n...<\/strong>\n### Option: DBHost\n# Database host name.\n...<\/strong>\nDBHost=localhost<\/strong>\n\n### Option: DBName\n...<\/strong>\nDBName=zabbix<\/strong>\n...<\/strong>\n### Option: DBUser\n...<\/strong>\nDBUser=zabbix<\/strong>\n...<\/strong>\n### Option: DBPassword\n...<\/strong>\nDBPassword=STRONGP@SSWORD<\/strong>\n...\n<\/strong>### Option: PidFile\n...<\/strong>\n# PidFile=\/tmp\/zabbix_server.pid\nPidFile=\/var\/run\/zabbix\/zabbix_server.pid<\/strong>\n<\/code><\/pre>\n\n\n\n
mkdir \/var\/log\/zabbix\nmkdir \/var\/run\/zabbix\/\nchown zabbix.zabbix \/var\/log\/zabbix\nchown zabbix.zabbix \/var\/run\/zabbix<\/code><\/pre>\n\n\n\n
Start Zabbix Server<\/h3>\n\n\n\n
vim \/etc\/systemd\/system\/zabbix-server.service<\/code><\/pre>\n\n\n\n
\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\n<\/code><\/pre>\n\n\n\n
vim \/etc\/systemd\/system\/zabbix-agent.service<\/code><\/pre>\n\n\n\n
\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\n<\/code><\/pre>\n\n\n\n
systemctl daemon-reload<\/code><\/pre>\n\n\n\n
systemctl start zabbix-server\nsystemctl enable zabbix-server\nsystemctl start zabbix-agent\nsystemctl enable zabbix-agent<\/code><\/pre>\n\n\n\n
Zabbix Frontend Configuration<\/h2>\n\n\n\n
~\/zabbix-4.0.1\/frontends\/php<\/code> to the Web root directory.<\/p>\n\n\n\n
Create Zabbix Web root directory<\/h3>\n\n\n\n
mkdir \/var\/www\/html\/zabbix\nrsync -avP ~\/zabbix-4.0.1\/frontends\/php\/ \/var\/www\/html\/zabbix\/\nchown -R<\/span> apache:apache<\/span> \/<\/span>var\/<\/span>www\/<\/span>html\/<\/span>zabbix\/<\/span><\/code><\/pre>\n\n\n\n
Configure PHP for Zabbix frontend<\/h4>\n\n\n\n
\/etc\/php.ini<\/code> configuration file and make the following adjustments<\/p>\n\n\n\n
max_execution_time 300\nmemory_limit 128M\npost_max_size 16M\nupload_max_filesize 5M\nmax_input_time 300\nmax_input_vars 10000\n<\/code><\/pre>\n\n\n\n
firewall-cmd --add-port={10051,10050}\/tcp --permanent\nfirewall-cmd --reload<\/code><\/pre>\n\n\n\n
systemctl restart httpd<\/code><\/pre>\n\n\n\n
Zabbix frontend initial Setup<\/h3>\n\n\n\n
http:\/\/<server_ip_or_name>\/zabbix<\/code><\/p>\n\n\n\n
<\/a><\/figure><\/div>\n\n\n
<\/a><\/figure><\/div>\n\n\n
<\/a><\/figure><\/div>\n\n\n
<\/a><\/figure><\/div>\n\n\n
<\/a><\/figure><\/div>\n\n\n
Username: Admin<\/strong>\nPassword: zabbix<\/strong><\/code><\/pre>\n\n\n\n
<\/a> You can then be able to monitor Zabbix server performance. For example, to check graphical overview of Zabbix server performance, click on Monitoring<\/strong> > Graphs<\/strong> > Group<\/strong> (Zabbix Servers) > Host<\/strong> (Zabbix Server) > Graph<\/strong> (Zabbix Server performance) > View as<\/strong> (Graph).<\/p>\n\n\n\n
<\/a><\/figure>\n\n\n\n