centos 7 安装zabbix-4.0
第一步:安装nginx
############安装Nginx###########
yum localinstall http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum install -y nginx
systemctl start nginx.service
systemctl enable nginx
关闭自带firewalld 防火墙服务
systemctl stop firewalld
禁止开机启动firewalld 服务
systemctl mask firewalld
setenforce 0
第二步:安装php
#########安装PHP###############
检查当前安装的PHP包
yum list installed | grep php
如果有安装的PHP包,先删除他们
yum remove php.x86_64 php-cli.x86_64 php-common.x86_64 php-gd.x86_64 php-ldap.x86_64 php-mbstring.x86_64 php-mcrypt.x86_64 php-mysql.x86_64 php-pdo.x86_64
安装PHP rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum 安装PHP
yum install php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-mysql.x86_64 php70w-pdo.x86_64
安装PHP FPM
yum install php70w-fpm
systemctl start php-fpm
php -v
systemctl enable php-fpm
第三步安装:zabbix
###########添加EPEL源########
rpm -ivh http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
########安装zabbix###########
wget http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm
rpm -ivh zabbix-release-3.5-1.el7.noarch.rpm
yum search zabbix ###查看zabbix 安装包####
yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-get
第四步:安装mysql
#######安装mysql数据库#########
wget http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql57-community-release-el7-7.noarch.rpm
rpm -vhi mysql57-community-release-el7-7.noarch.rpm
yum install -y mysql-community-server
systemctl start mysqld
systemctl enable mysqld
vi /etc/my.cnf ###在最后一行添加 validate_password = off ######
systemctl restart mysqld
grep 'temporary password' /var/log/mysqld.log #####查看mysql默认生成的密码######
mysql_secure_installation #初始化数据库信息
######创建zabbix用户#########
mysql -uroot -p
root
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by 'zabbix';
mysql> flush privileges;
exit
######创建zabbix 数据库########
zcat /usr/share/doc/zabbix-server-mysql-4.0.0/create.sql.gz | mysql zabbix -uzabbix -pzabbix
#########修改zabbix配置文件#######
vi /etc/zabbix/zabbix_server.conf
########查看zabbix配置文件########
[root@localhost ~]# grep ^DB /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
########################
#######修改配置文件php.ini 文件########
sed -i "s/max_execution_time = 30/max_execution_time = 300/" /etc/php.ini
sed -i 's/max_input_time = 60/max_input_time = 300/' /etc/php.ini
sed -i 's/post_max_size = 8M/post_max_size = 16M/' /etc/php.ini
sed -i 's/post_max_size = 8M/post_max_size = 16M/' /etc/php.ini
sed -i 's_;date.timezone =_date.timezone =Asia/Shanghai_' /etc/php.ini
systemctl restart php-fpm
第五步:整合nginx与php
server {
#listen 8080;
listen 80;
server_name zabbix.nuoya.ph;
root /usr/share/zabbix;
index index.html index.htm index.php;
include /etc/nginx/default.d/*.conf;
#rewrite ^(.*) https://$server_name$1 permanent;
# return 301 https://zabbix.aoyoujiasu88.com$request_uri;
location / {try_files $uri $uri/ /index.php?$query_string;
}
#监控PHP状态
location ~ ^/(status|ping)$
{
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
}
#监控nginx 状态
location /ngx_status
{
stub_status on;
access_log off;
}
location ~ \.php$ {
include fastcgi.conf;
#try_files $uri /index.php =404;
#fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
#fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
# Settings for a TLS enabled server.
#
# server {
# listen 443;
#server_name zabbix.aoyoujiasu88.com ;
# root /usr/share/zabbix;
# ssl on;
# ssl_certificate /etc/nginx/conf.d/certificate.crt;
# ssl_certificate_key /etc/nginx/conf.d/private.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 10m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# # Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
# error_page 404 /404.html;
# location = /40x.html {
# }
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# }
启动nginx
systemctl start nginx
systemctl enable nginx
启动zabbix
systemctl start zabbix-server
systemctl enable zabbix-server
http://本机IP/zabbix
####用户名:Admin 密码:登入时候设置的密码######
zabbix中文显示优化
安装方法如下:
wget https://github.com/echohn/zabbix-zh_CN/archive/master.zip
unzip master.zip
rm /usr/share/zabbix/locale/zh_CN/LC_MESSAGES/frontend.mo
cp zabbix-zh_CN-master/frontend.mo /usr/share/zabbix/locale/zh_CN/LC_MESSAGES/frontend.mo
systemctl restart nginx
systemctl restart zabbix-server
把Windows系统中找到C:\Windows\Fonts中的楷体(常规)复制到windows桌面上
cd /usr/share/zabbix/fonts/
导入simkai.ttf(常规字体)
chmod 777 simkai.ttf
cp graphfont.ttf graphfont.ttf.bak
mv simkai.ttf graphfont.ttf
mv:是否覆盖"graphfont.ttf"? y
######centos 7 zabbix agnet 安装####
wget http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm
rpm -ivh zabbix-release-3.5-1.el7.noarch.rpm
yum -y install zabbix-agent
iptables -I INPUT -p tcp --dport 10050 -j ACCEPT
service iptables save
###配置/etc/zabbix/zabbix_agentd.conf 文件里面的Server 地址###
#Server= zabbix sever IP ###
##启动 zabbix agent ####
systemctl start zabbix-agent
systemctl enable zabbix-agent
#####centos 6 zabbix agnet 安装####
wget http://repo.zabbix.com/zabbix/3.5/rhel/6/x86_64/zabbix-agent-4.0.0-1.1alpha2.el6.x86_64.rpm
rpm -ivh zabbix-agent-4.0.0-1.1alpha2.el6.x86_64.rpm
###配置/etc/zabbix/zabbix_agentd.conf 文件里面的Server 地址###
#Server= zabbix sever IP ###
##启动 zabbix agent ####
service zabbix-agent start