目录
编译安装nginx
-
[root@8a-1 opt]
# uname -a
-
Linux 8a-1 3.10.0-1160.71.1.el7.x86_64
#1 SMP Tue Jun 28 15:37:28 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
-
[root@8a-1 opt]
# cat /etc/redhat-release
-
CentOS Linux release 7.9.2009 (Core)
-
-
-
[root@8a-1 ~]
# cd /opt/
-
[root@8a-1 opt]
# ll
-
-rw-r--r-- 1 root root 832104 Dec 21 09:45 nginx-1.8.0.tar.gz
-
[root@8a-1 opt]
# tar -zxvf nginx-1.8.0.tar.gz
-
[root@8a-1 opt]
# cd nginx-1.8.0
-
[root@8a-1 nginx-1.8.0]
# mkdir -p /usr/local/nginx/
-
[root@8a-1 nginx-1.8.0]
# ./configure --prefix=/usr/local/nginx/ --without-http_rewrite_module --without-http_gzip_module --with-pcre
-
[root@8a-1 nginx-1.8.0]
# make
-
[root@8a-1 nginx-1.8.0]
# make install
配置nginx开机自启动
-
[root@8a-1 nginx-1.8.0]
# vi /etc/init.d/nginx
-
[root@8a-1 nginx-1.8.0]
# cat /etc/init.d/nginx
-
#!/bin/sh
-
#
-
# nginx - this script starts and stops the nginx daemon
-
#
-
# chkconfig: - 85 15
-
# description: NGINX is an HTTP(S) server, HTTP(S) reverse \
-
# proxy and IMAP/POP3 proxy server
-
# processname: nginx
-
# config: /usr/local/nginx/conf/nginx.conf
-
# pidfile: /usr/local/nginx/logs/nginx.pid
-
-
# Source function library.
-
. /etc/rc.d/init.d/functions
-
-
# Source networking configuration.
-
. /etc/sysconfig/network
-
-
# Check that networking is up.
-
[
"$NETWORKING" =
"no" ] &&
exit 0
-
# :set ff=unix
-
-
# 修改为实际配置文件目录
-
nginx=
"/usr/local/nginx/sbin/nginx"
-
prog=$(
basename
$nginx)
-
# 修改为实际配置文件目录
-
NGINX_CONF_FILE=
"/usr/local/nginx/conf/nginx.conf"
-
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
-
lockfile=/var/lock/subsys/nginx
-
-
make_dirs() {
-
# make required directories
-
user=`
$nginx -V 2>&1 | grep
"configure arguments:.*--user=" | sed
's/[^*]*--user=\([^ ]*\).*/\1/g' -`
-
if [ -n
"$user" ];
then
-
if [ -z
"`grep $user /etc/passwd`" ];
then
-
useradd -M -s /bin/nologin
$user
-
fi
-
options=`
$nginx -V 2>&1 | grep
'configure arguments:'`
-
for opt
in
$options;
do
-
if [ `
echo
$opt | grep
'.*-temp-path'` ];
then
-
value=`
echo
$opt |
cut -d
"=" -f 2`
-
if [ ! -d
"$value" ];
then
-
# echo "creating" $value
-
mkdir -p
$value &&
chown -R
$user
$value
-
fi
-
fi
-
done
-
fi
-
}
-
-
start() {
-
[ -x
$nginx ] ||
exit 5
-
[ -f
$NGINX_CONF_FILE ] ||
exit 6
-
make_dirs
-
echo -n $
"Starting $prog: "
-
daemon
$nginx -c
$NGINX_CONF_FILE
-
retval=$?
-
echo
-
[
$retval -eq 0 ] &&
touch
$lockfile
-
return
$retval
-
}
-
-
stop() {
-
echo -n $
"Stopping $prog: "
-
killproc
$prog -QUIT
-
retval=$?
-
echo
-
[
$retval -eq 0 ] &&
rm -f
$lockfile
-
return
$retval
-
}
-
-
restart() {
-
configtest ||
return $?
-
stop
-
sleep 1
-
start
-
}
-
-
reload() {
-
configtest ||
return $?
-
echo -n $
"Reloading $prog: "
-
killproc
$prog -HUP
-
retval=$?
-
echo
-
}
-
-
force_reload() {
-
restart
-
}
-
-
configtest() {
-
nginx -t -c
$NGINX_CONF_FILE
-
}
-
-
rh_status() {
-
status
$prog
-
}
-
-
rh_status_q() {
-
rh_status >/dev/null 2>&1
-
}
-
-
case
"$1"
in
-
start)
-
rh_status_q &&
exit 0
-
$1
-
;;
-
stop)
-
rh_status_q ||
exit 0
-
$1
-
;;
-
restart|configtest)
-
$1
-
;;
-
reload)
-
rh_status_q ||
exit 7
-
$1
-
;;
-
force-reload)
-
force_reload
-
;;
-
status)
-
rh_status
-
;;
-
condrestart|try-restart)
-
rh_status_q ||
exit 0
-
;;
-
*)
-
echo
"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
-
exit 2
-
esac
-
[root@8a-1 nginx-1.8.0]
# chmod +x /etc/init.d/nginx
-
[root@8a-1 nginx-1.8.0]
# chkconfig --add nginx
-
[root@8a-1 nginx-1.8.0]
# chkconfig nginx on
-
[root@8a-1 nginx-1.8.0]
# systemctl start nginx
-
[root@8a-1 nginx-1.8.0]
# systemctl status nginx
验证nginx
-
[root@8a-1 nginx-1.8.0]
# ip a
-
inet 192.168.61.1/24 brd 192.168.61.255 scope global noprefixroute ens33
编译安装PHP
千万不要用PHP8.0 !!! 建议用PHP7.2 因为我第一次用了PHP8 ,可以直接翻到最后看结果,页面加载不出来! 还得改源码 卧槽
-
[root@8a-1 opt]
# wget https://www.php.net/distributions/php-7.4.12.tar.gz
-
[root@8a-1 opt]
# groupadd www
-
[root@8a-1 opt]
# useradd -g www www
-
[root@8a-1 opt]
# ll
-
-rw-r--r-- 1 root root 20054375 Dec 20 10:34 php-8.2.0.tar.gz
-
[root@8a-1 opt]
# tar -zxvf php-8.2.0.tar.gz
-
[root@8a-1 opt]
# cd php-8.2.0
-
[root@8a-1 php-8.2.0]
# ./configure --prefix=/usr/local/php --with-config-file-path=/etc --with-fpm-user=www --with-fpm-group=www --with-curl --with-freetype --enable-gd --with-gettext --without-iconv --with-kerberos --with-libdir=lib64 --with-libxml --with-mysqli --with-openssl --with-pdo-mysql --with-pdo-sqlite --with-pear --with-jpeg --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-fpm --disable-mbregex
-
[root@8a-1 php-8.2.0]
# make
-
[root@8a-1 php-8.2.0]
# make install
-
[root@8a-1 php-8.2.0]
# /usr/local/php/bin/php -v
-
PHP 8.2.0 (cli) (built: Dec 21 2022 11:23:03) (NTS)
-
Copyright (c) The PHP Group
-
Zend Engine v4.2.0, Copyright (c) Zend Technologies
-
-
#php7.0.2 编译方式
-
[root@8a-2 php-7.0.2]
# ./configure --prefix=/usr/local/php --with-config-file-path=/etc --with-fpm-user=www --with-fpm-group=www --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-zip --enable-fpm
-
-
#php7.4.12 编译方式
-
[root@8a-2 php-7.4.12]
# ./configure --prefix=/usr/local/php --with-config-file-path=/etc --with-fpm-user=www --with-fpm-group=www --with-curl --with-freetype --enable-gd --with-gettext --without-iconv --with-kerberos --with-libdir=lib64 --with-libxml --with-mysqli --with-openssl --with-pdo-mysql --with-pdo-sqlite --with-pear --with-jpeg --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-fpm --disable-mbregex
上面的这些编译参数 要根据版本情况而定,很多参数已经换了写法 使用./configure --help查看,如果缺少依赖包的话 也可以视情况删掉一些不需要的参数
另外:第二次用了php7.0.2 结果发现 zabbix5.0 要求php最低7.2 我又换成php7.4
如果编译缺少依赖包的话,需要根据自己的环境补充依赖
-
[root@8a-1 opt]
# ll
-
-rw-r--r-- 1 root root 759839 Dec 21 10:17 oniguruma-7.0.zip
-
[root@8a-1 opt]
# unzip oniguruma-7.0.zip
-
[root@8a-1 opt]
# cd oniguruma-7.0
-
[root@8a-1 opt]
# mkdir -p /usr/local/oniguruma
-
[root@8a-1 oniguruma-7.0]
# ./autogen.sh && ./configure --prefix=/usr/local/oniguruma --libdir=/lib64
-
[root@8a-1 oniguruma-7.0]
# make
-
[root@8a-1 oniguruma-7.0]
# make install
配置php-fpm
-
[root@8a-1 php-8.2.0]
# vi /etc/profile
-
[root@8a-1 php-8.2.0]
# source /etc/profile
-
[root@8a-1 php-8.2.0]
# cp /usr/bin/php /usr/bin/php.bak
-
[root@8a-1 bin]
# ln -s /usr/local/php/bin/php /usr/bin/php
-
[root@8a-1 bin]
# php -v
-
PHP 8.2.0 (cli) (built: Dec 21 2022 11:23:03) (NTS)
-
Copyright (c) The PHP Group
-
Zend Engine v4.2.0, Copyright (c) Zend Technologies
-
-
[root@8a-1 opt]
# cd php-8.2.0
-
[root@8a-1 php-8.2.0]
# cp php.ini-production /etc/php.ini
-
[root@8a-1 php-8.2.0]
# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
-
[root@8a-1 php-8.2.0]
# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
-
[root@8a-1 php-8.2.0]
# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
-
[root@8a-1 php-8.2.0]
# chmod +x /etc/init.d/php-fpm
-
[root@8a-1 php-8.2.0]
# /etc/init.d/php-fpm start
PATH=$PATH:/usr/local/php/bin
export PATH
配置nginx支持php
-
[root@8a-1 init.d]
# cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak
-
[root@8a-1 init.d]
# vi /usr/local/nginx/conf/nginx.conf
-
[root@8a-1 init.d]
# grep -v "#" /usr/local/nginx/conf/nginx.conf
-
-
worker_processes 1;
-
-
events {
-
worker_connections 1024;
-
}
-
-
http {
-
include mime.types;
-
default_type application/octet-stream;
-
sendfile on;
-
keepalive_timeout 65;
-
-
server {
-
listen 80;
-
server_name localhost;
-
#添加index.php
-
location / {
-
root html;
-
index index.php index.html index.htm;
-
}
-
-
error_page 500 502 503 504 /50x.html;
-
location = /50x.html {
-
root html;
-
}
-
#放开有关php的location注释
-
location ~ \.php$ {
-
root html;
-
fastcgi_pass 127.0.0.1:9000;
-
fastcgi_index index.php;
-
#修改路径
-
fastcgi_param SCRIPT_FILENAME $document_root
$fastcgi_script_name;
-
include fastcgi_params;
-
}
-
}
-
}
-
验证nginx+php
-
[root@8a-1 init.d]
# cd /usr/local/nginx/html
-
[root@8a-1 html]
# vi info.php
-
[root@8a-1 html]
# cat info.php
-
<?php
-
phpinfo();
-
?>
-
[root@8a-1 html]
# systemctl restart nginx
-
[root@8a-1 html]
# /etc/init.d/php-fpm restart
mysqli模块要显示才行 ,不然php可能无法连接mysql
编译安装mysql
-
# 安装之前需要把系统自带的Mariadb卸载(如果不用yum安装 好像不用卸载也行 原文用的是yum安装 所以他卸载了,我这里不是yum安装的,不确定需不需要卸载。PS 后面我又试了试 这里不删Mariadb也能成功)
-
[root@8a-1 opt]
# rpm -qa | grep mariadb
-
mariadb-libs-5.5.68-1.el7.x86_64
-
mariadb-devel-5.5.68-1.el7.x86_64
-
mariadb-server-5.5.68-1.el7.x86_64
-
mariadb-5.5.68-1.el7.x86_64
-
[root@8a-1 opt]
# yum remove -y mariadb-libs-5.5.68-1.el7.x86_64
-
[root@8a-1 opt]
# groupadd mysql
-
[root@8a-1 opt]
# useradd mysql
-
-
[root@8a-1 opt]
# ll
-
-rw-r--r-- 1 root root 744349688 Nov 9 23:35 mysql-5.7.39-el7-x86_64.tar.gz
-
[root@8a-1 opt]
# tar -zxvf mysql-5.7.39-el7-x86_64.tar.gz
-
[root@8a-1 opt]
# cd mysql-5.7.39-el7-x86_64
-
[root@8a-1 mysql-5.7.39-el7-x86_64]
# visudo
mysql ALL=(ALL) ALL
-
[root@8a-1 mysql-5.7.39-el7-x86_64]
# mkdir -p /data/mysql
-
[root@8a-1 mysql-5.7.39-el7-x86_64]
# chown -R mysql:mysql /data/mysql
-
[root@8a-1 mysql-5.7.39-el7-x86_64]
# vi /etc/my.cnf
[mysqld]
bind-address=0.0.0.0
port=3306
user=mysql
basedir=/usr/local/mysql
datadir=/data/mysql
socket=/tmp/mysql.sock
log-error=/data/mysql/mysql.err
pid-file=/data/mysql/mysql.pid
#character config
character_set_server=utf8mb4
symbolic-links=0
explicit_defaults_for_timestamp=true
-
[root@8a-1 opt]
# cd /opt/
-
[root@8a-1 opt]
# ll
-
drwxr-xr-x 9 root root 129 Dec 21 13:57 mysql-5.7.39-el7-x86_64
-
[root@8a-1 opt]
# mv mysql-5.7.39-el7-x86_64 /usr/local/mysql
-
[root@8a-1 opt]
# cd /usr/local/mysql/bin/
-
[root@8a-1 bin]
# ./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql/ --datadir=/data/mysql/ --user=mysql --initialize
-
[root@8a-1 bin]
# cat /data/mysql/mysql.err
-
2022-12-21T06:08:14.208797Z 1 [Note] A temporary password is generated
for root@localhost: 1rvFK/IOTkPm
-
[root@8a-1 bin]
# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
-
[root@8a-1 bin]
# chown -R mysql.mysql /usr/local/mysql
-
[root@8a-1 bin]
# chown -R mysql.mysql /data/mysql
-
[root@8a-1 bin]
# service mysql start
-
[root@8a-1 opt]
# vi /etc/my.cnf
[mysqld]
skip-grant-tables
-
[root@8a-1 opt]
# service mysql restart
-
[root@8a-1 opt]
# /usr/local/mysql/bin/mysql -u root -p
-
mysql> use mysql;
-
mysql> update user
set host=
'%'
where user=
'root';
-
mysql> FLUSH PRIVILEGES;
-
mysql> ALTER USER
"root"@
"%" IDENTIFIED BY
"123456";
-
mysql> quit
-
-
[root@8a-1 opt]
# tail -1 /etc/my.cnf
-
skip-grant-tables
-
[root@8a-1 opt]
# vi /etc/my.cnf
-
[root@8a-1 opt]
# tail -1 /etc/my.cnf
-
#skip-grant-tables
-
[root@8a-1 opt]
# ln -s /usr/local/mysql/bin/mysql /bin/mysql
-
[root@8a-1 opt]
# service mysql restart
-
[root
@8a
-1 opt]# mysql
-uroot
-p123456
-
mysql
>
GRANT
ALL PRIVILEGES
ON
*.
*
TO
'root'@
'%'IDENTIFIED
BY
'123456'
WITH
GRANT OPTION;
-
mysql
> flush privileges;
-
mysql
> quit
这篇文章用的是mariadb 应该也没问题,感觉如果有mariadb 那直接用就好,不用非得把mariadb卸载然后装mysql,我这里搞得有点麻烦了,后面有时间再调整一下
安装zabbix
-
[root@8a-1 opt]
# yum install gcc gcc-c++ make unixODBC-devel net-snmp-devel libssh2-devel OpenIPMI-devel libevent-devel pcre-devel libcurl-devel curl-* net-snmp* libxml2-* wget tar -y
-
[root@8a-1 opt]
# yum install -y mysql-devel
-
[root@8a-1 opt]
# ll
-
-rw-r--r-- 1 root root 18519888 Dec 20 22:24 zabbix-5.0.0.tar.gz
-
[root@8a-1 opt]
# tar -zxvf zabbix-5.0.0.tar.gz
-
[root@8a-1 opt]
# cd zabbix-5.0.0/
-
[root@8a-1 zabbix-5.0.0]
# mkdir -p /usr/local/zabbix
-
[root@8a-1 zabbix-5.0.0]
# ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
-
[root@8a-1 zabbix-5.0.0]
# make
-
[root@8a-1 zabbix-5.0.0]
# make install
-
-
[root@8a-1 zabbix-5.0.0]
# groupadd --system zabbix
-
[root@8a-1 zabbix-5.0.0]
# useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix
-
[root@8a-1 zabbix-5.0.0]
# cd /opt/zabbix-5.0.0
-
[root@8a-1 zabbix-5.0.0]
# cp misc/init.d/fedora/core/zabbix_* /etc/init.d/
-
[root@8a-1 zabbix-5.0.0]
# ll -d /etc/init.d/zabbix_*
-
-rwxr-xr-x 1 root root 2170 Dec 21 14:49 /etc/init.d/zabbix_agentd
-
-rwxr-xr-x 1 root root 2181 Dec 21 14:49 /etc/init.d/zabbix_server
-
[root@8a-1 zabbix-5.0.0]
# chmod +x /etc/init.d/zabbix_*
初始化zabbix数据库
-
[root
@8a
-1 opt]# mysql
-u root
-p123456
-
mysql
>
create database zabbix
character
set utf8
collate utf8_bin;
-
mysql
>
grant
all privileges
on zabbix.
*
to zabbix
@localhost identified
by
'123456';
-
mysql
>
grant
all privileges
on zabbix.
*
to zabbix
@127
.0
.0
.1 identified
by
'123456';
-
mysql
>
GRANT
ALL PRIVILEGES
ON
*.
*
TO
'zabbix'@
'%'IDENTIFIED
BY
'123456'
WITH
GRANT OPTION;
-
mysql
> flush privileges;
-
mysql
> quit
导入表结构
-
[root@8a-1 mysql]
# cd /opt/zabbix-5.0.0/database/mysql/
-
[root@8a-1 mysql]
# ll
-
-rw-r--r-- 1
test
test 156239 May 11 2020 schema.sql
-
-rw-r--r-- 1
test
test 1978341 May 11 2020 images.sql
-
-rw-r--r-- 1
test
test 7097625 May 11 2020 data.sql
-
[root@8a-1 mysql]
# mysql -u root -p123456
-
mysql> use zabbix;
-
mysql>
source /opt/zabbix-5.0.0/database/mysql/schema.sql
-
mysql>
source /opt/zabbix-5.0.0/database/mysql/images.sql
-
mysql>
source /opt/zabbix-5.0.0/database/mysql/data.sql
使用php连接mysql验证
-
[root@8a-1 opt]
# vi /usr/local/nginx/html/test.php
-
[root@8a-1 opt]
# cat /usr/local/nginx/html/test.php
-
<?php
-
$link=mysqli_connect(
'127.0.0.1',
'zabbix',
'123456');
-
if (
$link)
echo
"数据库连接成功!";
-
else
echo
"数据库连接失败~";
-
?>
-
[root@8a-1 opt]
# php /usr/local/nginx/html/test.php
-
数据库连接成功!
-
-
[root@8a-1 opt]
# systemctl restart nginx
-
[root@8a-1 opt]
# /etc/init.d/php-fpm restart
-
[root@8a-1 opt]
# killall php-fpm
-
[root@8a-1 opt]
# systemctl restart php-fpm
配置zabbix服务端
-
[root@8a-1 opt]
# cp /usr/local/zabbix/etc/zabbix_server.conf /usr/local/zabbix/etc/zabbix_server.conf.bak
-
[root@8a-1 opt]
# cp /usr/local/zabbix/etc/zabbix_agentd.conf /usr/local/zabbix/etc/zabbix_agentd.conf.bak
-
[root@8a-1 opt]
#grep -v "^#|^$" /usr/local/zabbix/etc/zabbix_server.conf
-
[root@8a-1 opt]
# vi /usr/local/zabbix/etc/zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/tmp/zabbix_server.pidSocketDir=/tmp
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123456
DBSocket=/tmp/mysql.sock
DBPort=3306
StartPollers=100
StartTrappers=10
StartPingers=10
StartDiscoverers=10
Timeout=4
LogSlowQueries=3000
Include=/usr/local/zabbix/etc/zabbix_server.conf.d/*.conf
StatsAllowedIP=127.0.0.1
配置zabbix代理端
-
-
[root@8a-1 opt]
# vi /usr/local/zabbix/etc/zabbix_agentd.conf
-
[root@8a-1 opt]
# mkdir -p /var/log/zabbix
-
[root@8a-1 opt]
# chown -R zabbix:zabbix /var/log/zabbix
-
[root@8a-1 opt]
# chown -R zabbix:zabbix /tmp/zabbix_*
PidFile=/tmp/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
DenyKey=system.run[*]
Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=Zabbix server
Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/*.conf
UnsafeUserParameters=1
配置zabbix 服务端启动文件
-
[root@8a-1 opt]
# vi /lib/systemd/system/zabbix-server.service
-
[root@8a-1 opt]
# cat /lib/systemd/system/zabbix-server.service
-
-
[Unit]
-
Description=Zabbix Server
-
After=syslog.target
-
After=network.target
-
After=mysql.service
-
After=mysqld.service
-
After=mariadb.service
-
After=postgresql.service
-
-
[Service]
-
Environment=
"CONFFILE=/usr/local/zabbix/etc/zabbix_server.conf"
-
EnvironmentFile=-/etc/sysconfig/zabbix-server
-
Type=forking
-
Restart=on-failure
-
PIDFile=/tmp/zabbix_server.pid
-
KillMode=control-group
-
ExecStart=/usr/local/zabbix/sbin/zabbix_server -c /usr/local/zabbix/etc/zabbix_server.conf
-
ExecStop=/bin/kill -SIGTERMMAINPID
-
RestartSec=10s
-
TimeoutSec=0
-
-
[Install]
-
WantedBy=multi-user.target
配置 zabbix 代理端启动文件
-
[root@8a-1 opt]
# vi /lib/systemd/system/zabbix-agent.service
-
[root@8a-1 opt]
# cat /lib/systemd/system/zabbix-agent.service
-
-
[Unit]
-
Description=Zabbix Agent
-
After=syslog.target
-
After=network.target
-
-
[Service]
-
Environment=
"CONFFILE=/usr/local/zabbix/etc/zabbix_agentd.conf"
-
EnvironmentFile=-/etc/sysconfig/zabbix-agent
-
Type=forking
-
Restart=on-failure
-
PIDFile=/tmp/zabbix_agentd.pid
-
KillMode=control-group
-
ExecStart=/usr/local/zabbix/sbin/zabbix_agentd -c /usr/local/zabbix/etc/zabbix_agentd.conf
-
ExecStop=/bin/kill -SIGTERMMAINPID
-
RestartSec=10s
-
User=zabbix
-
Group=zabbix
-
-
[Install]
-
WantedBy=multi-user.target
启动zabbix服务端和客户端
-
[root@8a-1 opt]
# systemctl daemon-reload
-
[root@8a-1 opt]
# systemctl enable --now zabbix-server
-
[root@8a-1 opt]
# systemctl enable --now zabbix-agent
-
[root@8a-1 opt]
# systemctl status zabbix-server.service
-
[root@8a-1 opt]
# systemctl status zabbix-agent.service
配置zabbix前端页面
-
[root@8a-1 opt]
# cp -r /opt/zabbix-5.0.0/ui/* /usr/local/nginx/html/
-
【不用执行 留着备用】[root@8a-1 opt]
# chown -R www:www /var/www/html/
-
【不用执行 留着备用】[root@8a-1 opt]
# chown -R /usr/local/nginx/html/
-
-
[root@8a-1 opt]
# find / -name mysql.sock
-
/tmp/mysql.sock
-
[root@8a-1 opt]
# vi /etc/php.ini
max_execution_time = 300
max_input_time = 300
post_max_size = 16Mdate.timezone = Asia/Shanghai
pdo_mysql.default_socket = /tmp/mysql.sock
mysqli.default_socket = /tmp/mysql.sock
[root@8a-1 opt]# systemctl restart php-fpm
验证前端页面
登录 http://192.168.61.1/setup.php
这里不知道为什么没过去,可能是权限问题? 然后按照提示手工上传了一份配置文件就好了
-
[root@8a-1 conf]
# pwd
-
/usr/local/nginx/html/conf
-
[root@8a-1 conf]
# ll
-
-rw-r--r-- 1 root root 1479 Dec 21 17:28 zabbix.conf.php
#这个文件是从网页上直接下载下来的 没有做任何修改
浏览器访问 http://192.168.61.1/index.php
账号 Admin 密码 zabbix
出现上图 原因是服务端端口没起来(其实不是端口问题,不过端口没起来也是不正常的)
因为我这个mysql是自己装的,sock的地址写错了,上面有很多配置sock的地方 都写的是/var/lib/mysql/mysql.sock ,但是在安装mysql的时候 把sock放到 /tmp/mysql.sock ,所以要改一下
-
[root@8a-1 tmp]
# vi /usr/local/zabbix/etc/zabbix_server.conf
-
[root@8a-1 tmp]
# cat /usr/local/zabbix/etc/zabbix_server.conf | grep Socket
-
SocketDir=/tmp
-
DBSocket=/tmp/mysql.sock
-
[root@8a-1 tmp]
# systemctl restart zabbix_server
不知道什么时候apache也挂了,端口跟nginx冲突了 需要改一下(后面看apache挂了也无所谓 nginx能用就好)
-
[root@8a-1 conf]
# vi httpd.conf
-
[root@8a-1 conf]
# systemctl restart httpd
-
[root@8a-1 conf]
# cat /etc/httpd/conf/httpd.conf | grep 8080
-
Listen 8080
-
[root@8a-1 conf]
# systemctl status httpd
编译load模块(这里是防止setup.php那里检查过不去)
-
[root@8a-1 ~]
# cd /opt/php-8.2.0/ext/ldap/
-
[root@8a-1 ldap]
# ll
-
#此时没有configure
-
-rw-r--r-- 1 501 games 4918 Dec 6 22:26 config.m4
-
-rw-r--r-- 1 501 games 1230 Dec 6 22:26 config.w32
-
-rw-r--r-- 1 501 games 77 Dec 6 22:26 CREDITS
-
-rw-r--r-- 1 501 games 37705 Dec 6 22:26 ldap_arginfo.h
-
-rw-r--r-- 1 501 games 111033 Dec 6 22:26 ldap.c
-
-rw-r--r-- 1 501 games 22542 Dec 6 22:26 ldap.stub.php
-
-rw-r--r-- 1 501 games 2195 Dec 6 22:26 php_ldap.h
-
drwxr-xr-x 2 501 games 8192 Dec 21 10:09 tests
-
[root@8a-1 ldap]
# /usr/local/php/bin/phpize
-
Configuring
for:
-
PHP Api Version: 20220829
-
Zend Module Api No: 20220829
-
Zend Extension Api No: 420220829
-
[root@8a-1 ldap]
# ll
-
#多了configure文件
-
drwxr-xr-x 2 root root 54 Dec 21 21:26 autom4te.cache
-
drwxr-xr-x 2 root root 261 Dec 21 21:26 build
-
-rw-r--r-- 1 root root 2710 Dec 21 21:26 config.h.in
-
-rw-r--r-- 1 501 games 4918 Dec 6 22:26 config.m4
-
-rwxr-xr-x 1 root root 468940 Dec 21 21:26 configure
-
-rw-r--r-- 1 root root 5313 Dec 21 21:26 configure.ac
-
-rw-r--r-- 1 501 games 1230 Dec 6 22:26 config.w32
-
-rw-r--r-- 1 501 games 77 Dec 6 22:26 CREDITS
-
-rw-r--r-- 1 501 games 37705 Dec 6 22:26 ldap_arginfo.h
-
-rw-r--r-- 1 501 games 111033 Dec 6 22:26 ldap.c
-
-rw-r--r-- 1 501 games 22542 Dec 6 22:26 ldap.stub.php
-
-rw-r--r-- 1 501 games 2195 Dec 6 22:26 php_ldap.h
-
-rw-r--r-- 1 root root 137381 Dec 21 21:26 run-tests.php
-
drwxr-xr-x 2 501 games 8192 Dec 21 10:09 tests
-
-
[root@8a-1 ldap]
# ll /usr/lib64/libldap*
-
lrwxrwxrwx. 1 root root 21 Nov 16 04:38 /usr/lib64/libldap-2.3.so.0 -> libldap-2.3.so.0.2.31
-
-rwxr-xr-x. 1 root root 261008 Jun 10 2014 /usr/lib64/libldap-2.3.so.0.2.31
-
lrwxrwxrwx. 1 root root 21 Nov 16 04:32 /usr/lib64/libldap-2.4.so.2 -> libldap-2.4.so.2.10.7
-
-rwxr-xr-x. 1 root root 352496 Feb 24 2022 /usr/lib64/libldap-2.4.so.2.10.7
-
lrwxrwxrwx. 1 root root 23 Nov 16 04:38 /usr/lib64/libldap_r-2.3.so.0 -> libldap_r-2.3.so.0.2.31
-
-rwxr-xr-x. 1 root root 281912 Jun 10 2014 /usr/lib64/libldap_r-2.3.so.0.2.31
-
lrwxrwxrwx. 1 root root 23 Nov 16 04:32 /usr/lib64/libldap_r-2.4.so.2 -> libldap_r-2.4.so.2.10.7
-
-rwxr-xr-x. 1 root root 381312 Feb 24 2022 /usr/lib64/libldap_r-2.4.so.2.10.7
-
lrwxrwxrwx. 1 root root 23 Nov 16 04:34 /usr/lib64/libldap_r.so -> libldap_r-2.4.so.2.10.7
-
lrwxrwxrwx. 1 root root 21 Nov 16 04:34 /usr/lib64/libldap.so -> libldap-2.4.so.2.10.7
-
[root@8a-1 ldap]
# cp -frp /usr/lib64/libldap* /usr/lib/
-
[root@8a-1 ldap]
# ./configure --with-php-config=/usr/local/php/bin/php-config --with-ldap
-
[root@8a-1 ldap]
# make
-
[root@8a-1 ldap]
# make install
好吧 上面的搞完了 还是不行 ,又找了一篇文章试试(这个方法也不行)
-
[root@8a-1 ext]
# cd /usr/local/nginx/html/
-
[root@8a-1 html]
# cp include/classes/db/DB.php ./include/classes/db/DB.php.bak
-
[root@8a-1 html]
# vi ./include/classes/db/DB.php
改完了 还是不行 貌似是因php8.0 的问题 ,改成php7.4就好了 我敲 这中文翻译是真的流弊
果然PHP版本不能用8.0 垃圾PHP!!!换了三个版本才搞好 !
转载:https://blog.csdn.net/qq_34479012/article/details/128380489