飞道的博客

Zabbix监控部署

355人阅读  评论(0)

目录

编译安装nginx

编译安装PHP

编译安装mysql

安装zabbix


编译安装nginx

参考文章   源码下载


  
  1. [root@8a-1 opt] # uname -a
  2. Linux 8a-1 3.10.0-1160.71.1.el7.x86_64 #1 SMP Tue Jun 28 15:37:28 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
  3. [root@8a-1 opt] # cat /etc/redhat-release
  4. CentOS Linux release 7.9.2009 (Core)
  5. [root@8a-1 ~] # cd /opt/
  6. [root@8a-1 opt] # ll
  7. -rw-r--r-- 1 root root 832104 Dec 21 09:45 nginx-1.8.0.tar.gz
  8. [root@8a-1 opt] # tar -zxvf nginx-1.8.0.tar.gz
  9. [root@8a-1 opt] # cd nginx-1.8.0
  10. [root@8a-1 nginx-1.8.0] # mkdir -p /usr/local/nginx/
  11. [root@8a-1 nginx-1.8.0] # ./configure --prefix=/usr/local/nginx/ --without-http_rewrite_module --without-http_gzip_module --with-pcre
  12. [root@8a-1 nginx-1.8.0] # make
  13. [root@8a-1 nginx-1.8.0] # make install

配置nginx开机自启动


  
  1. [root@8a-1 nginx-1.8.0] # vi /etc/init.d/nginx
  2. [root@8a-1 nginx-1.8.0] # cat /etc/init.d/nginx
  3. #!/bin/sh
  4. #
  5. # nginx - this script starts and stops the nginx daemon
  6. #
  7. # chkconfig: - 85 15
  8. # description: NGINX is an HTTP(S) server, HTTP(S) reverse \
  9. # proxy and IMAP/POP3 proxy server
  10. # processname: nginx
  11. # config: /usr/local/nginx/conf/nginx.conf
  12. # pidfile: /usr/local/nginx/logs/nginx.pid
  13. # Source function library.
  14. . /etc/rc.d/init.d/functions
  15. # Source networking configuration.
  16. . /etc/sysconfig/network
  17. # Check that networking is up.
  18. [ "$NETWORKING" = "no" ] && exit 0
  19. # :set ff=unix
  20. # 修改为实际配置文件目录
  21. nginx= "/usr/local/nginx/sbin/nginx"
  22. prog=$( basename $nginx)
  23. # 修改为实际配置文件目录
  24. NGINX_CONF_FILE= "/usr/local/nginx/conf/nginx.conf"
  25. [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
  26. lockfile=/var/lock/subsys/nginx
  27. make_dirs() {
  28. # make required directories
  29. user=` $nginx -V 2>&1 | grep "configure arguments:.*--user=" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
  30. if [ -n "$user" ]; then
  31. if [ -z "`grep $user /etc/passwd`" ]; then
  32. useradd -M -s /bin/nologin $user
  33. fi
  34. options=` $nginx -V 2>&1 | grep 'configure arguments:'`
  35. for opt in $options; do
  36. if [ ` echo $opt | grep '.*-temp-path'` ]; then
  37. value=` echo $opt | cut -d "=" -f 2`
  38. if [ ! -d "$value" ]; then
  39. # echo "creating" $value
  40. mkdir -p $value && chown -R $user $value
  41. fi
  42. fi
  43. done
  44. fi
  45. }
  46. start() {
  47. [ -x $nginx ] || exit 5
  48. [ -f $NGINX_CONF_FILE ] || exit 6
  49. make_dirs
  50. echo -n $ "Starting $prog: "
  51. daemon $nginx -c $NGINX_CONF_FILE
  52. retval=$?
  53. echo
  54. [ $retval -eq 0 ] && touch $lockfile
  55. return $retval
  56. }
  57. stop() {
  58. echo -n $ "Stopping $prog: "
  59. killproc $prog -QUIT
  60. retval=$?
  61. echo
  62. [ $retval -eq 0 ] && rm -f $lockfile
  63. return $retval
  64. }
  65. restart() {
  66. configtest || return $?
  67. stop
  68. sleep 1
  69. start
  70. }
  71. reload() {
  72. configtest || return $?
  73. echo -n $ "Reloading $prog: "
  74. killproc $prog -HUP
  75. retval=$?
  76. echo
  77. }
  78. force_reload() {
  79. restart
  80. }
  81. configtest() {
  82. nginx -t -c $NGINX_CONF_FILE
  83. }
  84. rh_status() {
  85. status $prog
  86. }
  87. rh_status_q() {
  88. rh_status >/dev/null 2>&1
  89. }
  90. case "$1" in
  91. start)
  92. rh_status_q && exit 0
  93. $1
  94. ;;
  95. stop)
  96. rh_status_q || exit 0
  97. $1
  98. ;;
  99. restart|configtest)
  100. $1
  101. ;;
  102. reload)
  103. rh_status_q || exit 7
  104. $1
  105. ;;
  106. force-reload)
  107. force_reload
  108. ;;
  109. status)
  110. rh_status
  111. ;;
  112. condrestart|try-restart)
  113. rh_status_q || exit 0
  114. ;;
  115. *)
  116. echo "Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
  117. exit 2
  118. esac

  
  1. [root@8a-1 nginx-1.8.0] # chmod +x /etc/init.d/nginx
  2. [root@8a-1 nginx-1.8.0] # chkconfig --add nginx
  3. [root@8a-1 nginx-1.8.0] # chkconfig nginx on
  4. [root@8a-1 nginx-1.8.0] # systemctl start nginx
  5. [root@8a-1 nginx-1.8.0] # systemctl status nginx

验证nginx


  
  1. [root@8a-1 nginx-1.8.0] # ip a
  2. inet 192.168.61.1/24 brd 192.168.61.255 scope global noprefixroute ens33

编译安装PHP

千万不要用PHP8.0 !!! 建议用PHP7.2   因为我第一次用了PHP8 ,可以直接翻到最后看结果,页面加载不出来! 还得改源码 卧槽

源码下载


  
  1. [root@8a-1 opt] # wget https://www.php.net/distributions/php-7.4.12.tar.gz
  2. [root@8a-1 opt] # groupadd www
  3. [root@8a-1 opt] # useradd -g www www
  4. [root@8a-1 opt] # ll
  5. -rw-r--r-- 1 root root 20054375 Dec 20 10:34 php-8.2.0.tar.gz
  6. [root@8a-1 opt] # tar -zxvf php-8.2.0.tar.gz
  7. [root@8a-1 opt] # cd php-8.2.0
  8. [root@8a-1 php-8.2.0] # ./configure --prefix=/usr/local/php --with-config-file-path=/etc --with-fpm-user=www --with-fpm-group=www --with-curl --with-freetype --enable-gd --with-gettext --without-iconv --with-kerberos --with-libdir=lib64 --with-libxml --with-mysqli --with-openssl --with-pdo-mysql --with-pdo-sqlite --with-pear --with-jpeg --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-fpm --disable-mbregex
  9. [root@8a-1 php-8.2.0] # make
  10. [root@8a-1 php-8.2.0] # make install
  11. [root@8a-1 php-8.2.0] # /usr/local/php/bin/php -v
  12. PHP 8.2.0 (cli) (built: Dec 21 2022 11:23:03) (NTS)
  13. Copyright (c) The PHP Group
  14. Zend Engine v4.2.0, Copyright (c) Zend Technologies
  15. #php7.0.2 编译方式
  16. [root@8a-2 php-7.0.2] # ./configure --prefix=/usr/local/php --with-config-file-path=/etc --with-fpm-user=www --with-fpm-group=www --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-zip --enable-fpm
  17. #php7.4.12 编译方式
  18. [root@8a-2 php-7.4.12] # ./configure --prefix=/usr/local/php --with-config-file-path=/etc --with-fpm-user=www --with-fpm-group=www --with-curl --with-freetype --enable-gd --with-gettext --without-iconv --with-kerberos --with-libdir=lib64 --with-libxml --with-mysqli --with-openssl --with-pdo-mysql --with-pdo-sqlite --with-pear --with-jpeg --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-fpm --disable-mbregex

上面的这些编译参数 要根据版本情况而定,很多参数已经换了写法 使用./configure --help查看,如果缺少依赖包的话 也可以视情况删掉一些不需要的参数

另外:第二次用了php7.0.2  结果发现 zabbix5.0 要求php最低7.2  我又换成php7.4

如果编译缺少依赖包的话,需要根据自己的环境补充依赖


  
  1. [root@8a-1 opt] # ll
  2. -rw-r--r-- 1 root root 759839 Dec 21 10:17 oniguruma-7.0.zip
  3. [root@8a-1 opt] # unzip oniguruma-7.0.zip
  4. [root@8a-1 opt] # cd oniguruma-7.0
  5. [root@8a-1 opt] # mkdir -p /usr/local/oniguruma
  6. [root@8a-1 oniguruma-7.0] # ./autogen.sh && ./configure --prefix=/usr/local/oniguruma --libdir=/lib64
  7. [root@8a-1 oniguruma-7.0] # make
  8. [root@8a-1 oniguruma-7.0] # make install

配置php-fpm


  
  1. [root@8a-1 php-8.2.0] # vi /etc/profile
  2. [root@8a-1 php-8.2.0] # source /etc/profile
  3. [root@8a-1 php-8.2.0] # cp /usr/bin/php /usr/bin/php.bak
  4. [root@8a-1 bin] # ln -s /usr/local/php/bin/php /usr/bin/php
  5. [root@8a-1 bin] # php -v
  6. PHP 8.2.0 (cli) (built: Dec 21 2022 11:23:03) (NTS)
  7. Copyright (c) The PHP Group
  8. Zend Engine v4.2.0, Copyright (c) Zend Technologies
  9. [root@8a-1 opt] # cd php-8.2.0
  10. [root@8a-1 php-8.2.0] # cp php.ini-production /etc/php.ini
  11. [root@8a-1 php-8.2.0] # cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
  12. [root@8a-1 php-8.2.0] # cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
  13. [root@8a-1 php-8.2.0] # cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
  14. [root@8a-1 php-8.2.0] # chmod +x /etc/init.d/php-fpm
  15. [root@8a-1 php-8.2.0] # /etc/init.d/php-fpm start

PATH=$PATH:/usr/local/php/bin 
export PATH

配置nginx支持php


  
  1. [root@8a-1 init.d] # cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak
  2. [root@8a-1 init.d] # vi /usr/local/nginx/conf/nginx.conf
  3. [root@8a-1 init.d] # grep -v "#" /usr/local/nginx/conf/nginx.conf
  4. worker_processes 1;
  5. events {
  6. worker_connections 1024;
  7. }
  8. http {
  9. include mime.types;
  10. default_type application/octet-stream;
  11. sendfile on;
  12. keepalive_timeout 65;
  13. server {
  14. listen 80;
  15. server_name localhost;
  16. #添加index.php
  17. location / {
  18. root html;
  19. index index.php index.html index.htm;
  20. }
  21. error_page 500 502 503 504 /50x.html;
  22. location = /50x.html {
  23. root html;
  24. }
  25. #放开有关php的location注释
  26. location ~ \.php$ {
  27. root html;
  28. fastcgi_pass 127.0.0.1:9000;
  29. fastcgi_index index.php;
  30. #修改路径
  31. fastcgi_param SCRIPT_FILENAME $document_root $fastcgi_script_name;
  32. include fastcgi_params;
  33. }
  34. }
  35. }

验证nginx+php


  
  1. [root@8a-1 init.d] # cd /usr/local/nginx/html
  2. [root@8a-1 html] # vi info.php
  3. [root@8a-1 html] # cat info.php
  4. <?php
  5. phpinfo();
  6. ?>
  7. [root@8a-1 html] # systemctl restart nginx
  8. [root@8a-1 html] # /etc/init.d/php-fpm restart

 mysqli模块要显示才行 ,不然php可能无法连接mysql

编译安装mysql


  
  1. # 安装之前需要把系统自带的Mariadb卸载(如果不用yum安装 好像不用卸载也行 原文用的是yum安装 所以他卸载了,我这里不是yum安装的,不确定需不需要卸载。PS 后面我又试了试 这里不删Mariadb也能成功)
  2. [root@8a-1 opt] # rpm -qa | grep mariadb
  3. mariadb-libs-5.5.68-1.el7.x86_64
  4. mariadb-devel-5.5.68-1.el7.x86_64
  5. mariadb-server-5.5.68-1.el7.x86_64
  6. mariadb-5.5.68-1.el7.x86_64
  7. [root@8a-1 opt] # yum remove -y mariadb-libs-5.5.68-1.el7.x86_64
  8. [root@8a-1 opt] # groupadd mysql
  9. [root@8a-1 opt] # useradd mysql
  10. [root@8a-1 opt] # ll
  11. -rw-r--r-- 1 root root 744349688 Nov 9 23:35 mysql-5.7.39-el7-x86_64.tar.gz
  12. [root@8a-1 opt] # tar -zxvf mysql-5.7.39-el7-x86_64.tar.gz
  13. [root@8a-1 opt] # cd mysql-5.7.39-el7-x86_64
  14. [root@8a-1 mysql-5.7.39-el7-x86_64] # visudo

mysql   ALL=(ALL)       ALL


  
  1. [root@8a-1 mysql-5.7.39-el7-x86_64] # mkdir -p /data/mysql
  2. [root@8a-1 mysql-5.7.39-el7-x86_64] # chown -R mysql:mysql /data/mysql
  3. [root@8a-1 mysql-5.7.39-el7-x86_64] # vi /etc/my.cnf

[mysqld]
bind-address=0.0.0.0
port=3306
user=mysql
basedir=/usr/local/mysql
datadir=/data/mysql
socket=/tmp/mysql.sock
log-error=/data/mysql/mysql.err
pid-file=/data/mysql/mysql.pid
#character config
character_set_server=utf8mb4
symbolic-links=0
explicit_defaults_for_timestamp=true


  
  1. [root@8a-1 opt] # cd /opt/
  2. [root@8a-1 opt] # ll
  3. drwxr-xr-x 9 root root 129 Dec 21 13:57 mysql-5.7.39-el7-x86_64
  4. [root@8a-1 opt] # mv mysql-5.7.39-el7-x86_64 /usr/local/mysql
  5. [root@8a-1 opt] # cd /usr/local/mysql/bin/
  6. [root@8a-1 bin] # ./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql/ --datadir=/data/mysql/ --user=mysql --initialize
  7. [root@8a-1 bin] # cat /data/mysql/mysql.err
  8. 2022-12-21T06:08:14.208797Z 1 [Note] A temporary password is generated for root@localhost: 1rvFK/IOTkPm
  9. [root@8a-1 bin] # cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
  10. [root@8a-1 bin] # chown -R mysql.mysql /usr/local/mysql
  11. [root@8a-1 bin] # chown -R mysql.mysql /data/mysql
  12. [root@8a-1 bin] # service mysql start
  13. [root@8a-1 opt] # vi /etc/my.cnf

[mysqld]
skip-grant-tables


  
  1. [root@8a-1 opt] # service mysql restart
  2. [root@8a-1 opt] # /usr/local/mysql/bin/mysql -u root -p
  3. mysql> use mysql;
  4. mysql> update user set host= '%' where user= 'root';
  5. mysql> FLUSH PRIVILEGES;
  6. mysql> ALTER USER "root"@ "%" IDENTIFIED BY "123456";
  7. mysql> quit
  8. [root@8a-1 opt] # tail -1 /etc/my.cnf
  9. skip-grant-tables
  10. [root@8a-1 opt] # vi /etc/my.cnf
  11. [root@8a-1 opt] # tail -1 /etc/my.cnf
  12. #skip-grant-tables
  13. [root@8a-1 opt] # ln -s /usr/local/mysql/bin/mysql /bin/mysql
  14. [root@8a-1 opt] # service mysql restart

  
  1. [root @8a -1 opt]# mysql -uroot -p123456
  2. mysql > GRANT ALL PRIVILEGES ON *. * TO 'root'@ '%'IDENTIFIED BY '123456' WITH GRANT OPTION;
  3. mysql > flush privileges;
  4. mysql > quit

这篇文章用的是mariadb 应该也没问题,感觉如果有mariadb 那直接用就好,不用非得把mariadb卸载然后装mysql,我这里搞得有点麻烦了,后面有时间再调整一下

安装zabbix


  
  1. [root@8a-1 opt] # yum install gcc gcc-c++ make unixODBC-devel net-snmp-devel libssh2-devel OpenIPMI-devel libevent-devel pcre-devel libcurl-devel curl-* net-snmp* libxml2-* wget tar -y
  2. [root@8a-1 opt] # yum install -y mysql-devel
  3. [root@8a-1 opt] # ll
  4. -rw-r--r-- 1 root root 18519888 Dec 20 22:24 zabbix-5.0.0.tar.gz
  5. [root@8a-1 opt] # tar -zxvf zabbix-5.0.0.tar.gz
  6. [root@8a-1 opt] # cd zabbix-5.0.0/
  7. [root@8a-1 zabbix-5.0.0] # mkdir -p /usr/local/zabbix
  8. [root@8a-1 zabbix-5.0.0] # ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
  9. [root@8a-1 zabbix-5.0.0] # make
  10. [root@8a-1 zabbix-5.0.0] # make install
  11. [root@8a-1 zabbix-5.0.0] # groupadd --system zabbix
  12. [root@8a-1 zabbix-5.0.0] # useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix
  13. [root@8a-1 zabbix-5.0.0] # cd /opt/zabbix-5.0.0
  14. [root@8a-1 zabbix-5.0.0] # cp misc/init.d/fedora/core/zabbix_* /etc/init.d/
  15. [root@8a-1 zabbix-5.0.0] # ll -d /etc/init.d/zabbix_*
  16. -rwxr-xr-x 1 root root 2170 Dec 21 14:49 /etc/init.d/zabbix_agentd
  17. -rwxr-xr-x 1 root root 2181 Dec 21 14:49 /etc/init.d/zabbix_server
  18. [root@8a-1 zabbix-5.0.0] # chmod +x /etc/init.d/zabbix_*

初始化zabbix数据库


  
  1. [root @8a -1 opt]# mysql -u root -p123456
  2. mysql > create database zabbix character set utf8 collate utf8_bin;
  3. mysql > grant all privileges on zabbix. * to zabbix @localhost identified by '123456';
  4. mysql > grant all privileges on zabbix. * to zabbix @127 .0 .0 .1 identified by '123456';
  5. mysql > GRANT ALL PRIVILEGES ON *. * TO 'zabbix'@ '%'IDENTIFIED BY '123456' WITH GRANT OPTION;
  6. mysql > flush privileges;
  7. mysql > quit

导入表结构


  
  1. [root@8a-1 mysql] # cd /opt/zabbix-5.0.0/database/mysql/
  2. [root@8a-1 mysql] # ll
  3. -rw-r--r-- 1 test test 156239 May 11 2020 schema.sql
  4. -rw-r--r-- 1 test test 1978341 May 11 2020 images.sql
  5. -rw-r--r-- 1 test test 7097625 May 11 2020 data.sql
  6. [root@8a-1 mysql] # mysql -u root -p123456
  7. mysql> use zabbix;
  8. mysql> source /opt/zabbix-5.0.0/database/mysql/schema.sql
  9. mysql> source /opt/zabbix-5.0.0/database/mysql/images.sql
  10. mysql> source /opt/zabbix-5.0.0/database/mysql/data.sql

使用php连接mysql验证


  
  1. [root@8a-1 opt] # vi /usr/local/nginx/html/test.php
  2. [root@8a-1 opt] # cat /usr/local/nginx/html/test.php
  3. <?php
  4. $link=mysqli_connect( '127.0.0.1', 'zabbix', '123456');
  5. if ( $link) echo "数据库连接成功!";
  6. else echo "数据库连接失败~";
  7. ?>
  8. [root@8a-1 opt] # php /usr/local/nginx/html/test.php
  9. 数据库连接成功!
  10. [root@8a-1 opt] # systemctl restart nginx
  11. [root@8a-1 opt] # /etc/init.d/php-fpm restart
  12. [root@8a-1 opt] # killall php-fpm
  13. [root@8a-1 opt] # systemctl restart php-fpm

配置zabbix服务端


  
  1. [root@8a-1 opt] # cp /usr/local/zabbix/etc/zabbix_server.conf /usr/local/zabbix/etc/zabbix_server.conf.bak
  2. [root@8a-1 opt] # cp /usr/local/zabbix/etc/zabbix_agentd.conf /usr/local/zabbix/etc/zabbix_agentd.conf.bak
  3. [root@8a-1 opt] #grep -v "^#|^$" /usr/local/zabbix/etc/zabbix_server.conf
  4. [root@8a-1 opt] # vi /usr/local/zabbix/etc/zabbix_server.conf

LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/tmp/zabbix_server.pid

SocketDir=/tmp
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123456
DBSocket=/tmp/mysql.sock
DBPort=3306
StartPollers=100
StartTrappers=10
StartPingers=10
StartDiscoverers=10
Timeout=4
LogSlowQueries=3000
Include=/usr/local/zabbix/etc/zabbix_server.conf.d/*.conf
StatsAllowedIP=127.0.0.1

配置zabbix代理端


  
  1. [root@8a-1 opt] # vi /usr/local/zabbix/etc/zabbix_agentd.conf
  2. [root@8a-1 opt] # mkdir -p /var/log/zabbix
  3. [root@8a-1 opt] # chown -R zabbix:zabbix /var/log/zabbix
  4. [root@8a-1 opt] # chown -R zabbix:zabbix /tmp/zabbix_*

PidFile=/tmp/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
DenyKey=system.run[*]
Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=Zabbix server
Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/*.conf
UnsafeUserParameters=1

配置zabbix 服务端启动文件 


  
  1. [root@8a-1 opt] # vi /lib/systemd/system/zabbix-server.service
  2. [root@8a-1 opt] # cat /lib/systemd/system/zabbix-server.service
  3. [Unit]
  4. Description=Zabbix Server
  5. After=syslog.target
  6. After=network.target
  7. After=mysql.service
  8. After=mysqld.service
  9. After=mariadb.service
  10. After=postgresql.service
  11. [Service]
  12. Environment= "CONFFILE=/usr/local/zabbix/etc/zabbix_server.conf"
  13. EnvironmentFile=-/etc/sysconfig/zabbix-server
  14. Type=forking
  15. Restart=on-failure
  16. PIDFile=/tmp/zabbix_server.pid
  17. KillMode=control-group
  18. ExecStart=/usr/local/zabbix/sbin/zabbix_server -c /usr/local/zabbix/etc/zabbix_server.conf
  19. ExecStop=/bin/kill -SIGTERMMAINPID
  20. RestartSec=10s
  21. TimeoutSec=0
  22. [Install]
  23. WantedBy=multi-user.target

配置 zabbix 代理端启动文件


  
  1. [root@8a-1 opt] # vi /lib/systemd/system/zabbix-agent.service
  2. [root@8a-1 opt] # cat /lib/systemd/system/zabbix-agent.service
  3. [Unit]
  4. Description=Zabbix Agent
  5. After=syslog.target
  6. After=network.target
  7. [Service]
  8. Environment= "CONFFILE=/usr/local/zabbix/etc/zabbix_agentd.conf"
  9. EnvironmentFile=-/etc/sysconfig/zabbix-agent
  10. Type=forking
  11. Restart=on-failure
  12. PIDFile=/tmp/zabbix_agentd.pid
  13. KillMode=control-group
  14. ExecStart=/usr/local/zabbix/sbin/zabbix_agentd -c /usr/local/zabbix/etc/zabbix_agentd.conf
  15. ExecStop=/bin/kill -SIGTERMMAINPID
  16. RestartSec=10s
  17. User=zabbix
  18. Group=zabbix
  19. [Install]
  20. WantedBy=multi-user.target

启动zabbix服务端和客户端


  
  1. [root@8a-1 opt] # systemctl daemon-reload
  2. [root@8a-1 opt] # systemctl enable --now zabbix-server
  3. [root@8a-1 opt] # systemctl enable --now zabbix-agent
  4. [root@8a-1 opt] # systemctl status zabbix-server.service
  5. [root@8a-1 opt] # systemctl status zabbix-agent.service

配置zabbix前端页面


  
  1. [root@8a-1 opt] # cp -r /opt/zabbix-5.0.0/ui/* /usr/local/nginx/html/
  2. 【不用执行 留着备用】[root@8a-1 opt] # chown -R www:www /var/www/html/
  3. 【不用执行 留着备用】[root@8a-1 opt] # chown -R /usr/local/nginx/html/
  4. [root@8a-1 opt] # find / -name mysql.sock
  5. /tmp/mysql.sock
  6. [root@8a-1 opt] # vi /etc/php.ini

max_execution_time = 300
max_input_time = 300
post_max_size = 16M

date.timezone = Asia/Shanghai
pdo_mysql.default_socket = /tmp/mysql.sock
mysqli.default_socket = /tmp/mysql.sock

[root@8a-1 opt]# systemctl restart php-fpm

验证前端页面

登录 http://192.168.61.1/setup.php

 

 这里不知道为什么没过去,可能是权限问题? 然后按照提示手工上传了一份配置文件就好了


   
  1. [root@8a-1 conf] # pwd
  2. /usr/local/nginx/html/conf
  3. [root@8a-1 conf] # ll
  4. -rw-r--r-- 1 root root 1479 Dec 21 17:28 zabbix.conf.php #这个文件是从网页上直接下载下来的 没有做任何修改

 

浏览器访问 http://192.168.61.1/index.php

账号   Admin  密码  zabbix

出现上图 原因是服务端端口没起来(其实不是端口问题,不过端口没起来也是不正常的)

 

因为我这个mysql是自己装的,sock的地址写错了,上面有很多配置sock的地方 都写的是/var/lib/mysql/mysql.sock  ,但是在安装mysql的时候 把sock放到 /tmp/mysql.sock ,所以要改一下


  
  1. [root@8a-1 tmp] # vi /usr/local/zabbix/etc/zabbix_server.conf
  2. [root@8a-1 tmp] # cat /usr/local/zabbix/etc/zabbix_server.conf | grep Socket
  3. SocketDir=/tmp
  4. DBSocket=/tmp/mysql.sock
  5. [root@8a-1 tmp] # systemctl restart zabbix_server

不知道什么时候apache也挂了,端口跟nginx冲突了 需要改一下(后面看apache挂了也无所谓 nginx能用就好)


  
  1. [root@8a-1 conf] # vi httpd.conf
  2. [root@8a-1 conf] # systemctl restart httpd
  3. [root@8a-1 conf] # cat /etc/httpd/conf/httpd.conf | grep 8080
  4. Listen 8080
  5. [root@8a-1 conf] # systemctl status httpd

编译load模块(这里是防止setup.php那里检查过不去)


  
  1. [root@8a-1 ~] # cd /opt/php-8.2.0/ext/ldap/
  2. [root@8a-1 ldap] # ll
  3. #此时没有configure
  4. -rw-r--r-- 1 501 games 4918 Dec 6 22:26 config.m4
  5. -rw-r--r-- 1 501 games 1230 Dec 6 22:26 config.w32
  6. -rw-r--r-- 1 501 games 77 Dec 6 22:26 CREDITS
  7. -rw-r--r-- 1 501 games 37705 Dec 6 22:26 ldap_arginfo.h
  8. -rw-r--r-- 1 501 games 111033 Dec 6 22:26 ldap.c
  9. -rw-r--r-- 1 501 games 22542 Dec 6 22:26 ldap.stub.php
  10. -rw-r--r-- 1 501 games 2195 Dec 6 22:26 php_ldap.h
  11. drwxr-xr-x 2 501 games 8192 Dec 21 10:09 tests
  12. [root@8a-1 ldap] # /usr/local/php/bin/phpize
  13. Configuring for:
  14. PHP Api Version: 20220829
  15. Zend Module Api No: 20220829
  16. Zend Extension Api No: 420220829
  17. [root@8a-1 ldap] # ll
  18. #多了configure文件
  19. drwxr-xr-x 2 root root 54 Dec 21 21:26 autom4te.cache
  20. drwxr-xr-x 2 root root 261 Dec 21 21:26 build
  21. -rw-r--r-- 1 root root 2710 Dec 21 21:26 config.h.in
  22. -rw-r--r-- 1 501 games 4918 Dec 6 22:26 config.m4
  23. -rwxr-xr-x 1 root root 468940 Dec 21 21:26 configure
  24. -rw-r--r-- 1 root root 5313 Dec 21 21:26 configure.ac
  25. -rw-r--r-- 1 501 games 1230 Dec 6 22:26 config.w32
  26. -rw-r--r-- 1 501 games 77 Dec 6 22:26 CREDITS
  27. -rw-r--r-- 1 501 games 37705 Dec 6 22:26 ldap_arginfo.h
  28. -rw-r--r-- 1 501 games 111033 Dec 6 22:26 ldap.c
  29. -rw-r--r-- 1 501 games 22542 Dec 6 22:26 ldap.stub.php
  30. -rw-r--r-- 1 501 games 2195 Dec 6 22:26 php_ldap.h
  31. -rw-r--r-- 1 root root 137381 Dec 21 21:26 run-tests.php
  32. drwxr-xr-x 2 501 games 8192 Dec 21 10:09 tests
  33. [root@8a-1 ldap] # ll /usr/lib64/libldap*
  34. lrwxrwxrwx. 1 root root 21 Nov 16 04:38 /usr/lib64/libldap-2.3.so.0 -> libldap-2.3.so.0.2.31
  35. -rwxr-xr-x. 1 root root 261008 Jun 10 2014 /usr/lib64/libldap-2.3.so.0.2.31
  36. lrwxrwxrwx. 1 root root 21 Nov 16 04:32 /usr/lib64/libldap-2.4.so.2 -> libldap-2.4.so.2.10.7
  37. -rwxr-xr-x. 1 root root 352496 Feb 24 2022 /usr/lib64/libldap-2.4.so.2.10.7
  38. lrwxrwxrwx. 1 root root 23 Nov 16 04:38 /usr/lib64/libldap_r-2.3.so.0 -> libldap_r-2.3.so.0.2.31
  39. -rwxr-xr-x. 1 root root 281912 Jun 10 2014 /usr/lib64/libldap_r-2.3.so.0.2.31
  40. lrwxrwxrwx. 1 root root 23 Nov 16 04:32 /usr/lib64/libldap_r-2.4.so.2 -> libldap_r-2.4.so.2.10.7
  41. -rwxr-xr-x. 1 root root 381312 Feb 24 2022 /usr/lib64/libldap_r-2.4.so.2.10.7
  42. lrwxrwxrwx. 1 root root 23 Nov 16 04:34 /usr/lib64/libldap_r.so -> libldap_r-2.4.so.2.10.7
  43. lrwxrwxrwx. 1 root root 21 Nov 16 04:34 /usr/lib64/libldap.so -> libldap-2.4.so.2.10.7
  44. [root@8a-1 ldap] # cp -frp /usr/lib64/libldap* /usr/lib/
  45. [root@8a-1 ldap] # ./configure --with-php-config=/usr/local/php/bin/php-config --with-ldap
  46. [root@8a-1 ldap] # make
  47. [root@8a-1 ldap] # make install

好吧 上面的搞完了 还是不行 ,又找了一篇文章试试(这个方法也不行)


  
  1. [root@8a-1 ext] # cd /usr/local/nginx/html/
  2. [root@8a-1 html] # cp include/classes/db/DB.php ./include/classes/db/DB.php.bak
  3. [root@8a-1 html] # vi ./include/classes/db/DB.php

改完了 还是不行 貌似是因php8.0 的问题 ,改成php7.4就好了  我敲  这中文翻译是真的流弊

 

果然PHP版本不能用8.0     垃圾PHP!!!换了三个版本才搞好 !


转载:https://blog.csdn.net/qq_34479012/article/details/128380489
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场