前言
zabbix是一個基于WEB界面的提供分布式系統(tǒng)監(jiān)視以及網(wǎng)絡(luò)監(jiān)視功能的企業(yè)級的開源解決方案芯义。
1.運行環(huán)境的搭建
zabbix 3.0+以上的版本需要php5.4以上的版本甫恩,自己的機器php版本是5.3.3所以本來打算安裝zabbix LTS2.2這個版本含潘。(筆者比較懶╭(╯^╰)╮)然而老大表示裝新的比較好,所以又重新擼了一遍php
在這里我們選擇了mysql作為zabbix的數(shù)據(jù)庫,apache作為zabbix的web服務(wù)器
yum install httpd mysql-server mysql-devel net-snmp-devel gcc
下載php(筆者怕系統(tǒng)版本太低坑了,所以選擇是現(xiàn)在相對比較老的php5.6這個版本)
看這個架勢只能自己編譯安裝了嚕(╮(╯╰)╭)
tar xf php-5.6.31.tar.gz
cd php-5.6.31
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/lib --enable-track-vars --with-xml --with-mysql-dir=/usr/include/mysql/mysql.h --with-zlib-dir=/usr/lib
編譯完成之后進行安裝
make install
各種報錯安裝,把路徑鏈接正確之后終于= =搞定
PHP 5.6.31 (cli) (built: Jul 7 2017 23:56:31)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
2.下載安裝zabbix
經(jīng)過多方權(quán)衡我決定使用3.2.6這個版本(因為這就是當(dāng)前最高版本了=甚垦。=
下載好之后我們解壓這個造孽的壓縮包
tar xf zabbix-3.2.6.tar.gz
然而這是源碼,少不了再編譯一次=。=
./configure --prefix=/usr/local --enable-server --enable-agent --enable-ipv6--with-mysql --with-net-snmp
編譯過程因為環(huán)境不同會提示奇奇怪怪的錯誤艰亮,這個時候就遇水搭橋見招拆招闭翩,缺啥裝啥啦。
3.初始化mysql數(shù)據(jù)庫
cd ./database/mysql
service mysqld start
設(shè)置數(shù)據(jù)庫管理員的賬號和密碼
mysqladmin –u root password root
輸入root用戶密碼
mysql –u root –p
創(chuàng)建zabbix數(shù)據(jù)庫
Mysql> create database zabbix character set utf8;
授權(quán)本機通過賬號account密碼password訪問數(shù)據(jù)庫的所有權(quán)限
Mysql> grant all on account.* TO account@'localhost' identified by 'password';
Mysql> flush privileges;
將zabbix數(shù)據(jù)庫設(shè)置導(dǎo)入mysql
mysql -h localhost -uroot -proot zabbix <schema.sql
mysql -h localhost -uroot -proot zabbix <images.sql
mysql -h localhost -uroot -proot zabbix <data.sql
4.修改配置文件
修改apache的配置文件
vim /etc/httpd/conf/httpd.conf
DirectoryIndex index.html index.html.var index.php
修改zabbix配置
vim
DBName=zabbix
DBUser=zabbix
DBPassword=zabbixpass
配置zabbix啟動項可通過SysV來管理服務(wù)的啟停迄埃。
cp misc/init.d/fedora/core5/zabbix_server /etc/init.d/
cp misc/init.d/fedora/core5/zabbix_agentd /etc/init.d/
這個時候通過zabbix_server命令就可以啟動服務(wù)啦
zabbix_server
創(chuàng)建apache的配置文件
vim /etc/httpd/conf.d/zabbix.conf
把下面的內(nèi)容復(fù)制進去
Alias /zabbix /usr/share/zabbix
<Directory "/usr/share/zabbix">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
<IfModule mod_php5.c>
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value always_populate_raw_post_data -1
php_value date.timezone Asia/Shanghai
</IfModule>
</Directory>
<Directory "/usr/share/zabbix/conf">
Order deny,allow
Deny from all
<files *.php>
Order deny,allow
Deny from all
</files>
</Directory>
<Directory "/usr/share/zabbix/app">
Order deny,allow
Deny from all
<files *.php>
Order deny,allow
Deny from all
</files>
</Directory>
<Directory "/usr/share/zabbix/include">
Order deny,allow
Deny from all
<files *.php>
Order deny,allow
Deny from all
</files>
</Directory>
<Directory "/usr/share/zabbix/local">
Order deny,allow
Deny from all
<files *.php>
Order deny,allow
Deny from all
</files>
</Directory>
重啟apache服務(wù)器
service httpd start