监控服务zabbix部署
监控服务zabbix部署
zabbix介绍
- zabbix是由Alexei Vladishev 开发的一种网络监视、管理系统,基于Server-Client架构。可用于监视各种网络服务、服务器和网络机器等状态。
- 使用各种Database-end 如 MySQL,PostgreSQL,SQlite,Oracle 或IBMDB2储存资料。Server端基于C语言、Web管理端frontend则是基于PHP所制作的。
- zabbix可以使用多种方式监视。可以只使用Simple Check不需要安装
Client端,亦可基于SMTP或HTTP… 各种协议定制监视。 - 在客户端如UNIX,Windows 中安装zabbix Agent之后,可监视CPULoad、网络使用状况、硬盘容量等各种状态。而就算没有安装Agent 在监视对象中,zabbix 也可以经由SNMP、TCP、ICMP、利用IPMI、SSH、telnet 对目标进行监视。
- zabbbix自带的Item足够满足普通小公司的监控需求,对于大公司也可以设定自定义的Item,自动生成报表,也有API可以和其他系统集成。
- zabbix由2部分构成,zabbix server与可选组件zabbix agent。
zabbix特点
zabbix的主要特点:
安装与配置简单,学习成本低
支持多语言(包括中文)
免费开源
自动发现服务器与网络设备
分布式监视以及WEB集中管理功能
可以无agent监视
用户安全认证和柔软的授权方式
通过WEB界面设置或查看监视结果
email等通知功能
zabbix主要功能:
CPU负荷
内存使用
磁盘使用
网络状况
端口监视
日志监视
为何是zabbix不是其他监控
zabbix就是可以满足理想化的监控系统需求
支持自定义监控脚本,提供需要输出的值即可
zabbix存储的数据库表结构稍有复杂但是逻辑清晰
zabbix存在模板的概念,可以方便的将一组监控项进行部署
zabbix每一个item也就是监控项,都可以看到历史记录,且web界面友好
zabbix有强大的Trigger(触发器)定义规则,可以定义复杂的报警逻辑
zabbix提供了ack报警确认机制
zabbix支持邮件,短信,微信等告警
zabbix在触发告警后,可以远程执行系统命令
zabbix有原生的PHP绘图模块
部署zabbix时为什么服务端也要安装部署zabbix
因为服务端在监控其他主机的时候,如果自己出了啥子问题是无法进行自我反应的,所以在监控其他主机的时候,也要进行自我监控,及时反应问题。
zabbix程序组件
zabbix_server,服务端守护进程
zabbix_agentd,agent守护进程
zabbix_proxy,代理服务器
zabbix_database,存储系统,mysql,pgsql
zabbix_web,web GUI图形化界面
zabbix_ get,命令行工具,测试向agent发起数据采集请求
zabbix_sender,命令行工具,测试向server发送数据
zabbix_ java_ gateway,java网关
zabbix配置文件
zabbix配置文件有两种:
服务器端配置文件(/usr/local/etc/zabbix_server.conf)
客户端配置文件(/usr/local/etc/zabbix_agentd.conf)
zabbix代理配置文件(/usr/local/etc/zabbix_proxy.conf)
部署zabbix
环境 | IP | 要安装的服务 |
---|---|---|
服务器 | 192.168.222.250 | lamp架构 zabbix server zabbix agent |
客户端 | 192.168.222.251 | zabbix agent |
因为zabbix是用php语言开发的,所以必须先部署lamp架构,使其能够支持运行php网页
需要提前搭建好lamp架构,可以查看 下面的搭建方法
mysql官网
此处需要使用的mysql8mysql源码包
php官网
此处需要使用的php源码包
zabbix官网
zabbix源码包
搭建lamp
安装httpd
yum源的配置:
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
CentOS-Base.repo
[root@localhost yum.repos.d]# rm -rf *
[root@localhost yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
//在阿里云网站里面复制的仓库链接
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2495 100 2495 0 0 7920 0 --:--:-- --:--:-- --:--:-- 7920
[root@localhost yum.repos.d]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
[root@localhost yum.repos.d]# ls
CentOS-Base.repo
[root@localhost yum.repos.d]# yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm
//安装epel源,也是在阿里云网站里面复制链接
Failed to set locale, defaulting to C.UTF-8
CentOS-8.5.2111 - Base - mirrors.aliyun.com 12 kB/s | 3.9 kB 00:00
CentOS-8.5.2111 - Extras - mirrors.aliyun.com 38 kB/s | 1.5 kB 00:00
[root@localhost yum.repos.d]# sed -i 's|^#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*
[root@localhost yum.repos.d]# sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*
[root@localhost yum.repos.d]# ls
CentOS-Base.repo epel-modular.repo epel-testing-modular.repo epel-testing.repo epel.repo
[root@localhost yum.repos.d]# dnf makecache //建立缓存
[root@localhost yum.repos.d]# dnf groups mark install 'Development Tools'
//安装开发工具包
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 0:00:51 ago on Fri Sep 2 08:49:49 2022.
Module yaml error: Unexpected key in data: static_context [line 9 col 3]
Module yaml error: Unexpected key in data: static_context [line 9 col 3]
Module yaml error: Unexpected key in data: static_context [line 9 col 3]
Module yaml error: Unexpected key in data: static_context [line 9 col 3]
Module yaml error: Unexpected key in data: static_context [line 9 col 3]
Module yaml error: Unexpected key in data: static_context [line 9 col 3]
Module yaml error: Unexpected key in data: static_context [line 9 col 3]
Module yaml error: Unexpected key in data: static_context [line 9 col 3]
Dependencies resolved.
=======================================================================================================
Package Architecture Version Repository Size
=======================================================================================================
Installing Groups:
Development Tools
Transaction Summary
=======================================================================================================
Is this ok [y/N]: y
Complete!
[root@localhost yum.repos.d]# cd
[root@localhost ~]# useradd -r -M -s /sbin/nologin apache
//创建用户的时候它会创建一个和用户名相同名字的组
//创建apache服务的用户和组
[root@localhost ~]# dnf -y install openssl-devel pcre-devel expat-devel libtool gcc gcc-c++ wget vim make
//安装依赖包
[root@localhost ~]# wget https://downloads.apache.org/apr/apr-1.7.0.tar.gz https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz https://downloads.apache.org/httpd/httpd-2.4.54.tar.gz
//在官网里面下载
[root@localhost ~]# ls
anaconda-ks.cfg apr-1.7.0.tar.gz apr-util-1.6.1.tar.gz httpd-2.4.54.tar.gz
[root@localhost ~]# tar xf apr-1.7.0.tar.gz //解压
[root@localhost ~]# tar xf apr-util-1.6.1.tar.gz
[root@localhost ~]# tar xf httpd-2.4.54.tar.gz
[root@localhost ~]# ls
anaconda-ks.cfg apr-1.7.0.tar.gz apr-util-1.6.1.tar.gz httpd-2.4.54.tar.gz
apr-1.7.0 apr-util-1.6.1 httpd-2.4.54
[root@localhost ~]# cd apr-1.7.0/
[root@localhost apr-1.7.0]# ls
CHANGES README.cmake atomic docs libapr.dsp passwd threadproc
CMakeLists.txt apr-config.in build dso libapr.mak poll time
LICENSE apr.dep build-outputs.mk emacs-mode libapr.rc random tools
Makefile.in apr.dsp build.conf encoding locks shmem user
Makefile.win apr.dsw buildconf file_io memory strings
NOTICE apr.mak config.layout helpers misc support
NWGNUmakefile apr.pc.in configure include mmap tables
README apr.spec configure.in libapr.dep network_io test
[root@localhost apr-1.7.0]# vim configure
# $RM "$cfgfile" //删除或者注释掉这个
[root@localhost apr-1.7.0]# ./configure --prefix=/usr/local/apr
...
config.status: creating test/internal/Makefile
config.status: creating include/arch/unix/apr_private.h
config.status: executing libtool commands
config.status: executing default commands
[root@localhost apr-1.7.0]# make
[root@localhost apr-1.7.0]# make install
[root@localhost apr-1.7.0]# cd ../apr-util-1.6.1/
[root@localhost apr-util-1.6.1]# ls
CHANGES README.FREETDS apu-config.in configure.in include redis
CMakeLists.txt README.cmake buckets crypto ldap renames_pending
LICENSE apr-util.pc.in build dbd libaprutil.dep strmatch
Makefile.in apr-util.spec build-outputs.mk dbm libaprutil.dsp test
Makefile.win aprutil.dep build.conf docs libaprutil.mak uri
NOTICE aprutil.dsp buildconf encoding libaprutil.rc xlate
NWGNUmakefile aprutil.dsw config.layout export_vars.sh.in memcache xml
README aprutil.mak configure hooks misc
[root@localhost apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@localhost apr-util-1.6.1]# make
[root@localhost apr-util-1.6.1]# make install
[root@localhost apr-util-1.6.1]# cd
[root@localhost ~]# ls /usr/local/
apr apr-util bin etc games include lib lib64 libexec sbin share src
[root@localhost ~]# cd httpd-2.4.54/
[root@localhost httpd-2.4.54]# ls
ABOUT_APACHE InstallBin.dsp README.CHANGES build httpd.dep modules
Apache-apr2.dsw LAYOUT README.cmake buildconf httpd.dsp os
Apache.dsw LICENSE README.platforms changes-entries httpd.mak server
BuildAll.dsp Makefile.in ROADMAP config.layout httpd.spec srclib
BuildBin.dsp Makefile.win VERSIONING configure include support
CHANGES NOTICE acinclude.m4 configure.in libhttpd.dep test
CMakeLists.txt NWGNUmakefile ap.d docs libhttpd.dsp
INSTALL README apache_probes.d emacs-style libhttpd.mak
[root@localhost httpd-2.4.54]# ./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
...
Server Version: 2.4.54
Install prefix: /usr/local/apache
C compiler: gcc
CFLAGS: -g -O2 -pthread
CPPFLAGS: -DLINUX -D_REENTRANT -D_GNU_SOURCE
LDFLAGS:
LIBS:
C preprocessor: gcc -E
[root@localhost httpd-2.4.54]# make
[root@localhost httpd-2.4.54]# make install
[root@localhost httpd-2.4.54]# cd
[root@localhost ~]# ls
anaconda-ks.cfg apr-1.7.0.tar.gz apr-util-1.6.1.tar.gz httpd-2.4.54.tar.gz
apr-1.7.0 apr-util-1.6.1 httpd-2.4.54
[root@localhost ~]# echo 'export PATH=/usr/local/apache/bin:$PATH' > /etc/profile.d/httpd.sh
//配置环境变量
[root@localhost ~]# cat /etc/profile.d/httpd.sh
export PATH=/usr/local/apache/bin:$PATH
[root@localhost ~]# ls /usr/local/
apache apr apr-util bin etc games include lib lib64 libexec sbin share src
[root@localhost ~]# source /etc/profile.d/httpd.sh
[root@localhost ~]# which httpd
/usr/local/apache/bin/httpd
//查看路径
[root@localhost ~]# ls /usr/local/apache/
bin build cgi-bin conf error htdocs icons include logs man manual modules
[root@localhost ~]# ln -s /usr/local/apache/include /usr/include/apache
//做一个头文件软链接
[root@localhost ~]# ll -d /usr/include/apache
lrwxrwxrwx. 1 root root 25 Sep 2 09:49 /usr/include/apache -> /usr/local/apache/include
[root@localhost ~]# vim /etc/man_db.conf
MANDATORY_MANPATH /usr/man
MANDATORY_MANPATH /usr/share/man
MANDATORY_MANPATH /usr/local/share/man
MANDATORY_MANPATH /usr/local/apache/man //添加这一行
将其添加到systemd服务里面:
root@localhost ~]# cd /usr/lib/systemd/system
[root@localhost system]# cp sshd.service httpd.service
[root@localhost system]# vim httpd.service
[root@localhost system]# cat httpd.service
[Unit]
Description=httpd server daemon
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/apache/bin/apachectl //开启的绝对路径
ExecStop=/usr/local/apache/bin/apachectl stop //关闭的绝对路径
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target
[root@localhost system]# cd
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl enable --now httpd.service
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
//设置开机自启
[root@localhost ~]# ss -antl //查看80端口
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 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
[root@localhost ~]# systemctl status httpd.service //查看状态
● httpd.service - httpd server daemon
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2022-09-02 09:54:46 CST; 39s ago
Docs: man:httpd(5)
Process: 184914 ExecStart=/usr/local/apache/bin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 184917 (httpd)
Tasks: 6 (limit: 12221)
Memory: 5.7M
CGroup: /system.slice/httpd.service
├─184917 /usr/local/apache/bin/httpd -k start
├─184918 /usr/local/apache/bin/httpd -k start
├─184919 /usr/local/apache/bin/httpd -k start
├─184920 /usr/local/apache/bin/httpd -k start
├─184921 /usr/local/apache/bin/httpd -k start
└─184922 /usr/local/apache/bin/httpd -k start
Sep 02 09:54:46 localhost systemd[1]: Starting httpd server daemon...
Sep 02 09:54:46 localhost apachectl[184914]: AH00558: httpd: Could not reliably determine the server's>
Sep 02 09:54:46 localhost systemd[1]: Started httpd server daemon.
安装mysql
[root@localhost ~]# dnf -y install ncurses-devel openssl-devel openssl cmake mariadb-devel ncurses-compat-libs
//安装依赖包
[root@localhost ~]# useradd -r -M -s /sbin/nologin mysql
//创建用户和组
[root@localhost ~]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.28-linux-glibc2.12-x86_64.tar.xz
//下载二进制格式的mysql软件包
[root@localhost ~]# ls
anaconda-ks.cfg apr-1.7.0.tar.gz apr-util-1.6.1.tar.gz httpd-2.4.54.tar.gz
apr-1.7.0 apr-util-1.6.1 httpd-2.4.54 mysql-8.0.28-linux-glibc2.12-x86_64.tar.xz
[root@localhost ~]# tar xf mysql-8.0.28-linux-glibc2.12-x86_64.tar.xz -C /usr/local/ //解压
[root@localhost ~]# cd /usr/local/
[root@localhost local]# ls
apache apr-util etc include lib64 mysql-8.0.28-linux-glibc2.12-x86_64 share
apr bin games lib libexec sbin src
[root@localhost local]# mv mysql-8.0.28-linux-glibc2.12-x86_64 mysql
//也可以做软链接ln -sv mysql-8.0.28-linux-glibc2.12-x86_64 mysql
[root@localhost local]# ls
apache apr apr-util bin etc games include lib lib64 libexec mysql sbin share src
[root@localhost local]# chown -R mysql.mysql mysql
//修改目录/usr/local/mysql的属主属组
[root@localhost local]# ll
total 0
drwxr-xr-x. 14 root root 164 Sep 2 09:47 apache
drwxr-xr-x. 6 root root 58 Sep 2 09:37 apr
drwxr-xr-x. 5 root root 43 Sep 2 09:40 apr-util
drwxr-xr-x. 2 root root 6 May 19 2020 bin
drwxr-xr-x. 2 root root 6 May 19 2020 etc
drwxr-xr-x. 2 root root 6 May 19 2020 games
drwxr-xr-x. 2 root root 6 May 19 2020 include
drwxr-xr-x. 2 root root 6 May 19 2020 lib
drwxr-xr-x. 3 root root 17 Jul 19 16:13 lib64
drwxr-xr-x. 2 root root 6 May 19 2020 libexec
drwxr-xr-x. 9 mysql mysql 129 Sep 2 10:09 mysql
drwxr-xr-x. 2 root root 6 May 19 2020 sbin
drwxr-xr-x. 5 root root 49 Jul 19 16:13 share
drwxr-xr-x. 2 root root 6 May 19 2020 src
[root@localhost local]# ln -s /usr/local/mysql/include /usr/include/mysql
[root@localhost local]# echo '/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf
[root@localhost local]# vim /etc/man_db.conf
MANDATORY_MANPATH /usr/man
MANDATORY_MANPATH /usr/share/man
MANDATORY_MANPATH /usr/local/share/man
MANDATORY_MANPATH /usr/local/apache/man
MANDATORY_MANPATH /usr/local/mysql/man //添加这一行
root@localhost local]# cd
[root@localhost ~]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
//配置环境变量
[root@localhost ~]# source /etc/profile.d/mysql.sh //使其生效
[root@localhost ~]# which mysql
/usr/local/mysql/bin/mysql
//查看路径
[root@localhost ~]# mkdir -p /opt/data
[root@localhost ~]# chown -R mysql.mysql /opt/data/
//建立数据存放目录
[root@localhost ~]# mysqld --initialize --user mysql --datadir /opt/data
//初始化数据库
2022-09-02T02:16:16.863454Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.28) initializing of server in progress as process 226543
2022-09-02T02:16:16.885734Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-09-02T02:16:17.359489Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-09-02T02:16:19.314671Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: &PDqtrcwe9w2 //临时密码
[root@localhost ~]# echo "&PDqtrcwe9w2" > password
[root@localhost ~]# cat password
&PDqtrcwe9w2
//将临时密码保存到这个文件里面
[root@localhost ~]# rpm -qa |grep mariadb //查找mariadb的数据库
mariadb-connector-c-3.1.11-2.el8_3.x86_64
mariadb-connector-c-config-3.1.11-2.el8_3.noarch
mariadb-devel-10.3.28-1.module_el8.3.0+757+d382997d.x86_64
mariadb-connector-c-devel-3.1.11-2.el8_3.x86_64
[root@localhost ~]# dnf -y remove mariadb* //要卸载掉mariadb数据库不然到时候和mysql数据库发生冲突
[root@localhost ~]# rpm -qa |grep mariadb //查看是否有存留
[root@localhost ~]# vim /etc/my.cnf
[root@localhost ~]# 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
[root@localhost ~]# cd /usr/local/mysql/
[root@localhost mysql]# ls
LICENSE README bin docs include lib man share support-files
[root@localhost mysql]# cd support-files/
[root@localhost support-files]# ls
mysql-log-rotate mysql.server mysqld_multi.server
[root@localhost support-files]# file mysql.server
mysql.server: POSIX shell script, ASCII text executable
//是一个脚本文件
[root@localhost support-files]# cp mysql.server /etc/init.d/mysqld
[root@localhost support-files]# vim /etc/init.d/mysqld
basedir=/usr/local/mysql //数据库存放位置
datadir=/opt/data //数据存放位置
[root@localhost support-files]# chmod +x /etc/init.d/mysqld
//赋予执行权限
[root@localhost support-files]# cd
[root@localhost ~]# service mysqld start //启动服务
Starting MySQL.Logging to '/opt/data/localhost.err'.
SUCCESS!
[root@localhost ~]# ss -antl //查看端口(2个)
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 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 70 *:33060 *:*
LISTEN 0 128 *:3306 *:*
[root@localhost ~]# chkconfig --add mysqld //设置开机自启
[root@localhost ~]# chkconfig --list
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
If you want to list systemd services use 'systemctl list-unit-files'.
To see services enabled on particular target use
'systemctl list-dependencies [target]'.
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
//在2,3,4,5下面开机自启了
[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# systemctl disable firewalld.service
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]# vim /etc/selinux/config
SELINUX=disabled
[root@localhost ~]# setenforce 0
//关闭防火墙
将其加入systemd服务
root@localhost ~]# cd /usr/lib/systemd/system
[root@localhost system]# cp sshd.service mysqld.service
[root@localhost system]# vim mysqld.service
[root@localhost system]# vim mysqld.service
[root@localhost system]# cat mysqld.service
[Unit]
Description=mysqld server daemon
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/mysql/support-files/mysql.server start
ExecStop=/usr/local/mysql/support-files/mysql.server stop
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target
[root@localhost ~]# systemctl daemon-reload //重新加载
[root@localhost ~]# systemctl enable --now mysqld.service //设置开机自启
Synchronizing state of mysqld.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable mysqld
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.
[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 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 70 *:33060 *:*
LISTEN 0 128 *:3306 *:*
[root@localhost ~]# cat password
&PDqtrcwe9w2
[root@localhost ~]# mysql -uroot -p'&PDqtrcwe9w2' //使用临时密码登录数据库
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.28
Copyright (c) 2000, 2022, 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 'lnh123'; //修改密码(mysql5.8以后没有password)
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
[root@localhost ~]# mysql -uroot -p'lnh123'
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.28 MySQL Community Server - GPL
Copyright (c) 2000, 2022, 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
[root@localhost ~]# wget https://www.php.net/distributions/php-8.0.22.tar.gz
//在官方网站下载
[root@localhost ~]# ls
anaconda-ks.cfg apr-util-1.6.1 httpd-2.4.54.tar.gz php-8.0.22.tar.gz
apr-1.7.0 apr-util-1.6.1.tar.gz mysql-8.0.28-linux-glibc2.12-x86_64.tar.xz
apr-1.7.0.tar.gz httpd-2.4.54 password
[root@localhost ~]# sha256sum php-8.0.22.tar.gz
56fce7529a9798fd0895bca3539d2a65b9cac5d23ffbdf6338419c62ed083519 php-8.0.22.tar.gz
//查看是否是要下载的包
[root@localhost ~]# dnf list |grep php|grep mysql
//查看本地是否有安装包
Failed to set locale, defaulting to C.UTF-8
Module yaml error: Unexpected key in data: static_context [line 9 col 3]
Module yaml error: Unexpected key in data: static_context [line 9 col 3]
Module yaml error: Unexpected key in data: static_context [line 9 col 3]
Module yaml error: Unexpected key in data: static_context [line 9 col 3]
Module yaml error: Unexpected key in data: static_context [line 9 col 3]
Module yaml error: Unexpected key in data: static_context [line 9 col 3]
Module yaml error: Unexpected key in data: static_context [line 9 col 3]
Module yaml error: Unexpected key in data: static_context [line 9 col 3]
php-mysqlnd.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream
[root@localhost ~]# dnf -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 libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel mhash mhash-devel php-mysqlnd sqlite* libzip*
//安装依赖包
[root@localhost ~]# ls
anaconda-ks.cfg apr-util-1.6.1 httpd-2.4.54.tar.gz php-8.0.22.tar.gz
apr-1.7.0 apr-util-1.6.1.tar.gz mysql-8.0.28-linux-glibc2.12-x86_64.tar.xz
apr-1.7.0.tar.gz httpd-2.4.54 password
[root@localhost ~]# vim /etc/hosts //可以提前做一个映射,防止访问不了github
[root@localhost ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
20.205.243.166 github.com //添加
[root@localhost ~]# tar xf php-8.0.22.tar.gz //解压
[root@localhost ~]# cd php-8.0.22/
[root@localhost php-8.0.22]# wget https://github.com/kkos/oniguruma/archive/v6.9.4.tar.gz -O ./oniguruma-6.9.4.tar.gz
[root@localhost php-8.0.22]# tar zxf ./oniguruma-6.9.4.tar.gz
[root@localhost php-8.0.22]# cd oniguruma-6.9.4
[root@localhost oniguruma-6.9.4]# ./autogen.sh
[root@localhost oniguruma-6.9.4]# ./configure --prefix=/usr
[root@localhost oniguruma-6.9.4]# make && make install
[root@localhost oniguruma-6.9.4]# cd ..
[root@localhost php-8.0.22]# ./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
...
+--------------------------------------------------------------------+
| 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.0.22]# make
[root@localhost php-8.0.22]# make install
//编译测试安装php
[root@localhost php-8.0.22]# echo 'export PATH=/usr/local/php8/bin:$PATH' > /etc/profile.d/php8.sh
//配置环境变量
[root@localhost php-8.0.22]# source /etc/profile.d/php8.sh
[root@localhost php-8.0.22]# which php
/usr/local/php8/bin/php
//查找php
[root@localhost php-8.0.22]# php -v //查看版本号
PHP 8.0.22 (cli) (built: Sep 2 2022 15:34:33) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.22, Copyright (c) Zend Technologies
[root@localhost php-8.0.22]# ls
CODING_STANDARDS.md README.md buildconf include php.ini-production
CONTRIBUTING.md TSRM buildconf.bat libs run-tests.php
EXTENSIONS UPGRADING config.log libtool sapi
LICENSE UPGRADING.INTERNALS config.nice main scripts
Makefile Zend config.status modules tests
Makefile.fragments appveyor configure oniguruma-6.9.4 travis
Makefile.objects azure configure.ac oniguruma-6.9.4.tar.gz win32
NEWS azure-pipelines.yml docs pear
README.REDIST.BINS build ext php.ini-development
[root@localhost php-8.0.22]# cp php.ini-production /etc/php.ini
cp: overwrite '/etc/php.ini'? y
//配置生成环境
[root@localhost php-8.0.22]# ls
CODING_STANDARDS.md README.md buildconf include php.ini-production
CONTRIBUTING.md TSRM buildconf.bat libs run-tests.php
EXTENSIONS UPGRADING config.log libtool sapi
LICENSE UPGRADING.INTERNALS config.nice main scripts
Makefile Zend config.status modules tests
Makefile.fragments appveyor configure oniguruma-6.9.4 travis
Makefile.objects azure configure.ac oniguruma-6.9.4.tar.gz win32
NEWS azure-pipelines.yml docs pear
README.REDIST.BINS build ext php.ini-development
[root@localhost php-8.0.22]# cd sapi/
[root@localhost sapi]# ls
apache2handler cgi cli embed fpm fuzzer litespeed phpdbg
[root@localhost sapi]# cd fpm/
[root@localhost fpm]# ls
CREDITS fpm php-fpm.8 php-fpm.service tests
LICENSE init.d.php-fpm php-fpm.8.in php-fpm.service.in www.conf
Makefile.frag init.d.php-fpm.in php-fpm.conf status.html www.conf.in
config.m4 php-fpm php-fpm.conf.in status.html.in
[root@localhost fpm]# file init.d.php-fpm
init.d.php-fpm: POSIX shell script, ASCII text executable
//是一个脚本文件
[root@localhost fpm]# cp init.d.php-fpm /etc/init.d/php-fpm
//配置php-fpm
[root@localhost fpm]# chmod +x /etc/init.d/php-fpm
//赋予执行权限
[root@localhost fpm]# cd
[root@localhost ~]# service php-fpm status
php-fpm is stopped
//此时还没有正式启动
[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]# ls //查看
pear.conf php-fpm.conf.default php-fpm.d
[root@localhost etc]# cp php-fpm.conf.default php-fpm.conf
[root@localhost etc]# ls //查看复制后的文件
pear.conf php-fpm.conf php-fpm.conf.default php-fpm.d
[root@localhost etc]# cd php-fpm.d/
[root@localhost php-fpm.d]# ls
www.conf.default
[root@localhost php-fpm.d]# cp www.conf.default www.conf
[root@localhost php-fpm.d]# ls //查看复制后的文件
www.conf www.conf.default
[root@localhost php-fpm.d]# service php-fpm start //开启服务
Starting php-fpm done
[root@localhost php-fpm.d]# ss -antl //查看端口9000
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 127.0.0.1:9000 0.0.0.0:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 70 *:33060 *:*
LISTEN 0 128 *:3306 *:*
[root@localhost php-fpm.d]# cd
[root@localhost ~]# chkconfig --add php-fpm //设置开机自启
[root@localhost ~]# chkconfig --list
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
If you want to list systemd services use 'systemctl list-unit-files'.
To see services enabled on particular target use
'systemctl list-dependencies [target]'.
php-fpm 0:off 1:off 2:on 3:on 4:on 5:on 6:off
//可以看见2,3,4,5,是开机自启
[root@localhost ~]# ps -ef|grep php //查看进程
root 524510 1 0 15:45 ? 00:00:00 php-fpm: master process (/usr/local/php8/etc/php-fpm.conf)
nobody 524511 524510 0 15:45 ? 00:00:00 php-fpm: pool www
nobody 524512 524510 0 15:45 ? 00:00:00 php-fpm: pool www
root 532246 283589 0 15:48 pts/4 00:00:00 grep --color=auto php
配置apache
启用代理模块
在apache httpd 2.4以后已经专门有一个模块针对FastCGI的实现,此模块为mod_proxy_fcgi.so,它其实是作为mod_proxy.so模块的扩展,因此,这两个模块都要加载,编辑httpd.conf文件,取消以下两行内容的注释:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
[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 128 127.0.0.1:9000 0.0.0.0:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 70 *:33060 *:*
LISTEN 0 128 *:3306 *:*
[root@localhost ~]# cd /usr/local/apache/conf/
[root@localhost conf]# ls
extra httpd.conf magic mime.types original
[root@localhost conf]# vim httpd.conf
LoadModule proxy_module modules/mod_proxy.so //取消注释
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so //取消注释
配置虚拟主机
[root@localhost conf]# ls /usr/local/apache/
bin build cgi-bin conf error htdocs icons include logs man manual modules
[root@localhost conf]# ls /usr/local/apache/htdocs/
index.html
//放置我们访问网页的位置
[root@localhost conf]# mkdir -p /usr/local/apache/htdocs/runtime
//创建虚拟主机的存放位置
[root@localhost conf]# vim /usr/local/apache/htdocs/runtime/index.php
//在刚刚创建的这个目录里面写一个网站
[root@localhost conf]# cat /usr/local/apache/htdocs/runtime/index.php
<?php
phpinfo();
?>
//创建php测试页面
[root@localhost conf]# ll /usr/local/apache/htdocs/
total 4
-rw-r--r--. 1 504 games 45 Jun 12 2007 index.html
drwxr-xr-x. 2 root root 23 Sep 2 16:45 runtime
//可以看见有执行权限,任何人都可以进入
[root@localhost conf]# ll /usr/local/apache/htdocs/runtime/
total 4
-rw-r--r--. 1 root root 23 Sep 2 16:45 index.php
//可读
[root@localhost conf]# ls
extra httpd.conf magic mime.types original
[root@localhost conf]# cd extra/
[root@localhost extra]# ls
httpd-autoindex.conf httpd-info.conf httpd-mpm.conf httpd-userdir.conf
httpd-dav.conf httpd-languages.conf httpd-multilang-errordoc.conf httpd-vhosts.conf
httpd-default.conf httpd-manual.conf httpd-ssl.conf proxy-html.conf
[root@localhost extra]# vim httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "/usr/local/apache/htdocs/runtime" //主机,网站存放位置
ServerName runtime.example.com //域名
ErrorLog "logs/runtime.example.com-error_log" //错误日志
CustomLog "logs/runtime.example.com-access_log" common //日志
ProxyRequests Off //关闭正向代理
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/runtime/$1 //打开反向代理
<Directory "/usr/local/apache/htdocs/runtime"> //存放网站的位置
Options none
AllowOverride none
Require all granted //允许所有人访问
</Directory>
</VirtualHost>
[root@localhost extra]# ls
httpd-autoindex.conf httpd-info.conf httpd-mpm.conf httpd-userdir.conf
httpd-dav.conf httpd-languages.conf httpd-multilang-errordoc.conf httpd-vhosts.conf
httpd-default.conf httpd-manual.conf httpd-ssl.conf proxy-html.conf
[root@localhost extra]# cd ..
[root@localhost conf]# ls
extra httpd.conf magic mime.types original
[root@localhost conf]# vim httpd.conf
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz //在这两行下面添加
AddType application/x-httpd-php .php //添加
AddType application/x-httpd-php-source .phps //添加
Include conf/extra/httpd-vhosts.conf //取消注释,因为刚刚写了虚拟主机的文件
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
//在index.html前面添加index.php,表示我默认去访问index.php页面
[root@localhost conf]# systemctl restart httpd.service //重启服务
[root@localhost conf]# systemctl status httpd.service //查看状态
● httpd.service - httpd server daemon
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2022-09-02 16:57:31 CST; 9s ago
Docs: man:httpd(5)
Process: 780286 ExecStop=/usr/local/apache/bin/apachectl stop (code=exited, status=0/SUCCESS)
Process: 780322 ExecStart=/usr/local/apache/bin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 780327 (httpd)
Tasks: 6 (limit: 12221)
Memory: 6.0M
CGroup: /system.slice/httpd.service
├─780327 /usr/local/apache/bin/httpd -k start
├─780328 /usr/local/apache/bin/httpd -k start
├─780329 /usr/local/apache/bin/httpd -k start
├─780330 /usr/local/apache/bin/httpd -k start
├─780331 /usr/local/apache/bin/httpd -k start
└─780332 /usr/local/apache/bin/httpd -k start
Sep 02 16:57:31 localhost systemd[1]: Starting httpd server daemon...
Sep 02 16:57:31 localhost apachectl[780322]: AH00558: httpd: Could not reliably determine the server's fu>
Sep 02 16:57:31 localhost systemd[1]: Started httpd server daemon.
访问:
zabbix服务端安装
[root@localhost conf]# cd
[root@localhost ~]# cd /usr/src/
[root@localhost src]# wget https://cdn.zabbix.com/zabbix/sources/stable/6.2/zabbix-6.2.2.tar.gz
//下载源码包
--2022-09-02 17:26:59-- https://cdn.zabbix.com/zabbix/sources/stable/6.2/zabbix-6.2.2.tar.gz
Resolving cdn.zabbix.com (cdn.zabbix.com)... 104.26.7.148, 104.26.6.148, 172.67.69.4, ...
Connecting to cdn.zabbix.com (cdn.zabbix.com)|104.26.7.148|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 34995538 (33M) [application/octet-stream]
Saving to: 'zabbix-6.2.2.tar.gz'
zabbix-6.2.2.tar.gz 100%[======================================>] 33.37M 6.98MB/s in 4.8s
2022-09-02 17:27:06 (6.98 MB/s) - 'zabbix-6.2.2.tar.gz' saved [34995538/34995538]
[root@localhost src]# ls
debug kernels zabbix-6.2.2.tar.gz
[root@localhost src]# tar xf zabbix-6.2.2.tar.gz //解压
[root@localhost src]# cd zabbix-6.2.2/
[root@localhost zabbix-6.2.2]# dnf -y install net-snmp-devel libevent-devel //安装依赖包
....
tpm2-tss-2.3.2-4.el8.x86_64
unzip-6.0-45.el8_4.x86_64
zip-3.0-23.el8.x86_64
Complete!
[root@localhost zabbix-6.2.2]# useradd -r -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix
//创建zabbix系统用户
[root@localhost zabbix-6.2.2]# mkdir -m u=rwx,g=rwx,o= -p /usr/lib/zabbix
//创建zabbix用户的家目录
[root@localhost zabbix-6.2.2]# chown -R zabbix.zabbix /usr/lib/zabbix/
//使其属主属组都是zabbix
[root@localhost zabbix-6.2.2]# mysql -uroot -p'lnh123'
//登录数据库,配置数据库
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.28 MySQL Community Server - GPL
Copyright (c) 2000, 2022, 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.05 sec)
mysql> create user 'zabbix'@'localhost' identified by 'zabbix123!';
Query OK, 0 rows affected (0.05 sec)
mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost';
Query OK, 0 rows affected, 1 warning (0.02 sec)
mysql> SET GLOBAL log_bin_trust_function_creators = 1;
Query OK, 0 rows affected (0.01 sec)
mysql> quit
Bye
[root@localhost zabbix-6.2.2]# cd /usr/src/zabbix-6.2.2/database/mysql/
[root@localhost mysql]# ls
Makefile.am Makefile.in data.sql double.sql history_pk_prepare.sql images.sql schema.sql
//将此处数据进行导入
[root@localhost mysql]# mysql -uroot -p'lnh123' zabbix < schema.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@localhost mysql]# mysql -uroot -p'lnh123' zabbix < images.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@localhost mysql]# mysql -uroot -p'lnh123' zabbix < data.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@localhost mysql]# mysql -uroot -p'lnh123'
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 18
Server version: 8.0.28 MySQL Community Server - GPL
Copyright (c) 2000, 2022, 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> SET GLOBAL log_bin_trust_function_creators = 0;
Query OK, 0 rows affected (0.00 sec)
mysql> show tables from zabbix;
+----------------------------+
| Tables_in_zabbix |
+----------------------------+
| acknowledges |
| actions |
....
| widget_field |
+----------------------------+
176 rows in set (0.03 sec)
//查看zabbix数据库下有哪些表,没有问题的话是176张表
[root@localhost mysql]# cd /usr/src/zabbix-6.2.2/
[root@localhost zabbix-6.2.2]# ./configure --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2
//编译zabbix
...
***********************************************************
* Now run 'make install' *
* *
* Thank you for using Zabbix! *
* <http://www.zabbix.com> *
***********************************************************
[root@localhost zabbix-6.2.2]# make install
zabbix服务端配置
[root@localhost zabbix-6.2.2]# cd /usr/local/etc/
[root@localhost etc]# ls
zabbix_agentd.conf zabbix_agentd.conf.d zabbix_server.conf zabbix_server.conf.d
[root@localhost etc]# vim zabbix_server.conf
# DBPassword= //在这行下面添加前面设置的mysql里面用户密码
DBPassword=zabbix123! //添加
zabbix配置web界面
[root@localhost etc]# cd
[root@localhost ~]# cd /usr/src/zabbix-6.2.2/
[root@localhost zabbix-6.2.2]# ls
AUTHORS Makefile README compile config.status database m4 sass
COPYING Makefile.am aclocal.m4 conf config.sub depcomp man src
ChangeLog Makefile.in bin config.guess configure include misc ui
INSTALL NEWS build config.log configure.ac install-sh missing
[root@localhost zabbix-6.2.2]# vim /usr/local/apache/conf/extra/httpd-vhosts.conf
//配置apache虚拟主机,可以注释之前的配置
<VirtualHost *:80>
DocumentRoot "/usr/local/apache/htdocs/zabbix"
ServerName zabbix.example.com
ErrorLog "logs/zabbix.example.com-error_log"
CustomLog "logs/zabbix.example.com-access_log" common
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/zabbix/$1
<Directory "/usr/local/apache/htdocs/zabbix">
Options none
AllowOverride none
Require all granted
</Directory>
</VirtualHost>
[root@localhost zabbix-6.2.2]# cd /usr/src/zabbix-6.2.2/
[root@localhost zabbix-6.2.2]# ls
AUTHORS Makefile README compile config.status database m4 sass
COPYING Makefile.am aclocal.m4 conf config.sub depcomp man src
ChangeLog Makefile.in bin config.guess configure include misc ui
INSTALL NEWS build config.log configure.ac install-sh missing
[root@localhost zabbix-6.2.2]# cd ui/
[root@localhost ui]# ls //此处是php代码
actionconf.php composer.lock imgstore.php report2.php
api_jsonrpc.php conf include report4.php
app data index.php robots.txt
assets disc_prototypes.php index_http.php setup.php
audio favicon.ico index_sso.php sysmap.php
auditacts.php graphs.php items.php sysmaps.php
browserwarning.php history.php js templates.php
chart.php host_discovery.php jsLoader.php toptriggers.php
chart2.php host_prototypes.php jsrpc.php tr_events.php
chart3.php hostinventories.php local trigger_prototypes.php
chart4.php hostinventoriesoverview.php locale triggers.php
chart6.php httpconf.php maintenance.php vendor
chart7.php httpdetails.php map.php zabbix.php
composer.json image.php modules
[root@localhost ui]# cd -
/usr/src/zabbix-6.2.2
[root@localhost zabbix-6.2.2]# cd
[root@localhost ~]# cd /usr/src/zabbix-6.2.2/
[root@localhost zabbix-6.2.2]# mkdir /usr/local/apache/htdocs/zabbix //创建zabbix的web站点目录
[root@localhost zabbix-6.2.2]# cp -a /usr/src/zabbix-6.2.2/ui/* /usr/local/apache/htdocs/zabbix/
//将zabbix的web界面php代码复制到站点目录
[root@localhost zabbix-6.2.2]# chown -R apache.apache /usr/local/apache/htdocs/
//使其属主属组是apache
[root@localhost zabbix-6.2.2]# ll /usr/local/apache/htdocs/
total 8
-rw-r--r--. 1 apache apache 45 Jun 12 2007 index.html
drwxr-xr-x. 2 apache apache 23 Sep 2 16:45 runtime
drwxr-xr-x. 13 apache apache 4096 Sep 2 17:50 zabbix
[root@localhost zabbix-6.2.2]# chmod 777 /usr/local/apache/htdocs/zabbix/conf/
//设置zabbix/conf目录的权限,让zabbix有权限生成配置文件zabbix.conf.php
[root@localhost zabbix-6.2.2]# ll -d /usr/local/apache/htdocs/zabbix/conf/
drwxrwxrwx. 3 apache apache 94 Aug 29 15:05 /usr/local/apache/htdocs/zabbix/conf/
[root@localhost zabbix-6.2.2]# httpd -t
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
Syntax OK
[root@localhost zabbix-6.2.2]# systemctl restart httpd.service
//重启httpd
[root@localhost zabbix-6.2.2]# sed -ri 's/(post_max_size =).*/\1 16M/g' /etc/php.ini
[root@localhost zabbix-6.2.2]# sed -ri 's/(max_execution_time =).*/\1 300/g' /etc/php.ini
[root@localhost zabbix-6.2.2]# sed -ri 's/(max_input_time =).*/\1 300/g' /etc/php.ini
[root@localhost zabbix-6.2.2]# sed -i '/;date.timezone/a date.timezone = Asia/Shanghai' /etc/php.ini
//修改/etc/php.ini的配置
[root@localhost zabbix-6.2.2]# service php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm done
//重启php-fpm
root@localhost zabbix-6.2.2]# cd
[root@localhost ~]# zabbix_server
[root@localhost ~]# zabbix_agentd
//启动zabbix_server和zabbix_agentd
[root@localhost ~]# ss -antl //查看端口(2个)
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:80 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 0.0.0.0:10050 0.0.0.0:*
LISTEN 0 128 0.0.0.0:10051 0.0.0.0:*
LISTEN 0 128 127.0.0.1:9000 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 70 *:33060 *:*
LISTEN 0 128 *:3306 *:*
在物理机上做hosts域名映射
在我的电脑里面进行映射(C:\Windows\System32\drivers\etc)
去浏览器访问,输入zabbix.example.com,看到如下页面,然后点击next step
下一步
下一步
下一步
下一步
下一步
用户名Admin 密码 zabbix
部署完成
[root@localhost ~]# chmod 755 /usr/local/apache/htdocs/zabbix/conf/
[root@localhost ~]# ll -d /usr/local/apache/htdocs/zabbix/conf/
drwxr-xr-x. 3 apache apache 117 Sep 1 23:41 /usr/local/apache/htdocs/zabbix/conf/
//恢复zabbix/conf目录的权限为755