操作系统:CentOS Linux release 7.6.1810 (Core)
环境:内网环境,无公网出口
YUM源:本地yum
MySQL版本:5.7.32
Nginx版本:nginx-1.22.0
PHP版本:php-7.4.30
Zabbix版本:zabbix-5.0.27
#systemctl stop firewalld
#systemctl disable firewalld
#setenforce 0
#vim /etc/selinux/config
SELINUX=disabled
下载地址:MySQL :: Download MySQL Community Server (Archived Versions)
# rpm -qa |grep -i mysql
如有,进行卸操作
#rpm -e --nodeps <包名>
#whereis mysql
#cd /;find / -name mysql
#cat /etc/passwd | grep mysql
#cat /etc/shadow | grep mysql
#cat /etc/group | grep mysql
#userdel mysql
#groupdel mysql
#tar -xvf mysql-5.7.32-1.el7.x86_64.rpm-bundle.tar
#yum remove mariadb-libs
#yum -y install perl-Data-Dumper
#yum -y install perl-JSON
#rpm -ivh mysql*.rpm
#service mysqld start
初始化 MySQL 数据库: [确定]
正在启动 mysqld: [确定]
#cat /var/log/mysqld.log |grep password
或
#grep 'temporary password' /var/log/mysqld.log
#mysql -uroot -p
使用得到的随机密码登录(复制生成的随机密码)
设置root密码:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'PASSWORD';
#mysql -u root -p
mysql> use mysql;
mysql> select host from user where user='root';
mysql> update user set host = '%' where user ='root';
mysql> flush privileges;
mysql> select host from user where user='root';
下载地址:MySQL :: Download MySQL Community Server (Archived Versions)https://downloads.mysql.com/archives/community/
#yum -y install gcc make pcre-devel openssl-devel
#useradd nginx
# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-stream --with-http_gzip_static_module --with-pcre
# make && make install
# ln -s /usr/local/nginx/sbin/* /usr/local/bin/
# nginx
下载地址:PHP: Downloadshttps://www.php.net/downloads
# yum -y install libxml2 libxml2-devel curl curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel zlib zlib-devel openldap openldap-devel sqlite-devel oniguruma-devel
[root@tools]# cd /tools/
[root@tools]# tar -xvf php-7.4.30.tar.gz
[root@tools]# cd php-7.4.30/
[root@tools]# useradd php -s /sbin/nologin
./configure --prefix=/usr/local/php7 --with-config-file-path=/usr/local/php7/etc --with-mhash --with-openssl --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-zlib --enable-bcmath --enable-gd --with-jpeg --with-freetype --enable-mbstring --enable-ftp --enable-sockets --with-gettext --enable-session --with-curl --enable-fpm --with-fpm-user=php --with-fpm-group=php --enable-pdo -enable-tokenizer --with-zip
上传下载好的oniguruma-6.7.0-1.el7.x86_64.rpm和oniguruma-devel-6.7.0-1.el7.x86_64.rpm
# rpm -ivh oniguruma-6.7.0-1.el7.x86_64.rpm oniguruma-devel-6.7.0-1.el7.x86_64.rpm
这里还需要手工编译安装libzip依赖包否则configure的时候会报以下错误:意思是 libzip的版本必须大于0.11 且 不能等于1.3.1或者1.7.0
下载地址:https://libzip.org/download/libzip-1.3.2.tar.gz
上传并解压源码包
# cd /tools/
# tar -xvf libzip-1.3.2.tar.gz
# cd libzip-1.3.2
# ./configure && make && make install
# export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/"
./configure --prefix=/usr/local/php7 --with-config-file-path=/usr/local/php7/etc --with-mhash --with-openssl --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-zlib --enable-bcmath --enable-gd --with-jpeg --with-freetype --enable-mbstring --enable-ftp --enable-sockets --with-gettext --enable-session --with-curl --enable-fpm --with-fpm-user=php --with-fpm-group=php --enable-pdo -enable-tokenizer --with-zip
# make && make install
# find / -name phpize //找出这个可执行文件
# cd /tools/php-7.4.30/ext/ldap
# /usr/local/php7/bin/phpize //到ldap的目录下执行该命令
# cp -frp /usr/lib64/libldap* /usr/lib/ //拷贝库文件,软链接也行
# ./configure --with-php-config=/usr/local/php7/bin/php-config
# make && make install //编译安装
记住/usr/local/php7/lib/php/extensions/no-debug-non-zts-20190902/,需要写在配置文件里。
# cp php.ini-production /usr/local/php7/etc/php.ini
# vim /usr/local/php7/etc/php.ini
增加两行内容
extension_dir = "/usr/local/php7/lib/php/extensions/no-debug-non-zts-20190902/"
extension=ldap.so //增加一行添加ldap模块
max_execution_time = 300
post_max_size = 16M
max_input_time = 300
date.timezone = Asia/Shanghai
# cd /usr/local/php7/etc/
# cp php-fpm.conf.default php-fpm.conf
# cp php-fpm.d/www.conf.default php-fpm.d/www.conf
# ln -s /usr/local/php7/bin/* /usr/local/bin
# ln -s /usr/local/php7/sbin/* /usr/local/sbin
# php -v
php-fpm是php的管理工具,默认9000端口
# php-fpm
# php -m | grep ldap
# vim /usr/local/nginx/conf/nginx.conf
location / {
root html;
index index.php index.html index.htm;
}
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 -t
# nginx -s reload
# vim /usr/local/nginx/html/index.php
phpinfo();
?>
[root]# vim /usr/local/nginx/html/index.php
$mysqli = new mysqli("localhost", "root", "PASSWORD");
if(!$mysqli) {
echo"database error";
}else{
echo"php env successful";
}
$mysqli->close();
?>
下载地址:https://www.zabbix.com/cn/download_sources#50LTS
# cd /tools/
# tar -xvf zabbix-5.0.27.tar.gz
# cd zabbix-5.0.27/
# groupadd --system zabbix
# cd /home
# mkdir -m 755 zabbix
# chown zabbix:zabbix zabbix/
# useradd --system -g zabbix -d /home/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix
# mysql -uroot -p
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> create user 'zabbix'@'localhost' identified by 'password';
mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost';
# cd /tools/zabbix-5.0.27/database/mysql/
# mysql -uzabbix -pHbis@123 zabbix < schema.sql
# mysql -uzabbix -pHbis@123 zabbix < images.sql
# mysql -uzabbix -pHbis@123 zabbix < data.sql
# yum -y install net-snmp-devel libevent-devel
# cd /tools/zabbix-5.0.27/
# ./configure --prefix=/home/zabbix/zabbix --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
# make install
# cd /home/zabbix/zabbix/
# mkdir -m 755 logs
# cd /home/
# chown -R zabbix:zabbix zabbix/
# vi /home/zabbix/zabbix/etc/zabbix_server.conf
LogFile=/home/zabbix/zabbix/logs/zabbix_server.log
PidFile=/home/zabbix/zabbix/logs/tmp/zabbix_server.pid
DBHost=127.0.0.1
DBName=zabbix
DBUser=zabbix
DBPassword=PASSWORD
DBSocket=/var/lib/mysql/mysql.sock
Timeout=10
LogSlowQueries=3000
Include=/home/zabbix/zabbix/etc/zabbix_server.conf.d/*.conf
StatsAllowedIP=127.0.0.1
Zabbix 前端是 PHP 编写的,所以必须运行在支持 PHP 的 Web 服务器上。只需要从ui路径下复制 PHP 文件到 Web 服务器的 HTML 文档目录,即可完成安装,我把整个ui目录都拷贝过去命名为zabbix
# cd /tools/zabbix-5.0.27/
# cp -r ui /usr/local/nginx/html/zabbix/
# vi /home/zabbix/zabbix/etc/zabbix_agentd.conf
PidFile=/home/zabbix/zabbix/zabbix_agentd.pid
LogFile=/home/zabbix/zabbix/logs/zabbix_agentd.log
Server=Zabbix_Server的IP
ServerActive=Zabbix_Server的IP
Hostname=Zabbix_Agent的IP
Include=/home/zabbix/zabbix/etc/zabbix_agentd.conf.d/*.conf
# cd /home/zabbix/zabbix/sbin/
# ./zabbix_server -f -c ../etc/zabbix_server.conf &
# ./zabbix_agent &
检查下端口是否正常,服务器端监听10051,客户端监听10050
# netstat -antp | grep zabbix