Ubuntu16.04安装部署监控系统Zabbix2.4
第一部分,php+mysql+nginx组件安装
1、系统更新
sudo apt-get update && sudo apt-get upgrade
2、安装php-fpm
检索系统当前自带的PHP版本:apt-cache search php-fpm
安装依赖包:sudo apt-get install make bison g++ build-essential libncurses5-dev cmake
安装php-fpm: sudo apt-get install php7.0-fpm
编辑修改配置文件:vim /etc/php/7.0/fpm/php.ini
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = Asia/Shanghai
启动php-fpm: service php7.0-fpm restart
3、安装 mysql
安装mysql: sudo apt-get install mysql-server mysql-client
安装mysql的依赖包:sudo apt-get install php7.0-gd php7.0-mysql libmysqlclient-dev
创建数据库zabbix: mysql -uzabbix -pniutianwen create zabbix
数据库授权:echo "grant all on zabbix.* to zabbix@localhost identified by 'niutianwen';" |mysql -uroot -pniutianwen(此例为本地授权,如果zabbix不是安装在本地应把localhost改为安装 zabbix的那台机器的ip地址即可)
导入数据库文件到zabbix数据库:
#cd /usr/local/src/zabbix-3.0.1/database
(tar xf zabbix_2.4.5.orig.tar.gz -C /usr/local/src/此例是我把zabbix的源代码包解压到 了/usr/local/src/目录下)
mysql -D zabbix -uroot -pniutianwen < schema.sql
mysql -D zabbix -uroot -pniutianwen < p_w_picpaths.sql
mysql -D zabbix -uroot -pniutianwen < data.sql
4、安装nginx
安装nginx: sudo apt-get install nginx
修改配置文件:
cp /etc/nginx/sites-available/default /tmp
vim /etc/nginx/sites-available/default
server {
listen 80 default_server;
root /usr/share/nginx/html/zabbix;
# server_name (可定义域名访问);
index index.php index.html index.htm index.nginx-debian.html;
location ~ \.php$ {
# include snippets/fastcgi-php.conf;
# With php7.0-cgi alone:
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# fastcgi_pass 127.0.0.1:9000;
# With php7.0-fpm:
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
测试配置文件:nginx -t
重启nginx:nginx -s reload
创建网站根目录: mkdir /usr/share/nginx/html/zabbix/
将zabbix的安装php文件导入到网站根目录:
cd /usr/local/src/zabbix-3.0.1/frontends/
sudo cp -r php/* /usr/share/nginx/html/zabbix
chmod -R zabbix zabbix /usr/share/nginx/html/zabbix/
5、安装zabbix2.4
安装编译zabbix时所必需的依赖包:
sudo apt-get install snmp libsnmp-dev snmpd libcurl4-openssl-dev fping
获取zabbix2.4版本:
wget http://repo.zabbix.com/zabbix/2.4/ubuntu/pool/main/z/zabbix/zabbix_2.4.5.orig.tar.gz
解压包:tar xf zabbix_2.4.5.orig.tar.gz -C /usr/local/src/
编译安装zabbix2.4:
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --with-net- snmp --with-libcurl
make && make install
修改配置文件vim /usr/local/zabbix/etc/zabbix_server.conf
DBHost=localhost(修改为数据库的IP,此例为本机)
DBName=zabbix
DBUser=zabbix
DBPassword=niutianwen
启动zabbix相关进程:
cd /usr/local/zabbix/sbin
./zabbix_server
./zabbix_agentd
ifconfig | grep inet -------->172.16.188.165(本地的IP地址)
在浏览器访问下172.16.188.165/zabbix
此处会遇到坑可以试着安装这些包后在retry:
apt-cache search bcmath
apt-get install php7.0-bcmath
apt-cache search mbstring
apt-get install php7.0-mbstring
apt-cache search php7.0-xml
apt-get install php7.0-xml
因为php7.0已经取消了always_populate_raw_post_data这个参数,因此要在zabbix的php安装文 件里修改一下代码:
vim /usr/share/nginx/html/zabbix/include/classes/setup/CFrontendSetup.php
// check for deprecated PHP 5.6.0 option 'always_populate_raw_post_data'
if (version_compare(PHP_VERSION, '5.6', '>=') && version_compare(PHP_VERSION, '7.0.0', '<')) {
$result[] = $this->checkPhpAlwaysPopulateRawPostData();
到此Zabbix就顺利的安装完成了!