(openeuler-x86)编译安装php-7.4+zabbix5.0.8(Apache+php+zabbix)

举报
QGS 发表于 2022/01/11 18:46:23 2022/01/11
【摘要】 (openeuler-x86)编译安装zabbix5.0.8

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

#yum 安装报错Error: There are no enabled repositories in "/etc/yum.repos.d", "/etc/yum/repos.d", "/etc/distro.repos.d".,解决办法
vim /etc/yum.repos.d/openEuler_x86_64.repo


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

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

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

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

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

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

#安装httpd(自带有)
yum install httpd -y
systemctl restart httpd 
#配置文件
/etc/httpd/conf/httpd.conf
/var/www/html
#浏览器访问
http://IP


编译安装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 -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

#查看运行日记
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  

安装MariaDB数据库

安装zabbix5.0.8

#安装mariaDB数据库
yum  -y install mariadb mariadb-libs mariadb-devel mariadb-server

#安装数据库,启动数据库,并开机自启
yum install mariadb-server -y
systemctl enable --now mariadb
#初始化 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/5.0/zabbix-5.0.8.tar.gz
tar -zvxf zabbix-5.0.8.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-5.0.8
#编译安装
./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
make install

#导入数据库
cd zabbix-5.0.8
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/
http://IP/zabbix/

netstat -antp | grep zabbix
浏览器:http://IP/zabbix/setup.php
#apache报错 403: forbidden,后续研究再更新
httpd -v

#编辑测试页
vim /var/www/html/index.php
chmod 755 /var/www/html/index.php

<?php
 phpinfo();
?>

#访问授权zabbix
yum install php-bcmath -y
chmod -R 755 /var/www/html/zabbix/
chmod 755 zabbix-5.0.8/*
chmod -R 755 /var/www/html/zabbix/conf/zabbix.conf.php

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

     



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

评论(0

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

全部回复

上滑加载中

设置昵称

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

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

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