freebsd 手工安装zabbix2.0 php,zabbix 服务端,子客户端安装配置日志

本文详细记录了在已有MySQL5.6.45和PHP7的Linux环境中安装和配置Zabbix 2.4.8的过程,包括创建数据库、添加用户、编译安装Zabbix、配置PHP参数、设置防火墙规则以及解决因版本差异导致的错误。过程中提到了如何处理PHP的类型要求问题和监控图像字体替换,确保Zabbix服务端和客户端的正常部署和通信。
摘要由CSDN通过智能技术生成

针对已经有mysql nginx php 的linux环境 ,zabbix2.4.8对不同版本的mysql会报不同的错,php也一样。

这只是针对本人的环境下的安装部署,mysql是5.6.4rmp安装,php7+。

服务端#创建数据库

create database zabbix character set utf8;

grant all privileges on zabbix.* to zabbix_user@'127.0.0.1' identified by '123456';

grant all privileges on zabbix.* to zabbix_user@'localhost' identified by '123456';

flush privileges;

#添加用户

useradd -s /sbin/nologin -M zabbix

#本站blog已下载一个

wget --no-check-certificate https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.4.8/zabbix-2.4.8.tar.gz

tar -zxvf zabbix-2.4.8.tar.gz

cd zabbix-2.4.8

cd database

cd mysql

mysql -h 127.0.0.1 -uzabbix_user -p zabbix< schema.sql

mysql -h 127.0.0.1 -uzabbix_user -p zabbix < images.sql

mysql -h 127.0.0.1 -uzabbix_user -p zabbix < data.sql

cd ../../

yum -y install net-snmp

yum -y install net-snmp-devel

./configure --prefix=/usr/local/zabbix --with-mysql --with-net-snmp --with-libcurl --enable-server --enable-proxy

#报错 仅仅以于已经重装rpm安装新版mysql 5.6.45的情况

#https://www.isres.com/database/274.html

[root@zabbix-2.4.8]# find / -name libmysqlclient.a

/usr/lib64/mysql/libmysqlclient.a

cp /usr/lib64/mysql/libmysqlclient.a /usr/local/lib

#再编译后即可进行安装

make && make install

#报错 仅仅以于已经重装rpm安装新版mysql 5.6.45 mysql的情况

#undefined reference to `operator new[](unsigned long)'

rpm -ivh MySQL-shared-5.6.45-1.el6.x86_64.rpm

ln -s /usr/local/zabbix/sbin/* /usr/local/sbin/

ln -s /usr/local/zabbix/bin/* /usr/local/bin/

cp /usr/tmp/zabbix-2.4.8/misc/init.d/fedora/core/zabbix_server /etc/rc.d/init.d/zabbix_server

chmod +x /etc/rc.d/init.d/zabbix_server

chkconfig zabbix_server on

sed -i 's/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix/g' /etc/rc.d/init.d/zabbix_server

echo "zabbix-trapper 10051/tcp # Zabbix Trapper" >> /etc/services

echo "zabbix-trapper 10051/udp # Zabbix Trapper" >> /etc/services

sed -i 's/DBUser=root/DBUser=zabbix_user/g' /usr/local/zabbix/etc/zabbix_server.conf

sed -i 's/DBUser=root/DBUser=zabbix_user/g' /usr/local/zabbix/etc/zabbix_server.conf

sed -i 's/# ListenPort=10051/ListenPort=10051/g' /usr/local/zabbix/etc/zabbix_server.conf

sed -i 's/# ListenIP=0.0.0.0/ListenIP=0.0.0.0/g' /usr/local/zabbix/etc/zabbix_server.conf

#修改php.ini 逐条运行

sed -i 's/post_max_size = 8M/post_max_size = 16M/g' /usr/local/php/etc/php.ini

sed -i 's/max_execution_time = 30/max_execution_time = 300/g' /usr/local/php/etc/php.ini

sed -i 's/max_input_time = 60/max_input_time = 300/g' /usr/local/php/etc/php.ini

sed -i 's/\;date.timezone =/date.timezone = "Asia\/Shanghai"/g' /usr/local/php/etc/php.ini

service php-fpm restart

#仅于对使用本站一件安装lnp脚本的情况,web目录在/home/public_html

mkdir -p /home/public_html/zabbix

chown www:www /home/public_html/zabbix

cp -r frontends/php/* /home/public_html/zabbix/

vim /home/public_html/zabbix/include/classes/setup/CFrontendSetup.php

添加 $current = -1;

public function checkPhpAlwaysPopulateRawPostData() {

$current = ini_get('always_populate_raw_post_data');

$current = -1;

return array(

'name' => _('PHP always_populate_raw_post_data'),

'current' => ($current != -1) ? _('on') : _('off'),

'required' => _('off'),

'result' => ($current != -1) ? self::CHECK_FATAL : self::CHECK_OK,

'error' => _('PHP always_populate_raw_post_data must be set to -1.')

);

}

service zabbix_server start

cd /usr/local/nginx/conf/vhost/

cp default.conf zabbix.conf

vim zabbix.conf

server {

listen 8384;

server_name localhost;

access_log /home/public_html/zabbix/access.log;

location / {

root /home/public_html/zabbix/;

index index.php index.html index.htm;

}

error_page 500 502 503 504 /50x.html;

location = /50x.html {

root /usr/local/nginx/html;

}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

location ~ \.php$ {

root /home/public_html/zabbix/;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

location ~ /\.ht {

deny all;

}

}

chown -R www:www /home/public_html/zabbix/

service nginx restart

iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 8384 -j ACCEPT

/etc/rc.d/init.d/iptables save

service iptables restart

http://xxx.10.81.xxx:8384/ 访问通过了

帐号admin 密码zabbix

#登录局部后报了A non well formed numeric value encountered [dashboard.php:140 → 原因php版本高对类型有要求

vim /home/public_html/zabbix/include/func.inc.php 换掉$val *= 1024;

function str2mem($val) {

$val = trim($val);

$last = strtolower(substr($val, -1));

switch ($last) {

case 'g':

#$val *= 1024;

$val = intval($val)*1024;

/* falls through */

case 'm':

#$val *= 1024;

$val = intval($val)*1024;

/* falls through */

case 'k':

#$val *= 1024;

$val = intval($val)*1024;

}

return $val;

}

替换监控图像上系统默认的字体 #默认字体不支持中文,如果不替换,图像上会显示乱码

在Windows系统中的C:WindowsFonts目录中复制出一个中文字体文件,例如msyh.ttf

把字体文件msyh.ttf上传到zabbix站点根目录下fonts文件夹中

例如:/usr/local/nginx/html/zabbix/fonts

备份默认的字体文件:DejaVusSans.ttf-bak

修改msyh.ttf名称为DejaVusSans.ttf

客户端部署在另一台,完成后需要做iptables对服务端的开放useradd -s /sbin/nologin -M zabbix

wget https://www.isres.com/file/zabbix-2.4.8.tar.gz

tar -zxvf zabbix-2.4.8.tar.gz

cd zabbix-2.4.8

./configure --prefix=/usr/local/zabbix --with-libcurl --enable-agent

make && make install

ln -s /usr/local/zabbix/sbin/* /usr/local/sbin/

ln -s /usr/local/zabbix/bin/* /usr/local/bin/

cp /usr/tmp/zabbix-2.4.8/misc/init.d/fedora/core/zabbix_agentd /etc/rc.d/init.d/zabbix_agentd

chmod +x /etc/rc.d/init.d/zabbix_agentd

chkconfig zabbix_agentd on

sed -i 's/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix/g' /etc/rc.d/init.d/zabbix_agentd

echo "zabbix-agent 10050/tcp # Zabbix Agent" >> /etc/services

echo "zabbix-agent 10050/tcp # Zabbix Agent" >> /etc/services

sed -i 's/# PidFile=\/tmp\/zabbix_agentd.pid/PidFile=\/tmp\/zabbix_agentd.pid/g' /usr/local/zabbix/etc/zabbix_agentd.conf

sed -i 's/Server=127.0.0.1/Server=192.168.10.55/g' /usr/local/zabbix/etc/zabbix_agentd.conf

service zabbix_agentd restart

centos6

iptables -I INPUT -s 192.168.10.55 -m state --state NEW -m tcp -p tcp --dport 10050 -j ACCEPT

/etc/rc.d/init.d/iptables save

service iptables restart

centos7

firewall-cmd --permanent --add-rich-rule 'rule family=ipv4 source address=192.168.10.55/32 port port=10050 protocol=tcp accept'

systemctl restart firewalld.service

非特殊说明,本博所有文章均为博主原创。

最新文章

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值