zabbix-4.2.1安装
yum -y install make gcc gcc-c++ flex bison file libtool libtool-libs autoconf kernel-devel libjpeg libjpeg-devel libpng libpng-devel gd freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel libevent ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel gettext gettext-devel ncurses-devel gmp-devel unzip libcap lsof
#安装nginx
#nginx添加php支持
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9007;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
#编译安装php
cat << EOF >/usr/local/nginx/html/a.php
<?php
phpinfo();
?>
EOF
#访问测试a.php
#编译安装mysql
msyql -uroot -p -h localhost
create database zabbix;
grant all on zabbix.* to zabbix@localhost identified by 'zabbix';
flush privileges;
wget https://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/4.2.1/zabbix-4.2.1.tar.gz
tar -zxvf zabbix-4.2.1.tar.gz -C /data/
groupadd zabbix
useradd -g zabbix zabbix -s /sbin/nologin
yum install -y net-snmp-devel libevent libevent-devel
#报错:configure: error: Unable to use libevent (libevent check failed)
yum install libevent-devel -y
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql=/usr/local/mysql/bin/mysql_config --with-net-snmp --with-libcurl --with-libxml2
make all
make install
egrep -v "^$|^#" /usr/local/zabbix/etc/zabbix_server.conf
DBHost=localhost #默认注释掉了,直接取消注释即可
DBName=zabbix #数据库用户,我们授权的用户也是zabbix
DBUser=zabbix #默认是 root,我们授权的用户是 zabbix
DBPassword=zabbix #密码我们授权的也是 zabbix
#AlertScriptsPath=/usr/local/etc/zabbix/alertscripts
egrep -v "^$|^#" /usr/local/zabbix/etc/zabbix_agentd.conf
Server=127.0.0.1 #默认监控服务器自己,这三行不用改
ServerActive=127.0.0.1
Hostname=Zabbix server
UnsafeUserParameters=1 #允许所有的字符是在用户定义的参
source /data/zabbix-4.2.1/database/mysql/schema.sql;
source /data/zabbix-4.2.1/database/mysql/images.sql;
source /data/zabbix-4.2.1/database/mysql/data.sql;
cd /data/zabbix-4.2.1/misc/init.d
cp fedora/core/* /etc/init.d/
vim /etc/init.d/zabbix_server
BASEDIR=/usr/local/zabbix #找到此行,并修改
vim /etc/init.d/zabbix_agentd
BASEDIR=/usr/local/zabbix #找到此行,并修改
#编辑 php 页面控制文件
cp -r /data/zabbix-4.2.1/frontends/php/* /usr/local/nginx/html/
sudo -u www /usr/local/zabbix/sbin/zabbix_server
/usr/local/nginx/sbin/nginx -s reload ; /etc/init.d/php-fpm7 restart
#zabbix无法启动:
#1、配置文件是否正常
#2、PHP的session文件
#3、zabbix_server.conf DBhost随意修改会造成server无法正常启动
#检测环境,发现环境检测无法通过,需要做相应调整
vim /usr/local/php7/etc/php.ini
post_max_size = 16M #修改
max_execution_time = 300 #修改
max_input_time = 300 #修改
date.timezone = Asia/Shanghai #此行有注释,去注释并修改
#缺少ldap.so模块
ls /usr/local/php7/lib/php/extensions/no-debug-non-zts-20160303
wget http://soft.down.yaosanhao.com:9000/php/php-src.tar.gz && tar xf php-src.tar.gz
cd /data/file_library/php-src/ext/ldap
/usr/local/php7/bin/phpize
./configure --with-php-config=/usr/local/php7/bin/php-config --with-ldap && make && make install
ls /usr/local/php7/lib/php/extensions/no-debug-non-zts-20160303
#[root@iZbp1ik57sceo3yje36q4uZ etc]# /usr/local/nginx/sbin/nginx -s reload ; /etc/init.d/php-fpm7 restart
#Gracefully shutting down php-fpm . done
#Starting php-fpm [24-May-2019 18:57:18] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/php7/lib/php/extensions/no-debug-non-zts-20160303/php_ldap.dll' - /usr/local/php7/lib/php/extensions/no-debug-non-zts-20160303/php_ldap.dll: cannot open shared object file: No such file or directory in Unknown on line 0
#done
vim /usr/local/php7/etc/php.ini
extension=ldap.so
/usr/local/nginx/sbin/nginx -s reload ; /etc/init.d/php-fpm7 restart
#/etc/init.d/zabbix_server无法启动
sudo -u www /usr/local/zabbix/sbin/zabbix_server
sudo -u www /usr/local/zabbix/sbin/zabbix_agentd
#添加中文
cd /data/wwwroot/zabbix/fonts/
cd /data/wwwroot/zabbix/include
sed -i 's/DejaVuSans/simkai/g' defines.inc.php
少年不识愁滋味,爱上层楼。爱上层楼。为赋新词强说愁。
而今识尽愁滋味,欲说还休。欲说还休。却道天凉好个秋。