First Production Ubuntu Server 14.04 running:
- MariaDB (Mysql)
- Nginx
- Php5-fpm
- Zabbix 2.2.*
All Stock Packages no Extra Repositories is needed. It Awesome!
DIY Ubuntu Server 14.04, it extremely easy. I mount /var on seperate hard disk for Mysql perfomance. MariaDB have many advantage than Mysql (belong to Oracle already).
hostname zabbix.mydomain.vn && echo 'zabbix.mydomain.vn ' > /etc/hostname
Note:
- datetime: sync your server to your NTP server.
- Notice your mysql password
sudo apt-get update && apt-get -y dist-upgrade
sudo apt-get install mariadb-server nginx php5-fpm php5-mysql snmp libnet-snmp-perl snmp-mibs-downloader
sudo apt-get install zabbix-server-mysql zabbix-frontend-php zabbix-agent
MariaDB Mysql
create zabbix user, zabbix database, grant privileges for zabbix user on database zabbix.
mysql -u root -p
Enter password: your root password at MariaDB installation
create user 'zabbix'@'localhost' identified by 'Zabbix_DB_Passwd';
create database zabbix;
grant all privileges on zabbix.* to 'zabbix'@'localhost';
flush privileges;
exit;
Php5-fpm
Edit /etc/php5/fpm/php.ini for Zabbix
[PHP]
.....
max_execution_time = 300
memory_limit = 128M
post_max_size = 16M
upload_max_filesize = 2M
max_input_time = 300
......
[Date]
date.timezone = Asia/Ho_Chi_Minh
Edit [www] pool /etc/php5/fpm/pool.d/www.conf
[www]
user = www-data
group = www-data
listen = /var/run/php5-fpm.sock
#### It depend on my server hardware, you can leave it as default ^^ #####
pm = dynamic
pm.max_children = 24
pm.start_servers = 8
pm.min_spare_servers = 5
pm.max_spare_servers = 10
pm.max_requests = 50000
chdir = /
Restart php5-fpm
sudo service php5-fpm restart
Nginx
In my case, this box is dedicated for Zabbix, so default site will be zabbix, Php web app root dir is in /usr/share/zabbix.
Edit /etc/nginx/sites-available/default
server {
listen 80 default_server;
root /usr/share/zabbix;
index index.php index.html index.htm;
server_name zabbix.mydomain.vn;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
Restart Nginx
sudo service nginx restart
Zabbix-server
Init Zabbix database:
cd /usr/share/zabbix-server-mysql/
mysql -u zabbix -p zabbix < schema.sql
mysql -u zabbix -p zabbix < images.sql
mysql -u zabbix -p zabbix < data.sql
sudo cp /usr/share/doc/zabbix-frontend-php/examples/zabbix.conf.php.example /etc/zabbix/zabbix.conf.php
Edit /etc/zabbix/zabbix.conf.php
$DB['TYPE'] = 'MYSQL';
$DB['SERVER'] = 'localhost';
$DB['PORT'] = '0';
$DB['DATABASE'] = 'zabbix';
$DB['USER'] = 'zabbix';
$DB['PASSWORD'] = 'Zabbix_DB_Passwd';
$ZBX_SERVER = 'zabbix.mydomain.vn';
$ZBX_SERVER_PORT = '10051';
Enable Zabbix monster in /etc/default/zabbix-server
START=yes
CONFIG_FILE="/etc/zabbix/zabbix_server.conf"
Edit /etc/zabbix/zabbix_server.conf
LogFile=/var/log/zabbix-server/zabbix_server.log
PidFile=/var/run/zabbix/zabbix_server.pid
DBName=zabbix
DBUser=zabbix
DBPassword=Zabbix_DB_Passwd
AlertScriptsPath=/etc/zabbix/alert.d/
FpingLocation=/usr/bin/fping
Start up Zabbix monster
service zabbix-sever restart
Zabbix-agent
Hostname is very important. It must be same with Hostname in Host Configuration in Zabbix Dashboard.
I disable ServerActive => My Zabbix agent will run in Passive mode (
Server directive). The Server will open a port and then visit his Agent port
10050 and ask for his money :D
Edit /etc/zabbix/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix-agent/zabbix_agentd.log
LogFileSize=0
Server=127.0.0.1 #Address of Zabbix Server
Hostname=zabbix.ssis.edu.vn #FQDN of monitored host
Restart Zabbix-agent
sudo service zabbix-agent restart
Zabbix Dashboard
Go to Zabbix web dashboard:
http://zabbix.mydomain.vn
Defaut username:
Admin
Default password:
zabbix
Add host monitoring will be on next Part
Troubleshooting
MariaDB: /var/log/mysql/error.log
Nginx: /var/log/nginx/error.log
Php5-fpm: /var/log/php5-fpm.log
Zabbix-server: /var/log/zabbix-server/zabbix_server.log
More verbosity? Turn on DebugLevel=4 at /etc/zabbix/zabbix_server.conf
Reference