(openEuler21.03-x86)编译安装zabbix6.0LTS+mysql8+Apache+php-7.4

举报
QGS 发表于 2022/02/16 17:52:43 2022/02/16
【摘要】 (openEuler21.03-x86)编译安装zabbix6.0LTS+mysql8+Apache+php-7.4


#关闭防火墙和 selinux 并重启
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
systemctl disable --now firewalld

#配源
vim /etc/yum.repos.d/openEuler.repo

[OS]
name=OS
baseurl=http://repo.openeuler.org/openEuler-21.03/OS/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-21.03/OS/$basearch/RPM-GPG-KEY-openEuler

[everything]
name=everything
baseurl=http://repo.openeuler.org/openEuler-21.03/everything/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-21.03/everything/$basearch/RPM-GPG-KEY-openEuler

[EPOL]
name=EPOL
baseurl=http://repo.openeuler.org/openEuler-21.03/EPOL/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-21.03/OS/$basearch/RPM-GPG-KEY-openEuler

[debuginfo]
name=debuginfo
baseurl=http://repo.openeuler.org/openEuler-21.03/debuginfo/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-21.03/debuginfo/$basearch/RPM-GPG-KEY-openEuler

[source]
name=source
baseurl=http://repo.openeuler.org/openEuler-21.03/source/
enabled=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-21.03/source/RPM-GPG-KEY-openEuler

[update]
name=update
baseurl=http://repo.openeuler.org/openEuler-21.03/update/$basearch/
enabled=0
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-21.03/OS/$basearch/RPM-GPG-KEY-openEuler
#更新yum源
yum makecache


#安装httpd(自带有)
yum install httpd -y
systemctl restart httpd 
#配置文件
/etc/httpd/conf/httpd.conf
/var/www/html

编译安装php-7.4

#官网地址
https://www.php.net/downloads
#或国内网站
https://mirrors.sohu.com/php/

#下载php压缩包
wget https://mirrors.sohu.com/php/php-7.4.9.tar.gz

#安装依赖
yum install gcc -y
yum install openssl -y
yum install openssl-devel -y
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

#解压,编译安装
mv php-7.4.9.tar.gz /opt/
cd /opt/
tar zxvf php-7.4.9.tar.gz
useradd -s /sbin/nologin -M php
#安装目录/usr/local/php7
cd php-7.4.9
./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

#解决报错No package 'oniguruma' found 
yum  -y  install autoconf automake libtool
wget https://github.com/kkos/oniguruma/archive/v6.9.5_rev1.tar.gz
tar zxvf v6.9.5_rev1.tar.gz 
cd oniguruma-6.9.5_rev1/
./autogen.sh 
./configure --prefix=/usr --libdir=/lib64
make && make install

#解决报错No package 'libzip' found
wget https://libzip.org/download/libzip-1.3.2.tar.gz
tar xf libzip-1.3.2.tar.gz
cd libzip-1.3.2
./configure && make && make install
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/" 
#解决报错,重新编译安装php
cd php-7.4.9
./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

yum install net-tools -y
yum install psmisc -y
#配置文件改名
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
#php命令设置软链接
ln -s /usr/local/php7/bin/* /usr/local/bin
ln -s /usr/local/php7/sbin/* /usr/local/sbin
#查看php的版本
php -v
#
php-fpm
netstat -antp | grep php-fpm
#查看运行日记
tail -f /usr/local/php7/var/log/php-fpm.log

#杀死当前php进程,重启
killall php-fpm
php-fpm
netstat -antp | grep php-fpm
tail -f /usr/local/php7/var/log/php-fpm.log
netstat -tln | grep 9000
netstat -tln | grep 80

安装ldap扩展模块

#安装ldap扩展模块
cd /opt/php-7.4.9/ext/ldap
find / -name phpize
#运行phpize
/usr/local/php7/bin/phpize
#复制库文件
cp -frp /usr/lib64/libldap* /usr/lib/
#安装至/usr/local/php7/bin/php-config
./configure --with-php-config=/usr/local/php7/bin/php-config

#编译安装
make && make install

#修改参数
cd /opt/php-7.4.9/
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

max_execution_time = 300
post_max_size = 16M
max_input_time = 300
date.timezone = Asia/Shanghai  

安装mysql8.0数据库

#查看是否安装有数据库,避免mariadb和mysql数据库冲突
rpm -qa | grep -i mariadb
rpm -qa | grep -i mysql
yum -y remove mariadb-connector-c-3.0.6-7.oe1.x86_64
#查看可安装的mysql数据库
yum list mysql
yum clean all
yum makecache
#安装数据库,启动数据库,并开机自启
yum  -y install mysql mysql-libs mysql-devel mysql-server
systemctl enable mysqld.service
systemctl start mysqld.service
#初始化 mariadb 并配置 root 密码
mysql_secure_installation 

#直接回车,空
是否设置密码:y
输入设置密码:
再次输入密码:
是否移除anonymous用户:y
是否不允许root远程登录:n
是否移除test数据库:y
是否更新:y


#创建初始数据库
mysql -uroot -p

mysql> show databases;         #查看默认数据库
mysql> create database zabbix character set utf8 collate utf8_bin;   #我们的电脑自带的编码就是utf8,如下图
mysql> create user zabbix@localhost identified by 'password';    (密码可以自行修改)
mysql> grant all privileges on zabbix.* to zabbix@localhost;
mysql> flush privileges;     更新
mysql> quit;

#安装依赖
yum install -y libevent-devel net-snmp-devel
#下载压缩包,解压
wget https://cdn.zabbix.com/zabbix/sources/stable/6.0/zabbix-6.0.0.tar.gz
tar -zvxf zabbix-6.0.0.tar.gz

#创建用户组等,授权
groupadd --system zabbix
useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix
mkdir -m u=rwx,g=rwx,o= -p /usr/lib/zabbix
chown zabbix:zabbix /usr/lib/zabbix
cd zabbix-6.0.0
#同步时钟,设置系统时间与网络时间同步
yum -y install ntpdate
ntpdate 0.asia.pool.ntp.org

#编译安装
./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
make install

#导入数据库
cd zabbix-6.0.0
mysql -uzabbix -p zabbix < database/mysql/schema.sql
mysql -uzabbix -p zabbix < database/mysql/images.sql
mysql -uzabbix -p zabbix < database/mysql/data.sql

#添加数据库zabbix用户的登陆密码
vim +/DBPassword /usr/local/etc/zabbix_server.conf
DBPassword=
DBSocket=/var/lib/mysql/mysql.sock

#启动server与agentd服务
zabbix_server
zabbix_agentd
#Zabbix 前端是 PHP 编写的,所以必须运行在支持 PHP 的 Web 服务器上。需要从ui路径下复制 PHP 文件到 Web 服务器的 HTML 文档目录,完成安装,把整个ui目录都拷贝过去并命名为zabbix
cp -r ui /var/www/html/zabbix/
#Apache网页目录下编写简单的php网页,验证访问Apache的php网页
vim /var/www/html/index.php

<?php
 phpinfo();
?>

#浏览器访问
http://IP/index.php

#配置Apache解析PHP
vim /etc/httpd/conf.d/php-fpm.conf

<FilesMatch \.php$>
        SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>

#查看运行日记
find / -name zabbix_server.log
tail -f /tmp/zabbix_server.log
#修改密码,否则访问受限
vim /var/www/html/zabbix/conf/zabbix.conf.php
#登入页面
Admin密码zabbix

用户原创内容,未经允许不得转载,转载请告知作者

     


【版权声明】本文为华为云社区用户原创内容,未经允许不得转载,如需转载请自行联系原作者进行授权。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。