目錄
7.2 針對php安裝ldap ///不做此步驟 ,後面會有警告
1 提前準備
centos 7.6 IP: 192.168.10.11
jdk 1.8.181
zabbix 4.2.7
php 5.6.36
nginx 1.14.2
2 關閉selinux(重啓)和防火牆
[root@ZabbixServer ~]# vim /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled ///此改爲disabled ,並重啓服務器
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
[root@ZabbixServer ~]# systemctl stop firewalld
[root@ZabbixServer ~]# systemctl disable firewalld
3 jdk安裝
[root@ZabbixServer ~]# cd /opt/ ///java包已放在此目錄
[root@ZabbixServer opt]# tar zxf jdk-8u181-linux-x64.tar.gz
[root@ZabbixServer opt]# cat >> /etc/profile << EOF
> #jdk環境配置
> export JAVA_HOME=/opt/jdk1.8.0_181
> export CLASSPATH=\$CLASSPATH:\$JAVA_HOME/lib/
> export PATH=\$PATH:\$JAVA_HOME/bin
> EOF
[root@ZabbixServer opt]# source /etc/profile
[root@ZabbixServer opt]# java -version
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
4 安裝相關的組件
yum install -y gcc gcc-c++ curl curl-devel net-snmp net-snmp-devel perl-DBI libevent-devel bzip2
5 數據庫安裝配置
[root@ZabbixServer ~]# yum install mariadb*
[root@ZabbixServer ~]# systemctl start mariadb
[root@ZabbixServer ~]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@ZabbixServer ~]# mysql -uroot ///創建數據庫
MariaDB [(none)]> create database zabbix charset=utf8;
MariaDB [(none)]> grant all on zabbix.* to zabbix@localhost identified by 'zabbix123';
MariaDB [(none)]> grant all on zabbix.* to zabbix@"%" identified by 'zabbix123';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit
///導入zabbix數據
[root@ZabbixServer ~]# tar zxf zabbix-4.2.7.tar.gz ///zabbix包放在了~目錄
[root@ZabbixServer ~]# cd zabbix-4.2.7/database/mysql/
[root@ZabbixServer mysql]# mysql -uzabbix -pzabbix123 zabbix < schema.sql
[root@ZabbixServer mysql]# mysql -uzabbix -pzabbix123 zabbix < images.sql
[root@ZabbixServer mysql]# mysql -uzabbix -pzabbix123 zabbix < data.sql
6 安裝zabbix
6.1 編譯安裝
[root@ZabbixServer ~]# cd zabbix-4.2.7
[root@ZabbixServer zabbix-4.2.7]#./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --with-net-snmp--with-libcurl --enable-java
[root@ZabbixServer zabbix-4.2.7]# make && make install
6.2 配置zabbix server和agent啓動文件
[root@ZabbixServer ~]# cp ~/zabbix-4.2.7/misc/init.d/tru64/zabbix_* /etc/init.d/
[root@ZabbixServer tru64]# cd /etc/init.d/
[root@ZabbixServer init.d]# chmod +x zabbix_*
[root@ZabbixServer init.d]# vim zabbix_server //配置zabbix_server啓動腳本,agent同理
...///上面忽略
SERVICE="Zabbix server"
#DAEMON=/usr/local/sbin/zabbix_server此行註釋改爲下一行,注意路徑
DAEMON=/usr/local/zabbix/sbin/zabbix_server
PIDFILE=/tmp/zabbix_server.pid
...///下面忽略
6.3 配置zabbix server 配置文件
[root@ZabbixServer ~]# vim /usr/local/zabbix/etc/zabbix_server.conf ///注意備份此文件
///主要修改這幾個地方 ,其他忽略
ListenPort=10051
LogFile=/tmp/zabbix_server.log
PidFile=/tmp/zabbix_server.pid
DBHost=localhost ///數據庫地址
DBName=zabbix ///數據庫 名字
DBUser=zabbix ///數據庫用戶
DBPassword=zabbix123 ///密碼
DBPort=3306 ///端口,默認爲3306
AllowRoot=1 ///默認爲0,設置1,允許其他用戶啓動
User=root ///設置root啓動
Include=/usr/local/Zabbix/etc/zabbix_server.conf.d/*.conf
6.4 啓動zabbix
[root@ZabbixServer ~]# /etc/init.d/zabbix_server restart
7 安裝php
[root@ZabbixServer ~]# cd php-5.6.36
[root@ZabbixServer php-5.6.36]# yum install -y curl curl-devel libjpeg libpng* libxslt-devel* libjpeg-devel
[root@ZabbixServer php-5.6.36]# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-curl --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysql --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-freetype-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml
[root@ZabbixServer php-5.6.36]# make && make install
7.1 php進行相關配置
[root@ZabbixServer ~]# cd /usr/local/php/etc
[root@ZabbixServer etc]# cp php-fpm.conf.default php-fpm.conf
[root@ZabbixServer etc]# cp ~/php-5.6.36/php.ini-development ./php.ini
[root@ZabbixServer etc]# cp ~/php-5.6.36/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@ZabbixServer etc]# cd /etc/init.d/
[root@ZabbixServer init.d]# chmod +x php-fpm
[root@ZabbixServer init.d]# /etc/init.d/php-fpm restart
root 41059 1 0 01:51 ? 00:00:01 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
7.2 針對php安裝ldap ///不做此步驟 ,後面會有警告
[root@ZabbixServer ~]# yum install -y openldap* autoconf
/// autoconf 必須安裝,此不安裝會,後面不會生產configure文件
[root@ZabbixServer ~]# cd php-5.6.36/ext/ldap/
[root@ZabbixServer ldap]# ls
config.m4 CREDITS ldap.dsp LDAP_Win32_HOWTO.txt tests
config.w32 ldap.c ldap.mak php_ldap.h
[root@ZabbixServer ldap]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version: 20131106
Zend Module Api No: 20131226
Zend Extension Api No: 220131226
[root@ZabbixServer ldap]# ls
acinclude.m4 config.h.in config.w32 ldap.mak mkinstalldirs
aclocal.m4 config.m4 CREDITS LDAP_Win32_HOWTO.txt php_ldap.h
autom4te.cache config.sub install-sh ltmain.sh run-tests.php
build configure ldap.c Makefile.global tests
config.guess configure.in ldap.dsp missing
///編譯安裝
[root@ZabbixServer ldap]# cp /usr/lib64/libldap* /usr/lib
[root@ZabbixServer ldap]# ./configure --with-php-config=/usr/local/php/bin/php-config --with-ldap
[root@ZabbixServer ldap]# make && make install
///php.ini文件設置
[root@ZabbixServer ~]# vim /usr/local/php/etc/php.ini
extension=ldap.so ////添加此行,重啓php
[root@ZabbixServer ~]# /etc/init.d/php-fpm restart
8 安裝nginx
8.1 編譯安裝
[root@ZabbixServer ~]# tar zxf nginx-1.14.2.tar.gz
[root@ZabbixServer ~]# cd nginx-1.14.2
[root@ZabbixServer nginx-1.14.2]# yum install libffi-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
[root@ZabbixServer nginx-1.14.2]# ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-mail_ssl_module --with-http_gzip_static_module --with-pcre
[root@ZabbixServer nginx-1.14.2]# make && make install
8.2 修改配置文件,支持php,這裏不再演示測試,啓動
[root@ZabbixServer ~]# vim /usr/local/nginx/conf/nginx.conf
#user nobody;
worker_processes auto;
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
server_tokens off;
log_format main '$remote_addr - $http_x_forwarded_for - "$upstream_addr" - $remote_user - [$time_local] - $request - $http_host - '
'$status - $upstream_status - $body_bytes_sent - $http_referer - $request_time - $upstream_response_time - '
'"$http_user_agent"';
#access_log logs/access.log main;
sendfile on;
tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
server {
listen 80;
server_name localhost;
charset utf-8;
access_log logs/zabbix.log main;
location / {
root html;
index index.php;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php$ {
root html;
fastcgi_split_path_info ^(.+.php)(.*)$;
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
}
8.3 拷貝zabbix前端文件
[root@ZabbixServer ~]# cd /root/zabbix-4.2.7/frontends/php
[root@ZabbixServer php]# cp -R * /usr/local/nginx/html/
9 瀏覽器配置
請自行根據內容修改 /usr/local/php/etc/php.ini 文件,然後重啓php
此地方自行下載文件,並放在指定位置!
登陸賬號密碼默認爲:Admin zabbix
設置語言爲中文:
上上個圖,有問題,說agent端不可達,是因爲agent沒有啓動,
[root@ZabbixServer init.d]# /etc/init.d/zabbix_agentd restart /// 啓動文件有修改,前面修改server提到,一樣的!
這樣都已正常!
10 解決中文亂碼問題
從Window服務器找到相應的字休複製到zabbix Server服務器上: C:\Windows\Fonts
(詳細圖片不提供了,請見諒)
[root@ZabbixServer fonts]# cd /usr/local/nginx/html/assets/fonts
[root@ZabbixServer fonts]# ll
total 740
-rw-r--r-- 1 root root 756072 Nov 10 01:46 DejaVuSans.ttf
[root@ZabbixServer fonts]# rz
[root@ZabbixServer fonts]# ll
total 12252
-rw-r--r-- 1 root root 756072 Nov 10 01:46 DejaVuSans.ttf
-rw-r--r-- 1 root root 11787328 Aug 9 2018 simkai.ttf
[root@ZabbixServer fonts]# mv DejaVuSans.ttf DejaVuSans.ttfbak
[root@ZabbixServer fonts]# mv simkai.ttf DejaVuSans.ttf
///重啓nginx