Zabbix Server Setup on Ubuntu(LNMP)

Author@henry 20160218

Installing Zabbix Server

apt-get install zabbix-server-mysql zabbix-frontend-php

Zabbix Server Configuration

vi /etc/zabbix/zabbix_server.conf

Search for the following properties and set them accordingly. Some may already be set correctly, and some you may have to add. Choose a password as well:

DBName=zabbix
DBUser=zabbix
DBPassword=<YOUR_PASSWD>

MySQL Configuration

mysql -u root -p
password:
> create user 'zabbix'@'localhost' identified by '<DB_PASSWD>';
> create database zabbix;
> grant all privileges on zabbix.* to 'zabbix'@'localhost';
> flush privileges;
> \q;
bye

import database tables;

cd /usr/share/zabbix-server-mysql/
sudo gunzip *.gz

mysql -u zabbix -p zabbix < schema.sql
mysql -u zabbix -p zabbix < images.sql
mysql -u zabbix -p zabbix < data.sql

PHP-FPM Configuration

vi /etc/php5/fpm/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

restart php-fpm

service php5-fpm restart

Zabbix Configuration

copy the Zabbix-specific php file into the configuration directory:

cp /usr/share/doc/zabbix-frontend-php/examples/zabbix.conf.php.example /etc/zabbix/zabbix.conf.php

edit configuration file

vi /etc/zabbix/zabbix.conf.php

Edit the following values. Use the same info as when you set up the database earlier:

$DB['DATABASE'] = 'zabbix';
$DB['USER'] = 'zabbix';
$DB['PASSWORD'] = '<YOUR_PASSWD>'

$ZBX_SERVER                     = '<SERVER_IP>';
$ZBX_SERVER_PORT                = '10051';
$ZBX_SERVER_NAME                = 'zabbix';

Nginx Configuration

add site into Nginx's site-available directory

vi /etc/nginx/site-available/zabbix

sample nginx server configuration file:

root@localhost:/etc/nginx/sites-available# cat zabbix 
server {
    listen 80;
    server_name monitor.domainname.com
    access_log /var/log/nginx/monitor_access.log;
    error_log /var/log/nginx/monitor_error.log;

    root /usr/share/zabbix;

    location / { 
        index index.php;
        error_page 403 404 502 503 504 /zabbix/index.php;
    }

    location ~ \.php($|/) {
        fastcgi_index index.php;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
     }

    location ~ \.(jpg|jpeg|gif|png|ico)$ {
        access_log off; 
        expires 33d; 
    }
}

enable zabbix server

cd /etc/nginx/site-enabled
ln -s ../site-available/zabbix
service nginx restart

Start Zabbix Service

vi /etc/default/zabbix-server

Go to the bottom and adjust the "START" property to read "yes":

START=yes

start zabbix service

service zabbix-server start

Front End Configuration

Visit you site use following url

http://monitor.yourdomain.com/

You will be presented with a login screen. The default credentials are as follows:

Username = admin
Password = zabbix

Login succeed, everything works, congrat!

Bug fix

  • Bug:
    ini_set(): Use of mbstring.internal_encoding is deprecated
    
  • Fix:
    vi /usr/share/zabbix/include/locales.inc.php
    

    Comment out the following line

    # line 25: 
    ini_set('mbstring.internal_encoding', 'UTF-8');
    

Ref:

暂无评论

发表评论

电子邮件地址不会被公开。 必填项已用*标注