监控服务zabbix的部署

监控服务zabbix部署

1. zabbix介绍

zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。

zabbix能监视各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。

zabbix由2部分构成,zabbix server与可选组件zabbix agent

zabbix server可以通过SNMPzabbix agentping,端口监视等方法提供对远程服务器/网络状态的监视,数据收集等功能,它可以运行在Linux,Ubuntu,Solaris,HP-UX,AIX,Free BSD,Open BSD,OS X等平台上。

zabbix agent需要安装在被监视的目标服务器上,它主要完成对硬件信息或与操作系统有关的内存,CPU等信息的收集。

zabbix server可以单独监视远程服务器的服务状态;同时也可以与zabbix agent配合,可以轮询zabbix agent主动接收监视数据(agent方式),同时还可被动接收zabbix agent发送的数据(trapping方式)。
另外zabbix server还支持SNMP (v1,v2),可以与SNMP软件(例如:net-snmp)等配合使用。

2. zabbix特点

zabbix的主要特点:

  • 安装与配置简单,学习成本低
  • 支持多语言(包括中文)
  • 免费开源
  • 自动发现服务器与网络设备
  • 分布式监视以及WEB集中管理功能
  • 可以无agent监视
  • 用户安全认证和柔软的授权方式
  • 通过WEB界面设置或查看监视结果
  • email等通知功能

Zabbix主要功能:

  • CPU负荷
  • 内存使用
  • 磁盘使用
  • 网络状况
  • 端口监视
  • 日志监视

3. zabbix配置文件

zabbix配置文件有两种:

  • 服务器端配置文件(/usr/local/etc/zabbix_server.conf)
  • 客户端配置文件(/usr/local/etc/zabbix_agentd.conf)
  • zabbix代理配置文件(/usr/local/etc/zabbix_proxy.conf)

服务器端配置文件zabbix_server.conf常用配置参数:

参数作用
LogFile设置服务端日志文件存放路径
ListenIP设置服务端监听IP
ListenPort设置服务端监听的端口号
PidFile设置服务端进程号文件存放路径
DBHost指定zabbix的数据库服务器IP
DBName指定zabbix使用的数据库库名
DBUser指定zabbix数据库登录用户
DBPassword指定zabbix数据库登录密码
DBPort指定zabbix数据库端口号
User设置zabbix以什么用户的身份运行
AlertScriptsPath设置告警脚本存放路径
ExternalScripts外部脚本存放路径

客户端配置文件zabbix_agentd.conf常用配置参数:

参数作用
Server指定zabbix服务器的IP或域名
ServerActive指定zabbix服务器的IP或域名
Hostname指定本机的主机名,此项必须与web界面配置项一致
UnsafeUserParameters是否启用自定义监控项,可选值为{1 | 0}
UserParameter指定自定义监控脚本参数
LogFile设置客户端日志文件存放路径

4. 部署zabbix

环境说明:

环境IP要安装的应用
服务器192.168.116.140lamp架构 zabbix server zabbix agent
客户端192.168.116.143zabbix agent

因为zabbix是用php语言开发的,所以必须先部署lamp架构,使其能够支持运行php网页

[root@localhost ~]# hostnamectl set-hostname zabbix-server
[root@localhost ~]# bash
[root@zabbix-server ~]# 
[root@zabbix-server ~]# systemctl disable --now firewalld
Removed "/etc/systemd/system/multi-user.target.wants/firewalld.service".
Removed "/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service".
[root@zabbix-server ~]# vi /etc/selinux/config
[root@zabbix-server ~]# cat /etc/selinux/config | grep '^SELINUX'
SELINUX=disabled
SELINUXTYPE=targeted
[root@zabbix-server ~]# setenforce 0
[root@zabbix-server ~]# getenforce
Permissive

4.1apache安装

1.安装依赖包
[root@zabbix-server ~]# yum -y install openssl-devel pcre-devel expat-devel libtool gcc gcc-c++ make vim
Complete!

2.创建系统用户
[root@zabbix-server ~]# useradd -r -M -s /sbin/nologin apache
[root@zabbix-server ~]# id apache
uid=991(apache) gid=991(apache) groups=991(apache)

3.下载软件包(官网下apache.org)
[root@zabbix-server ~]# wget https://downloads.apache.org/apr/apr-1.7.4.tar.gz
[root@zabbix-server ~]# wget https://downloads.apache.org/apr/apr-util-1.6.3.tar.gz
[root@zabbix-server ~]# wget https://downloads.apache.org/httpd/httpd-2.4.58.tar.gz

4.解压软件包
[root@zabbix-server ~]# ls
anaconda-ks.cfg  apr-1.7.4.tar.gz  apr-util-1.6.3.tar.gz  httpd-2.4.58.tar.gz
[root@zabbix-server ~]# tar xf apr-1.7.4.tar.gz 
[root@zabbix-server ~]# tar xf apr-util-1.6.3.tar.gz 
[root@zabbix-server ~]# tar xf httpd-2.4.58.tar.gz 
[root@zabbix-server ~]# ls
anaconda-ks.cfg  apr-1.7.4  apr-1.7.4.tar.gz  apr-util-1.6.3  apr-util-1.6.3.tar.gz  httpd-2.4.58  httpd-2.4.58.tar.gz

5.编译软件包
//apr-1.7.4
[root@zabbix-server ~]# cd apr-1.7.4
[root@zabbix-server apr-1.7.4]# ls
apr-config.in  apr.pc.in   buildconf         configure     encoding    libapr.dsp  Makefile.in   network_io     random        support     tools
apr.dep        apr.spec    build-outputs.mk  configure.in  file_io     libapr.mak  Makefile.win  NOTICE         README        tables      user
apr.dsp        atomic      CHANGES           docs          helpers     libapr.rc   memory        NWGNUmakefile  README.cmake  test
apr.dsw        build       CMakeLists.txt    dso           include     LICENSE     misc          passwd         shmem         threadproc
apr.mak        build.conf  config.layout     emacs-mode    libapr.dep  locks       mmap          poll           strings       time
[root@zabbix-server apr-1.7.4]# vim configure
cfgfile=${ofile}T
    trap "$RM \"$cfgfile\"; exit 1" 1 2 15
   # $RM "$cfgfile"          //注释这一行后者删除这一行

[root@zabbix-server apr-1.7.4]# ./configure --prefix=/usr/local/apr
[root@zabbix-server apr-1.7.4]# ls       //是否生成makefile文件
apr-1-config    apr.exp    build             config.layout  docs           file_io      libapr.mak  Makefile.in   NOTICE         README.cmake  threadproc
apr-config.in   apr.mak    build.conf        config.log     dso            helpers      libapr.rc   Makefile.win  NWGNUmakefile  shmem         time
apr-config.out  apr.pc     buildconf         config.nice    emacs-mode     include      libtool     memory        passwd         strings       tools
apr.dep         apr.pc.in  build-outputs.mk  config.status  encoding       libapr-1.la  LICENSE     misc          poll           support       user
apr.dsp         apr.spec   CHANGES           configure      exports.c      libapr.dep   locks       mmap          random         tables
apr.dsw         atomic     CMakeLists.txt    configure.in   export_vars.c  libapr.dsp   Makefile    network_io    README         test
[root@zabbix-server apr-1.7.4]# make
[root@zabbix-server apr-1.7.4]# make install

//apr-util-1.6.3
[root@zabbix-server ~]# cd apr-util-1.6.3
[root@zabbix-server apr-util-1.6.3]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@zabbix-server apr-util-1.6.3]# make
[root@zabbix-server apr-util-1.6.3]# make install

//httpd-2.4.58
[root@zabbix-server ~]# cd httpd-2.4.58
[root@zabbix-server httpd-2.4.58]# ./configure --prefix=/usr/local/apache \
> --enable-so \
> --enable-ssl \
> --enable-cgi \
> --enable-rewrite \
> --with-zlib \
> --with-pcre \
> --with-apr=/usr/local/apr \
> --with-apr-util=/usr/local/apr-util/ \
> --enable-modules=most \
> --enable-mpms-shared=all \
> --with-mpm=prefork
[root@zabbix-server httpd-2.4.58]# make
[root@zabbix-server httpd-2.4.58]# make install

6.配置环境变量
[root@zabbix-server ~]# cd /usr/local/apache
[root@zabbix-server apache]# ls
bin  build  cgi-bin  conf  error  htdocs  icons  include  logs  man  manual  modules
[root@zabbix-server apache]# echo 'export PATH=/usr/local/apache/bin:$PATH' > /etc/profile.d/httpd.sh
[root@zabbix-server apache]# source /etc/profile.d/httpd.sh 
[root@zabbix-server apache]# ln -s /usr/local/apache/include/ /usr/include/apache

7.设置开机自启
[root@zabbix-server ~]# cd /usr/lib/systemd/system
[root@zabbix-server system]# cp sshd.service httpd.service
[root@zabbix-server system]# vim httpd.service 
[root@zabbix-server system]# cat httpd.service 
[Unit]
Description=httpd server daemon
After=network.target 

[Service]
Type=forking
ExecStart=/usr/local/apache/bin/apachectl start
ExecStop=/usr/local/apache/bin/apachectl stop
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target
[root@zabbix-server system]# systemctl daemon-reload
[root@zabbix-server system]# systemctl enable --now httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@zabbix-server system]# ss -antl
State              Recv-Q             Send-Q                           Local Address:Port                           Peer Address:Port             Process             
LISTEN             0                  128                                    0.0.0.0:22                                  0.0.0.0:*                                    
LISTEN             0                  128                                       [::]:22                                     [::]:*                                    
LISTEN             0                  511                                          *:80                                        *:*                                    

4.2mysql安装

1.安装依赖包
//mariadb-devel要到pkgs.org上面找这个软件包默认是没有的
[root@zabbix-server ~]# yum -y install https://mirror.stream.centos.org/9-stream/CRB/x86_64/os/Packages/mariadb-devel-10.5.16-2.el9.x86_64.rpm
[root@zabbix-server ~]# yum -y install ncurses-devel openssl-devel openssl cmake

2.创建系统用户
[root@zabbix-server ~]# useradd -r -M -s /sbin/nologin mysql
[root@zabbix-server ~]# id mysql
uid=990(mysql) gid=990(mysql) groups=990(mysql)

3.下载软件包(官网下:mysql.com,下了之后上传)
[root@zabbix-server ~]# ls
anaconda-ks.cfg  apr-1.7.4  apr-1.7.4.tar.gz  apr-util-1.6.3  apr-util-1.6.3.tar.gz  httpd-2.4.58  httpd-2.4.58.tar.gz  mysql-8.0.35-linux-glibc2.28-x86_64.tar.xz

4.解压软件包
[root@zabbix-server ~]# ls
anaconda-ks.cfg  apr-1.7.4  apr-1.7.4.tar.gz  apr-util-1.6.3  apr-util-1.6.3.tar.gz  httpd-2.4.58  httpd-2.4.58.tar.gz  mysql-8.0.35-linux-glibc2.28-x86_64.tar.xz
[root@zabbix-server ~]# 
[root@zabbix-server ~]# tar xf mysql-8.0.35-linux-glibc2.28-x86_64.tar.xz -C /usr/local
[root@zabbix-server ~]# cd /usr/local
[root@zabbix-server local]# ls
apache  apr  apr-util  bin  etc  games  include  lib  lib64  libexec  mysql-8.0.35-linux-glibc2.28-x86_64  sbin  share  src
[root@zabbix-server local]# mv mysql-8.0.35-linux-glibc2.28-x86_64 mysql
[root@zabbix-server local]# ls
apache  apr  apr-util  bin  etc  games  include  lib  lib64  libexec  mysql  sbin  share  src

5.配置环境变量
[root@zabbix-server local]# cd mysql
[root@zabbix-server mysql]# ls
bin  docs  include  lib  LICENSE  man  README  share  support-files
[root@zabbix-server mysql]# echo 'PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@zabbix-server mysql]# source /etc/profile.d/mysql.sh
[root@zabbix-server mysql]# ln -s /usr/local/mysql/include/ /usr/include/mysql/
[root@zabbix-server mysql]# vim /etc/ld.so.conf.d/mysql.conf
[root@zabbix-server mysql]# cat /etc/ld.so.conf.d/mysql.conf
/usr/local/mysql/lib
[root@zabbix-server mysql]# ldconfig -v

6.修改用户所有者和所属组
[root@zabbix-server ~]# chown -R mysql.mysql /usr/local/mysql
[root@zabbix-server ~]# ll /usr/local/mysql
total 296
drwxr-xr-x.  2 mysql mysql   4096 Oct 12 22:11 bin
drwxr-xr-x.  2 mysql mysql     38 Oct 12 22:11 docs
drwxr-xr-x.  3 mysql mysql   4096 Oct 12 22:11 include
drwxr-xr-x.  6 mysql mysql   4096 Oct 12 22:11 lib
-rw-r--r--.  1 mysql mysql 279355 Oct 12 19:45 LICENSE
drwxr-xr-x.  4 mysql mysql     30 Oct 12 22:11 man
-rw-r--r--.  1 mysql mysql    666 Oct 12 19:45 README
drwxr-xr-x. 28 mysql mysql   4096 Oct 12 22:11 share
drwxr-xr-x.  2 mysql mysql     77 Oct 12 22:11 support-files

7.初始化
//创建目录并修改所有者和所属组
[root@zabbix-server ~]# mkdir /opt/data
[root@zabbix-server ~]# chown -R mysql.mysql /opt/data
[root@zabbix-server ~]# ll -d /opt/data
drwxr-xr-x. 2 mysql mysql 6 Jan  4 14:48 /opt/data
[root@zabbix-server ~]# mysqld --initialize --user mysql --datadir /opt/data
2024-01-04T06:49:33.874760Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.35) initializing of server in progress as process 159751
2024-01-04T06:49:33.881444Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2024-01-04T06:49:34.200975Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2024-01-04T06:49:36.290548Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: QiM.!Wu&#1ip
[root@zabbix-server ~]# echo 'QiM.!Wu&#1ip'>pass
[root@zabbix-server ~]# cat pass
QiM.!Wu&#1ip

8.生成配置文件
[root@zabbix-server ~]# vim /etc/my.cnf
[root@zabbix-server ~]# cat /etc/my.cnf
[mysqld]
basedir = /usr/local/mysql
datadir = /opt/data
socket = /tmp/mysql.sock
port = 3306
pid-file = /opt/data/mysql.pid
user = mysql
skip-name-resolve

9.配置服务启动脚本
[root@zabbix-server ~]# cd /usr/local/mysql/support-files/
[root@zabbix-server support-files]# ls
mysqld_multi.server  mysql-log-rotate  mysql.server
[root@zabbix-server support-files]# mkdir /etc/init.d
[root@zabbix-server support-files]# cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@zabbix-server support-files]# vim /etc/init.d/mysqld 
basedir=/usr/local/mysql
datadir=/opt/data

10.设置开机自启
[root@zabbix-server ~]# cd /usr/lib/systemd/system
[root@zabbix-server system]# cp sshd.service mysqld.service
[root@zabbix-server system]# vim mysqld.service 
[root@zabbix-server system]# cat mysqld.service 
[Unit]
Description=mysql server daemon
After=network.target 

[Service]
Type=forking
ExecStart=service mysqld start
ExecStop=service mysqld stop
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target
[root@zabbix-server system]# systemctl daemon-reload
[root@zabbix-server system]# systemctl enable --now mysqld
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.
[root@zabbix-server system]# ss -antl
State              Recv-Q             Send-Q                          Local Address:Port                            Peer Address:Port             Process             
LISTEN             0                  128                                   0.0.0.0:22                                   0.0.0.0:*                                    
LISTEN             0                  128                                      [::]:22                                      [::]:*                                    
LISTEN             0                  511                                         *:80                                         *:*                                    
LISTEN             0                  151                                         *:3306                                       *:*                                    
LISTEN             0                  70                                          *:33060                                      *:*                                    

11.修改数据库密码
[root@zabbix-server ~]# cat pass
QiM.!Wu&#1ip
[root@zabbix-server ~]# mysql -uroot -p'QiM.!Wu&#1ip'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.35

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> alter user root@localhost identified with mysql_native_password by 'Passw0rd@_~';
Query OK, 0 rows affected (0.01 sec)

mysql> quit
Bye
[root@zabbix-server ~]# mysql -uroot -pPassw0rd@_~
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.35 MySQL Community Server - GPL

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> quit
Bye

php安装(yum方式)

1.安装php
[root@zabbix-server ~]# yum list all | grep php
php.x86_64                                           8.0.30-1.el9_2                      appstream    
php-bcmath.x86_64                                    8.0.30-1.el9_2                      appstream    
php-cli.x86_64                                       8.0.30-1.el9_2                      appstream    
php-common.x86_64                                    8.0.30-1.el9_2                      appstream    
php-dba.x86_64                                       8.0.30-1.el9_2                      appstream    
php-dbg.x86_64                                       8.0.30-1.el9_2                      appstream    
php-devel.x86_64                                     8.0.30-1.el9_2                      appstream    
php-embedded.x86_64                                  8.0.30-1.el9_2                      appstream    
php-enchant.x86_64                                   8.0.30-1.el9_2                      appstream    
php-ffi.x86_64                                       8.0.30-1.el9_2                      appstream    
php-fpm.x86_64                                       8.0.30-1.el9_2                      appstream    
php-gd.x86_64                                        8.0.30-1.el9_2                      appstream    
php-gmp.x86_64                                       8.0.30-1.el9_2                      appstream    
php-intl.x86_64                                      8.0.30-1.el9_2                      appstream    
php-ldap.x86_64                                      8.0.30-1.el9_2                      appstream    
php-mbstring.x86_64                                  8.0.30-1.el9_2                      appstream    
php-mysqlnd.x86_64                                   8.0.30-1.el9_2                      appstream    
php-odbc.x86_64                                      8.0.30-1.el9_2                      appstream    
php-opcache.x86_64                                   8.0.30-1.el9_2                      appstream    
php-pdo.x86_64                                       8.0.30-1.el9_2                      appstream    
php-pear.noarch                                      1:1.10.13-1.el9                     appstream    
php-pecl-apcu.x86_64                                 5.1.20-5.el9                        appstream    
php-pecl-apcu-devel.x86_64                           5.1.20-5.el9                        appstream    
php-pecl-rrd.x86_64                                  2.0.3-3.el9                         appstream    
php-pecl-xdebug3.x86_64                              3.1.2-1.el9                         appstream    
php-pecl-zip.x86_64                                  1.19.2-6.el9                        appstream    
php-pgsql.x86_64                                     8.0.30-1.el9_2                      appstream    
php-process.x86_64                                   8.0.30-1.el9_2                      appstream    
php-snmp.x86_64                                      8.0.30-1.el9_2                      appstream    
php-soap.x86_64                                      8.0.30-1.el9_2                      appstream    
php-xml.x86_64                                       8.0.30-1.el9_2                      appstream    
[root@zabbix-server ~]# yum -y install php*
Complete!

2.启动服务
[root@zabbix-server ~]# systemctl enable --now php-fpm
Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service → /usr/lib/systemd/system/php-fpm.service.
[root@zabbix-server ~]# ss -antl
State              Recv-Q             Send-Q                          Local Address:Port                            Peer Address:Port             Process             
LISTEN             0                  128                                   0.0.0.0:22                                   0.0.0.0:*                                    
LISTEN             0                  128                                      [::]:22                                      [::]:*                                    
LISTEN             0                  511                                         *:80                                         *:*                                    
LISTEN             0                  151                                         *:3306                                       *:*                                    
LISTEN             0                  70                                          *:33060                                      *:*                                    
[root@zabbix-server ~]# find / -name www.conf
/etc/php-fpm.d/www.conf
[root@zabbix-server ~]# vim /etc/php-fpm.d/www.conf
listen = 0.0.0.0:9000
[root@zabbix-server ~]# systemctl restart php-fpm
[root@zabbix-server ~]# ss -antl
State              Recv-Q             Send-Q                          Local Address:Port                            Peer Address:Port             Process             
LISTEN             0                  511                                   0.0.0.0:9000                                 0.0.0.0:*                                    
LISTEN             0                  128                                   0.0.0.0:22                                   0.0.0.0:*                                    
LISTEN             0                  128                                      [::]:22                                      [::]:*                                    
LISTEN             0                  511                                         *:80                                         *:*                                    
LISTEN             0                  151                                         *:3306                                       *:*                                    
LISTEN             0                  70                                          *:33060                                      *:*                                    

[root@zabbix-server opt]# yum -y remove httpd     //用yum安装php包的时候,把httpd也一并安装了,这时需要卸载一并安装的,因为上面已经源码安装了
Complete!
[root@zabbix-server ~]# rpm -qa | grep httpd
httpd-filesystem-2.4.57-5.el9.noarch
[root@zabbix-server ~]# apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::20c:29ff:feed:2b10%ens33. Set the 'ServerName' directive globally to suppress this message
//出现这种提示,修改一下配置就行
[root@zabbix-server ~]# vim /usr/local/apache/conf/httpd.conf 
#ServerName www.example.com:80    //取消这一行注释

4.3php安装(源码方式)

1.安装依赖包
[root@localhost ~]# yum list all | grep php | grep mysql
php-mysqlnd.x86_64                                   8.0.30-1.el9_2                      appstream    

[root@localhost ~]# yum -y install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libicu-devel libjpeg libjpeg-devel libpng libpng-devel openldap-devel  pcre-devel freetype freetype-devel gmp gmp-devel  readline readline-devel libxslt libxslt-devel  php-mysqlnd
Complete!
[root@localhost ~]# echo $?
0

2.下载php软件包(官网下最新的:php.net)
[root@localhost ~]# wget https://www.php.net/distributions/php-8.3.0.tar.xz
[root@localhost ~]# ls
anaconda-ks.cfg  apr-1.7.4.tar.gz  apr-util-1.6.3.tar.gz  httpd-2.4.58.tar.gz                         pass
apr-1.7.4        apr-util-1.6.3    httpd-2.4.58           mysql-8.0.35-linux-glibc2.28-x86_64.tar.xz  php-8.3.0.tar.xz

3.解压软件包
[root@localhost ~]# tar xf php-8.3.0.tar.xz 
[root@localhost ~]# cd php-8.3.0
[root@localhost php-8.3.0]# ls
appveyor   buildconf.bat        configure.ac     EXTENSIONS  pear                 README.REDIST.BINS  SECURITY.md  UPGRADING
benchmark  CODEOWNERS           CONTRIBUTING.md  LICENSE     php.ini-development  run-tests.php       tests        UPGRADING.INTERNALS
build      CODING_STANDARDS.md  docs             main        php.ini-production   sapi                travis       win32
buildconf  configure            ext              NEWS        README.md            scripts             TSRM         Zend
4.编译安装php
[root@localhost php-8.3.0]# ./configure --prefix=/usr/local/php8  \
> --with-config-file-path=/etc \
> --enable-fpm \
> --enable-inline-optimization \
> --disable-debug \
> --disable-rpath \
> --enable-shared \
> --enable-soap \
> --with-openssl \
> --enable-bcmath \
> --with-iconv \
> --with-bz2 \
> --enable-calendar \
> --with-curl \
> --enable-exif  \
> --enable-ftp \
> --with-gd \
> --with-jpeg-dir \
> --with-png-dir \
> --with-zlib-dir \
> --with-freetype-dir \
> --with-gettext \
> --enable-json \
> --enable-mbstring \
> --enable-pdo \
> --with-mysqli=mysqlnd \
> --with-pdo-mysql=mysqlnd \
> --with-readline \
> --enable-shmop \
> --enable-simplexml \
> --enable-sockets \
> --enable-zip \
> --enable-mysqlnd-compression-support \
> --with-pear \
> --enable-pcntl \
> --enable-posix
configure: WARNING: unrecognized options: --enable-inline-optimization, --with-gd, --with-jpeg-dir, --with-png-dir, --with-freetype-dir, --enable-json, --enable-zip
checking for grep that handles long lines and -e... /usr/bin/grep   //开头的警告

configure: error: Package requirements (sqlite3 >= 3.7.7) were not met:  //结尾的报错
Package 'sqlite3', required by 'virtual:world', not found

//解决方案
[root@localhost php-8.3.0]# ./configure --help | grep optimization
[root@localhost php-8.3.0]# ./configure --help | grep gd
  --with-gdbm[=DIR]       DBA: GDBM support
  --enable-gd             Include GD support
  --with-external-gd      Use external libgd
  --with-avif             GD: Enable AVIF support (only for bundled libgd)
  --with-webp             GD: Enable WEBP support (only for bundled libgd)
  --with-jpeg             GD: Enable JPEG support (only for bundled libgd)
  --with-xpm              GD: Enable XPM support (only for bundled libgd)
                          libgd)
  --enable-gd-jis-conv    GD: Enable JIS-mapped Japanese font support (only
                          for bundled libgd)
[root@localhost php-8.3.0]# ./configure --help | grep jpeg
  --with-jpeg             GD: Enable JPEG support (only for bundled libgd)
[root@localhost php-8.3.0]# ./configure --help | grep png
[root@localhost php-8.3.0]# ./configure --help | grep freetype
  --with-freetype         GD: Enable FreeType 2 support (only for bundled
[root@localhost php-8.3.0]# 
[root@localhost php-8.3.0]# ./configure --help | grep json
[root@localhost php-8.3.0]# ./configure --help | grep zip
  --with-zip              Include Zip read/write support

//修改后重新编译
[root@localhost php-8.3.0]#./configure --prefix=/usr/local/php8  \
--with-config-file-path=/etc \
--enable-fpm \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-soap \
--with-openssl \
--enable-bcmath \
--with-iconv \
--with-bz2 \
--enable-calendar \
--with-curl \
--enable-exif  \
--enable-ftp \
--enable-gd \
--with-jpeg \
--with-zlib-dir \
--with-freetype \
--with-gettext \
--enable-mbstring \
--enable-pdo \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-readline \
--enable-shmop \
--enable-simplexml \
--enable-sockets \
--with-zip \
--enable-mysqlnd-compression-support \
--with-pear \
--enable-pcntl \
--enable-posix
configure: error: Package requirements (sqlite3 >= 3.7.7) were not met:
Package 'sqlite3', required by 'virtual:world', not found

//解决方案
[root@localhost php-8.3.0]# yum -y install epel-release
[root@localhost php-8.3.0]# yum list all | grep sqlite3
libsqlite3x.x86_64                                                                       20071018-31.el9                                epel               
libsqlite3x-devel.x86_64                                                                 20071018-31.el9                                epel               
preludedb-sqlite3.x86_64                                                                 5.2.0-2.el9                                    epel               
rubygem-sqlite3.x86_64                                                                   1.4.2-8.el9                                    epel               
rubygem-sqlite3-doc.noarch                                                               1.4.2-8.el9                                    epel               
soci-sqlite3.x86_64                                                                      4.0.3-1.el9                                    epel               
soci-sqlite3-devel.x86_64                                                                4.0.3-1.el9                                    epel               
uwsgi-plugin-sqlite3.x86_64                                                              2.0.23-1.el9                                   epel               
zabbix-dbfiles-sqlite3.noarch                                                            1:6.0.22-2.el9                                 epel               
zabbix-proxy-sqlite3.x86_64                                                              1:6.0.22-2.el9                                 epel               
[root@localhost php-8.3.0]# yum -y install libsqlite3x-devel
Complete!

//重新编译
[root@localhost php-8.3.0]# ./configure --prefix=/usr/local/php8  \
.........
configure: error: Package requirements (oniguruma) were not met:
Package 'oniguruma', required by 'virtual:world', not found

//解决方案
[root@localhost php-8.3.0]# yum list all | grep oniguruma
oniguruma.i686                                                                           6.9.6-1.el9.5                                  appstream          
oniguruma.x86_64                                                                         6.9.6-1.el9.5                                  appstream          
[root@localhost php-8.3.0]# cd
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
epel-cisco-openh264.repo  epel.repo  epel-testing.repo  rocky-addons.repo  rocky-devel.repo  rocky-extras.repo  rocky.repo
[root@localhost yum.repos.d]# vim rocky-devel.repo 
[root@localhost yum.repos.d]# cat rocky-devel.repo 
[devel]
name=Rocky Linux $releasever - Devel WARNING! FOR BUILDROOT ONLY DO NOT LEAVE ENABLED
mirrorlist=https://mirrors.rockylinux.org/mirrorlist?arch=$basearch&repo=devel-$releasever$rltype
#baseurl=http://dl.rockylinux.org/$contentdir/$releasever/devel/$basearch/os/
gpgcheck=1
enabled=1
countme=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Rocky-9
[root@localhost yum.repos.d]# yum list all | grep oniguruma
oniguruma.i686                                                                           6.9.6-1.el9.5                                  appstream          
oniguruma.x86_64                                                                         6.9.6-1.el9.5                                  appstream          
oniguruma.x86_64                                                                         6.9.6-1.el9.5                                  devel              
oniguruma-devel.x86_64                                                                   6.9.6-1.el9.5                                  devel              
[root@localhost php-8.3.0]# yum -y install oniguruma-devel
Complete!

//重新编译
[root@localhost php-8.3.0]# ./configure --prefix=/usr/local/php8  \
........
configure: error: Package requirements (libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0) were not met:

Package 'libzip', required by 'virtual:world', not found
Package 'libzip', required by 'virtual:world', not found
Package 'libzip', required by 'virtual:world', not found

//解决方案
[root@localhost php-8.3.0]# yum list all | grep libzip
libzip.i686                                                                              1.7.3-7.el9                                    appstream          
libzip.x86_64                                                                            1.7.3-7.el9                                    appstream          
libzip.x86_64                                                                            1.7.3-7.el9                                    devel              
libzip-devel.x86_64                                                                      1.7.3-7.el9                                    devel              
libzip-tools.x86_64                                                                      1.7.3-7.el9                                    devel              
[root@localhost php-8.3.0]# yum -y install libzip-devel
Complete!

//重新编译
[root@localhost php-8.3.0]# ./configure --prefix=/usr/local/php8  \
--with-config-file-path=/etc \
--enable-fpm \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-soap \
--with-openssl \
--enable-bcmath \
--with-iconv \
--with-bz2 \
--enable-calendar \
--with-curl \
--enable-exif  \
--enable-ftp \
--enable-gd \
--with-jpeg \
--with-zlib-dir \
--with-freetype \
--with-gettext \
--enable-mbstring \
--enable-pdo \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-readline \
--enable-shmop \
--enable-simplexml \
--enable-sockets \
--with-zip \
--enable-mysqlnd-compression-support \
--with-pear \
--enable-pcntl \
--enable-posix
config.status: executing default commands

+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE. By continuing this installation  |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.

[root@localhost php-8.3.0]# make
[root@localhost php-8.3.0]# echo $?
0
[root@localhost php-8.3.0]# make install
[root@localhost php-8.3.0]# echo $?
0

5.配置环境变量
[root@localhost ~]# cd /usr/local/php8
[root@localhost php8]# ls
bin  etc  include  lib  php  sbin  var
[root@localhost php8]# echo 'export PATH=/usr/local/php8/bin:/usr/local/php8/sbin:$PATH' > /etc/profile.d/php8.sh
[root@localhost php8]# source /etc/profile.d/php8.sh
[root@localhost php8]# which php
/usr/local/php8/bin/php
[root@localhost php8]# php -v
PHP 8.3.0 (cli) (built: Dec 11 2023 17:25:44) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.0, Copyright (c) Zend Technologies

6.配置php-fpm
[root@localhost ~]# cd php-8.3.0
[root@localhost php-8.3.0]# ls
appveyor       CODEOWNERS           configure        EXTENSIONS  main                NEWS                 README.REDIST.BINS  tests                win32
benchmark      CODING_STANDARDS.md  configure.ac     include     Makefile            pear                 run-tests.php       travis               Zend
build          config.log           CONTRIBUTING.md  libs        Makefile.fragments  php.ini-development  sapi                TSRM
buildconf      config.nice          docs             libtool     Makefile.objects    php.ini-production   scripts             UPGRADING
buildconf.bat  config.status        ext              LICENSE     modules             README.md            SECURITY.md         UPGRADING.INTERNALS
[root@localhost php-8.3.0]# cp php.ini-production /etc/php.ini
cp: overwrite '/etc/php.ini'? y
[root@localhost php-8.3.0]# 
[root@localhost php-8.3.0]# cd sapi
[root@localhost sapi]# ls
apache2handler  cgi  cli  embed  fpm  fuzzer  litespeed  phpdbg
[root@localhost sapi]# cd fpm
[root@localhost fpm]# ls
config.m4  fpm             init.d.php-fpm.in  Makefile.frag  php-fpm.8     php-fpm.conf     php-fpm.service     status.html     tests     www.conf.in
CREDITS    init.d.php-fpm  LICENSE            php-fpm        php-fpm.8.in  php-fpm.conf.in  php-fpm.service.in  status.html.in  www.conf
[root@localhost php-8.3.0]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@localhost php-8.3.0]# chmod +x /etc/init.d/php-fpm
[root@localhost php-8.3.0]# ll -d /etc/init.d/php-fpm
-rwxr-xr-x. 1 root root 2402 Dec 11 17:53 /etc/init.d/php-fpm

[root@localhost ~]# cd /usr/local/php8
[root@localhost php8]# ls
bin  etc  include  lib  php  sbin  var
[root@localhost php8]# cd /etc
[root@localhost etc]# cp /usr/local/php8/etc/php-fpm.conf.default /usr/local/php8/etc/php-fpm.conf
[root@localhost etc]# cp /usr/local/php8/etc/php-fpm.d/www.conf.default /usr/local/php8/etc/php-fpm.d/www.conf

7.启动php.fpm
[root@localhost ~]# service php-fpm start
Starting php-fpm  done
[root@localhost ~]# ss -antl
State              Recv-Q             Send-Q                          Local Address:Port                            Peer Address:Port             Process             
LISTEN             0                  128                                   0.0.0.0:22                                   0.0.0.0:*                                    
LISTEN             0                  4096                                127.0.0.1:9000                                 0.0.0.0:*                                    
LISTEN             0                  151                                         *:3306                                       *:*                                    
LISTEN             0                  70                                          *:33060                                      *:*                                    
LISTEN             0                  511                                         *:80                                         *:*                                    
LISTEN             0                  128                                      [::]:22                                      [::]:*                                    

4.4配置apache代理

[root@zabbix-server ~]# vim /usr/local/apache/conf/httpd.conf 
LoadModule proxy_module modules/mod_proxy.so            //取消这一行注释
#LoadModule proxy_connect_module modules/mod_proxy_connect.so
#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
#LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so      //取消这一行注释
#LoadModule proxy_scgi_module modules/mod_proxy_scgi.so
#LoadModule proxy_uwsgi_module modules/mod_proxy_uwsgi.so
#LoadModule proxy_fdpass_module modules/mod_proxy_fdpass.so
#LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
#LoadModule proxy_ajp_module modules/mod_proxy_ajp.so

    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddType application/x-httpd-php .php      //添加这一行
    AddType application/x-httpd-php-source .phps   //添加这一行

# Virtual hosts
#Include conf/extra/httpd-vhosts.conf
Include conf/extra/vhosts.conf            //添加这一行

<IfModule dir_module>
    DirectoryIndex  index.html index.php(添加这)
</IfModule>
[root@zabbix-server ~]# systemctl restart httpd

[root@zabbix-server ~]# cd /usr/local/apache/
[root@zabbix-server apache]# ls
bin  build  cgi-bin  conf  error  htdocs  icons  include  logs  man  manual  modules
[root@zabbix-server apache]# cd htdocs/
[root@zabbix-server htdocs]# ls
index.html
[root@zabbix-server htdocs]# mkdir test
[root@zabbix-server htdocs]# ls
index.html  test
[root@zabbix-server test]# vim index.php
<?php
phpinfo();
?>
[root@zabbix-server test]# ls
index.php

[root@zabbix-server apache]# ls
bin  build  cgi-bin  conf  error  htdocs  icons  include  logs  man  manual  modules
[root@zabbix-server apache]# cd conf
[root@zabbix-server conf]# ls
extra  httpd.conf  magic  mime.types  original
[root@zabbix-server conf]# ls extra/
httpd-autoindex.conf  httpd-default.conf  httpd-languages.conf  httpd-mpm.conf                 httpd-ssl.conf      httpd-vhosts.conf
httpd-dav.conf        httpd-info.conf     httpd-manual.conf     httpd-multilang-errordoc.conf  httpd-userdir.conf  proxy-html.conf
[root@zabbix-server conf]# vim extra/vhosts.conf
[root@zabbix-server conf]# cat extra/vhosts.conf 
<VirtualHost *:80>
    DocumentRoot "/usr/local/apache/htdocs/test"
    ServerName www.test.com
    ProxyRequests Off
    ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/test$1
    <Directory "/usr/local/apache/htdocs/test">
        Options none
        AllowOverride none
        Require all granted
    </Directory>
</VirtualHost>  

[root@zabbix-server apache]# chown -R apache.apache /usr/local/apache/htdocs/
[root@zabbix-server ~]# systemctl restart httpd
[root@zabbix-server ~]# systemctl restart php-fpm

在这里插入图片描述

4.5zabbix安装

1.安装依赖包
[root@zabbix-server ~]# yum -y install net-snmp-devel libevent-devel
Complete!

2.下载zabbix与解压
[root@zabbix-server ~]# ls
anaconda-ks.cfg  apr-1.7.4.tar.gz  apr-util-1.6.3.tar.gz  httpd-2.4.58.tar.gz                         pass       php-8.3.0.tar.xz
apr-1.7.4        apr-util-1.6.3    httpd-2.4.58           mysql-8.0.35-linux-glibc2.28-x86_64.tar.xz  php-8.3.0  zabbix-6.4.10.tar.gz
[root@zabbix-server ~]# tar xf zabbix-6.4.10.tar.gz 
[root@zabbix-server ~]# ls
anaconda-ks.cfg  apr-1.7.4.tar.gz  apr-util-1.6.3.tar.gz  httpd-2.4.58.tar.gz                         pass       php-8.3.0.tar.xz  zabbix-6.4.10.tar.gz
apr-1.7.4        apr-util-1.6.3    httpd-2.4.58           mysql-8.0.35-linux-glibc2.28-x86_64.tar.xz  php-8.3.0  zabbix-6.4.10

3.创建zabbix用户
[root@zabbix-server ~]# useradd -r -M -s /sbin/nologin zabbix
[root@zabbix-server ~]# id zabbix
uid=987(zabbix) gid=987(zabbix) groups=987(zabbix)

4.配置zabbix数据库
[root@zabbix-server ~]# mysql -uroot -pPassw0rd@_~
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.35 MySQL Community Server - GPL

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
Query OK, 1 row affected (0.02 sec)
mysql> create user 'zabbix'@'localhost' identified with mysql_native_password by 'Passw0rd@_~';
Query OK, 0 rows affected (0.01 sec)

mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> SET GLOBAL log_bin_trust_function_creators = 1;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql> quit
Bye

[root@zabbix-server ~]# cd zabbix-6.4.10
[root@zabbix-server zabbix-6.4.10]# ls
aclocal.m4  bin    ChangeLog  conf          config.sub  configure.ac  database  include  install-sh  Makefile.am  man   missing  README  src
AUTHORS     build  compile    config.guess  configure   COPYING       depcomp   INSTALL  m4          Makefile.in  misc  NEWS     sass    ui
[root@zabbix-server zabbix-6.4.10]# cd database/mysql
[root@zabbix-server mysql]# ls
data.sql  images.sql  Makefile.am  Makefile.in  option-patches  schema.sql
[root@zabbix-server mysql]# mysql -uzabbix -pPassw0rd@_~ zabbix < schema.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@zabbix-server mysql]# mysql -uzabbix -pPassw0rd@_~ zabbix < images.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@zabbix-server mysql]# mysql -uzabbix -pPassw0rd@_~ --default-character-set=utf8mb4 zabbix < data.sql
mysql: [Warning] Using a password on the command line interface can be insecure.

[root@zabbix-server mysql]# mysql -uroot -pPassw0rd@_~

mysql> SET GLOBAL log_bin_trust_function_creators = 0;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> quit
Bye

[root@zabbix-server ~]# export CFLAGS="-std=gnu99"

5.编译安装zabbix
[root@zabbix-server zabbix-6.4.10]# ./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
[root@zabbix-server zabbix-6.4.10]# echo $?
0
[root@zabbix-server zabbix-6.4.10]# make
[root@zabbix-server zabbix-6.4.10]# make install

4.6zabbix服务端配置

//修改服务端配置文件
//设置数据库信息
[root@zabbix-server ~]# ls /usr/local/etc/
zabbix_agentd.conf  zabbix_agentd.conf.d  zabbix_server.conf  zabbix_server.conf.d
[root@zabbix-server ~]# vim /usr/local/etc/zabbix_server.conf
DBPassword=Passw0rd@_~     //找到这一行取消注释,设置密码
DBName=zabbix
DBHost=localhost
DBUser=zabbix

//启动zabbix_server和zabbix_agentd
[root@zabbix-server ~]# ls /usr/local/etc/
zabbix_agentd.conf  zabbix_agentd.conf.d  zabbix_server.conf  zabbix_server.conf.d
[root@zabbix-server ~]# zabbix_server   //启动之后端口没有起来的话重启一下reboot
[root@zabbix-server ~]# zabbix_agentd
[root@zabbix-server ~]# ss -antl
State              Recv-Q             Send-Q                          Local Address:Port                            Peer Address:Port             Process             
LISTEN             0                  4096                                  0.0.0.0:10050                                0.0.0.0:*                                    
LISTEN             0                  4096                                  0.0.0.0:10051                                0.0.0.0:*                                    
LISTEN             0                  4096                                127.0.0.1:9000                                 0.0.0.0:*                                    
LISTEN             0                  128                                   0.0.0.0:22                                   0.0.0.0:*                                    
LISTEN             0                  70                                          *:33060                                      *:*                                    
LISTEN             0                  511                                         *:80                                         *:*                                    
LISTEN             0                  128                                      [::]:22                                      [::]:*                                    
LISTEN             0                  151                                         *:3306                                       *:*                                    

//假如没有监听到10051端口的话,以下是解决方案
[root@zabbix-server ~]# cat /tmp/zabbix_server.log
[root@zabbix-server ~]# vim /usr/local/etc/zabbix_server.conf
DBSocket=/tmp/mysql.sock     //取消这一行注释,添加套接字
[root@zabbix-server ~]#  
[root@zabbix-server ~]# ss -antl
State              Recv-Q             Send-Q                          Local Address:Port                            Peer Address:Port             Process             
LISTEN             0                  4096                                  0.0.0.0:10051                                0.0.0.0:*                                    
LISTEN             0                  4096                                  0.0.0.0:10050                                0.0.0.0:*                                    
LISTEN             0                  128                                   0.0.0.0:22                                   0.0.0.0:*                                    
LISTEN             0                  4096                                127.0.0.1:9000                                 0.0.0.0:*                                    
LISTEN             0                  4096                                     [::]:10051                                   [::]:*                                    
LISTEN             0                  4096                                     [::]:10050                                   [::]:*                                    
LISTEN             0                  128                                      [::]:22                                      [::]:*                                    
LISTEN             0                  511                                         *:80                                         *:*                                    
LISTEN             0                  151                                         *:3306                                       *:*                                    
LISTEN             0                  70                                          *:33060                                      *:*                                    

4.7zabbix服务端web界面安装与配置

4.7.1zabbix web界面安装前配置
[root@zabbix-server ~]# cd zabbix-6.4.10
[root@zabbix-server zabbix-6.4.10]# ls
aclocal.m4  build      conf          config.status  configure.ac  depcomp  install-sh  Makefile.am  misc     README  ui
AUTHORS     ChangeLog  config.guess  config.sub     COPYING       include  m4          Makefile.in  missing  sass
bin         compile    config.log    configure      database      INSTALL  Makefile    man          NEWS     src
[root@zabbix-server zabbix-6.4.10]# cd ui
[root@zabbix-server ui]# ls
api_jsonrpc.php     chart3.php     conf                 hostinventoriesoverview.php  include         jsrpc.php    robots.txt       trigger_prototypes.php
api_scim.php        chart4.php     data                 hostinventories.php          index_http.php  local        setup.php        triggers.php
app                 chart6.php     disc_prototypes.php  host_prototypes.php          index.php       locale       sysmap.php       vendor
assets              chart7.php     favicon.ico          httpconf.php                 index_sso.php   map.php      sysmaps.php      widgets
audio               chart.php      graphs.php           httpdetails.php              items.php       modules      templates.php    zabbix.php
browserwarning.php  composer.json  history.php          image.php                    js              report2.php  toptriggers.php
chart2.php          composer.lock  host_discovery.php   imgstore.php                 jsLoader.php    report4.php  tr_events.php
[root@zabbix-server ui]# cp -a * /usr/local/apache/htdocs/test
cp: -r not specified; omitting directory 'app'
cp: -r not specified; omitting directory 'assets'
cp: -r not specified; omitting directory 'audio'
cp: -r not specified; omitting directory 'conf'
cp: -r not specified; omitting directory 'data'
cp: -r not specified; omitting directory 'include'
cp: overwrite '/usr/local/apache/htdocs/index.php'? y
cp: -r not specified; omitting directory 'js'
cp: -r not specified; omitting directory 'local'
cp: -r not specified; omitting directory 'locale'
cp: -r not specified; omitting directory 'modules'
cp: -r not specified; omitting directory 'vendor'
cp: -r not specified; omitting directory 'widgets'
[root@zabbix-server ui]# ls /usr/local/apache/htdocs/
api_jsonrpc.php     chart6.php           favicon.ico                  host_prototypes.php  index_http.php  map.php      sysmaps.php             zabbix.php
api_scim.php        chart7.php           graphs.php                   httpconf.php         index.php       report2.php  templates.php
browserwarning.php  chart.php            history.php                  httpdetails.php      index_sso.php   report4.php  toptriggers.php
chart2.php          composer.json        host_discovery.php           image.php            items.php       robots.txt   tr_events.php
chart3.php          composer.lock        hostinventoriesoverview.php  imgstore.php         jsLoader.php    setup.php    trigger_prototypes.php
chart4.php          disc_prototypes.php  hostinventories.php          index.html           jsrpc.php       sysmap.php   triggers.php
[root@zabbix-server ui]# chown -R apache.apache /usr/local/apache/
[root@zabbix-server ui]# chmod 777 /usr/local/apache/htdocs/test/conf
[root@zabbix-server ui]# systemctl restart httpd
[root@zabbix-server ui]# systemctl restart httpd
[root@zabbix-server ui]# ss -antl
State              Recv-Q             Send-Q                          Local Address:Port                            Peer Address:Port             Process             
LISTEN             0                  4096                                  0.0.0.0:10050                                0.0.0.0:*                                    
LISTEN             0                  4096                                  0.0.0.0:10051                                0.0.0.0:*                                    
LISTEN             0                  4096                                127.0.0.1:9000                                 0.0.0.0:*                                    
LISTEN             0                  128                                   0.0.0.0:22                                   0.0.0.0:*                                    
LISTEN             0                  70                                          *:33060                                      *:*                                    
LISTEN             0                  511                                         *:80                                         *:*                                    
LISTEN             0                  128                                      [::]:22                                      [::]:*                                    
LISTEN             0                  151                                         *:3306                                       *:*                                    

在这里插入图片描述
在这里插入图片描述

//解决方案
[root@zabbix-server ~]# sed -ri 's/(post_max_size =).*/\1 16M/g' /etc/php.ini
[root@zabbix-server ~]# sed -ri 's/(max_execution_time =).*/\1 300/g' /etc/php.ini
[root@zabbix-server ~]# sed -ri 's/(max_input_time =).*/\1 300/g' /etc/php.ini
[root@zabbix-server ~]# sed -i '/;date.timezone/a date.timezone = Asia/Shanghai' /etc/php.ini
[root@zabbix-server ~]# service php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm  done

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

4.7.2用域名访问的话
  • 修改/etc/hosts文件,添加域名与IP的映射
  • 在浏览器上访问域名,本文设置的域名为zabbix.wangqing.com,你需要修改成你自己的域名
  • 恢复zabbix/conf目录的权限为755
➜  ~ sudo vim /etc/hosts
Password:
➜  ~ cat /etc/hosts
127.0.0.1   localhost
255.255.255.255 broadcasthost
::1             localhost
172.16.12.128   zabbix.wangqing.com

恢复zabbix/conf目录的权限为755:

[root@localhost ~]# chmod 755 /usr/local/apache/htdocs/zabbix/conf
[root@localhost ~]# ll -d /usr/local/apache/htdocs/zabbix/conf
drwxr-xr-x 2 apache apache 104 Aug 17 13:05 /usr/local/apache/htdocs/zabbix/conf
4.7.3登录zabbix

zabbix默认登录用户名和密码:

用户名密码
Adminzabbix
  • 48
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值