ZABBIX INSTALLATION

Zabbix is a networked server and software monitor. It can be used to keep track of multiple physical or virtual private server instances.

The client-server model that Zabbix employs allows the cloud server to collect rich sets of data that be used to graph historical trends. This can be very useful for monitoring the performance of the websites and applications hosted on your VPS.

Zabbix Installation Steps

  1. Create user zabbix as super root user.
groupadd -g 1090 zabbix
useradd -u 1090 -g 1090 -s /bin/bash -d /home/zabbix zabbix
mkdir /home/zabbix zabbix
chown -R zabbix:zabbix
passwd zabbix
password
su zabbix
mkdir -p downloads 

Install Apache and Php Dependencies

 apt-get install build-essential
apt-get build-dep apache2
apt-get install openssl libssl-dev libfreetype6-dev libxslt-dev libapr1 libapr1-dev libgdbm-dev  libsnmp-dev
aptitude install libjpeg8-dev 

2. Download apache and php under downloads folder and compile in under zabbix user. Compile apache with below parameter. You can add parameters in one file like
For Apache and php installation refer https://hari2ulinux.com/apache/

./ins.sh
"./configure" \
"--prefix=/home/zabbix/apache" \
"--enable-so" \
"--enable-cgi" \
"--enable-info--enable-rewrite" \
"--enable-speling" \
"--enable-usertrack" \
"--enable-deflate" \
"--enable-mime-magic" \

make

make install 

3. If we get APR error while compiling apache we can do following.

Download link for APR tar file.

http://apr.apache.org/download

Download and extract the tar file

tar -zxvf apr-1.5.0.tar.gz
mv apr-1.5.0 /home/zabbix/downloads/httpd-2.4.7/srclib/apr
tar -zxvf apr-util-1.5.3.tar.gz
mv apr-util-1.5.3  /home/zabbix/downloads/httpd-2.4.7/srclib/apr-util

Parameter for the Apache with apr.

./configure --prefix=/home/zabbix/apache --enable-so --enable-cgi --enable-info--enable-rewrite --enable-speling --enable-usertrack --enable-deflate --enable-ssl --with-included-apr 

4.  Install php with the Below parameter.We can put this in one file lets ins.sh and run to compile.

./ins.sh
'./configure' \
'--with-apxs2=/home/zabbix/apache/bin/apxs' \
'--with-mysql' \
'--prefix=/home/zabbix/apache/php' \
'--with-config-file-path=/home/zabbix/apache/php' \
'--with-zlib' \
'--enable-mbstring' \
'--with-mysqli' \
'--with-curl' \
'--with-gd' \
'--with-xsl' \
'--enable-force-cgi-redirect' \
'--with-gettext' \
'--with-gdbm' \
'--enable-bcmath' \
'--enable-sockets' \
'--with-jpeg-dir' \
'--with-freetype-dir' \
"$@"

make
make install 

If file /home/zabbix/apache/modules/libphp5.so does not exist or is an older version, type this (change this to libphp4.so for PHP 4):

cp -p .libs/libphp5.so /home/zabbix/apache/modules 

Install the php.ini file:

 cp -p php.ini-production /home/zabbix/apache/php/php.ini 

We need to adjust some values for the php processing of our monitoring data. Open the php configuration file:

vi /home/zabbix/apache/php.ini 

Search for and adjust the following entries. If they do not exist, add them:

post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = UTC 

Add these directives are in httpd.conf (if already there, verify they are correct):

# Make sure there's only **1** line for each of these 2 directives:
# Use for PHP 4.x:
#LoadModule php4_module modules/libphp4.so
#AddHandler php-script .php

# Use for PHP 5.x:
LoadModule php5_module modules/libphp5.so
AddHandler php5-script .php

# Add index.php to your DirectoryIndex line:
DirectoryIndex index.html index.php

AddType text/html .php

# PHP Syntax Coloring
# (optional but useful for reading PHP source for debugging):
AddType application/x-httpd-php-source phps  </strong></blockquote>
Access your webserver with your favorite browser. The following is a good test page to use for PHP. You only need the one line in bold is needed to display PHP configuration information. Name

the file anything you want, but it must end with .php, such as phpinfo.php, and move the file to your web server content directory (for me /home/zabbix/apache/htdocs), with read permission set:

vi phpinfo.php
<html>
<head>
<title>PHP Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<h1>PHP Test</h1>
<b>An Example of PHP in Action</b>

<?php echo "The Current Date and Time is:  "; echo date("g:i A l, F j Y.");?>
<h2>PHP Information</h2>
<?php phpinfo(); ?>

</body>
</html>  

5. Downloads latest zabbix source package from below link
http://www.zabbix.com/download.php
Parameter for zabbix compiling.

./configure --prefix=/home/zabbix/zabbix --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --enable-ssl --enable-cgi
make
make install 

6. Copy  from zabbbix source file  frontends/php/* to / /home/zabbix/apache/htdocs/zabbix

7. Now we have to configure MYSQL for zabbix server.

Install mysql server from root user.

sudo apt-get install mysql-server 

8. Log into MySQL as the root user using the password that you set up during installation:

 mysql -u root -p 

First, create a user for Zabbix that matches the information we entered in the "installationpath/zabbix_server.conf" file. Make sure to use the same information:

 create user 'zabbix'@'localhost' identified by 'Your.Password.Here'; 

Next, we will create the Zabbix database:

 create database zabbix; 

Give control over the new database to the new user we created:

 grant all privileges on zabbix.* to 'zabbix'@'localhost'; 

The following line will implement our new permissions:

 flush privileges; 

We are now done with the initial MySQL configuration. Exit back to the shell:

 exit; 

Now that we have our database set up, we can import the files that Zabbix needs to function We can find below files under zabbix database source file.
Enter the password for the user "zabbix" that you configured when prompted:
Go to /home/zabbix//database

 mysql -u zabbix -p zabbix < schema.sql 

Do the same with the images file:

 mysql -u zabbix -p zabbix < images.sql 

And finally, import the data file:

 mysql -u zabbix -p zabbix < data.sql 

9. Make changes to  /home/zabbix/zabbix/etc/zabbix_server.conf and /home/zabbix/zabbix/etc/zabbix_agent.conf as required.

Changes to /home/zabbix/zabbix/etc/zabbix_server.conf.
Edit the following values. Use the same info as when you set up the database earlier:

DBName=zabbix
DBUser=root
DBPassword=abc 

Put zabbix server ip in /home/zabbix/zabbix/etc/zabbix_agent.conf

10. Copy  startup for agent and server in /etc/init.d/ folder and create symlink.

cp /home/zabbix/zabbix/sbin/zabbix_agentd /etc/init.d/
cp /home/zabbix/zabbix/sbin/zabbix_server /etc/init.d/

Done with Zabbix installation.
Enjoy!!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s