1. 官方

参考官方: PHP: Unix 系统下的 Apache 2.x - Manual
        现在需要配置并编译 PHP。在这里可以用各种各样的参数来自定义 PHP,例如启动哪些扩展功能包的支持等。用 ./configure --help 命令可以列出当前可用的所有参数。在此例中,将给出一个在有 MySQL 支持的 Apache 2 上进行配置的范例。
        如果按照上面的说明从源代码编译了 Apache,下面的例子会正确匹配 apxs 的路径。如果通过其他方式安装了 Apache,需要相应的调整 apxs 的路径。注意,在有些发行版本中,可能将 apxs 更名为 apxs2。
cd ../php-NN
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-pdo-mysql
make
make install

        如果决定在安装后改变配置选项,只需重复最后的三步 configure,make,以及 make install,然后需要重新启动 Apache 使新模块生效。Apache 不需要重新编译。
        请注意,除非明确有提示,否则“ make install ” 命令将安装 PEAR、各种 PHP 工具诸如 phpize,并安装 PHP CLI 等等。

2. 说明

        apxs是一个为Apache HTTP服务器编译和安装扩展模块的工具,用于编译一个或多个源程序或目标代码文件为动态共享对象,使之可以用由mod_so提供的LoadModule指令在运行时加载到Apache服务器中。
        查了官网资料和网上的资料,结合自己实战,整理了本篇文档,知识点非常丰富,可惜的是升级到php8.1.6之后,zabbix 6.0.4网页报错,问题在研究处理中。

3. 实际环境

tar -zxvf  php-8.1.6.tar.gz
cd php-8.1.6
./configure --with-apxs2=/usr/bin/apxs --with-pdo-mysql
./configure --with-apxs2=/usr/bin/apxs \--prefix=/usr/local/php8 \--with-config-file-path=/usr/local/php8 \--with-config-file-scan-dir=/usr/local/php8/php.d \--enable-mysqlnd \--with-mysqli=mysqlnd \--with-pdo-mysql=mysqlnd \--enable-fpm \--with-fpm-user=apache \--with-fpm-group=apache \--with-gd \--with-iconv \--with-zlib \--enable-xml \--enable-shmop \--enable-sysvsem \--enable-inline-optimization \--enable-mbregex \--enable-mbstring \--enable-ftp \--with-openssl \--enable-pcntl \--enable-sockets \--with-xmlrpc \--with-zip \--enable-soap \--without-pear \--with-gettext \--enable-session \--with-curl \--with-jpeg=/usr/lib64 \--with-freetype=/usr/lib64 \--enable-opcache

如果按照上面编译安装,则会报警示,参数需要再核对:

configure: WARNING: unrecognized options: --with-gd, --enable-inline-optimization, --with-xmlrpc

3.1. 配置php

        安装完成后,需要配置php.ini
cp /usr/local/src/php-8.1.6/php.ini-production /usr/local/php8/
        查看版本:
[root@zabbix php8]# php -v
PHP 8.1.6 (cli) (built: May 24 2022 13:47:06) (ZTS)
Copyright (c) The PHP Group
Zend Engine v4.1.6, Copyright (c) Zend Technologies
        查看ini配置文件位置
[root@zabbix php8]# php --ini
Configuration File (php.ini) Path: /usr/local/php8
Loaded Configuration File:         /usr/local/php8/php.ini
Scan for additional .ini files in: /usr/local/php8/php.d
Additional .ini files parsed:      (none)
        查看php的模块:
[root@zabbix bin]# ./php -m
[PHP Modules]
Core
ctype
curl
date
dom
fileinfo
filter
ftp
gettext
hash
iconv
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
sqlite3
standard
sysvsem
tokenizer
xml
xmlreader
xmlwriter
zlib
[Zend Modules]

3.2. 修改php-fpm配置

cd /usr/local/php8/etc
cp php-fpm.conf.default php-fpm.conf
cd /usr/local/php8/etc/php-fpm.d
cp www.conf.default www.conf
​

启动php-fpm

php-fpm

3.3. Apache2与php的连接

        编译安装后httpd.conf文件里自动添加了如下内容(如果没有自动添加,则需要手动添加):
libphp.so的模块:
LoadModule php_module         /usr/lib64/httpd/modules/libphp.so
        执行php的程序:
AddType application/x-httpd-php .php

3.4. php与数据库的连接

        使用默认配置也可以。
使用mysqli的方式连接数据库(可能不需要)
vim /usr/local/php8/php.ini
#打开注释
extension=mysqli
#修改mysql的sock位置
mysqli.default_socket = /var/lib/mysql/mysql.sock
重启httpd

4. 过程中遇到的报错

4.1. 报错一

checking for sqlite3 >= 3.7.7... no
configure: error: Package requirements (sqlite3 >= 3.7.7) were not met:
Package 'sqlite3', required by 'virtual:world', not found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables SQLITE_CFLAGS
and SQLITE_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
        解决方法:
yum install sqlite-devel

4.2. 错误二

checking for oniguruma... no
configure: error: Package requirements (oniguruma) were not met:
Package 'oniguruma', required by 'virtual:world', not found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables ONIG_CFLAGS
and ONIG_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
        解决方法:
yum install oniguruma-devel

4.3. 错误三

[Tue May 24 14:19:09.751641 2022] [php:error] [pid 600084:tid 281470394495008] [client 10.46.18.50:32309] PHP Fatal error:  Uncaught Error: Call to undefined function bccomp() in /var/www/html/zabbix/include/db.inc.php:816\nStack trace:\n#0 /var/www/html/zabbix/include/db.inc.php(715): dbQuoteInt()\n#1 [internal function]: {closure}()\n#2 /var/www/html/zabbix/include/db.inc.php(716): array_map()\n#3 /var/www/html/zabbix/include/classes/db/DB.php(1315): dbConditionInt()\n#4 /var/www/html/zabbix/include/classes/db/DB.php(1189): DB::dbFilter()\n#5 /var/www/html/zabbix/include/classes/db/DB.php(1099): DB::applyQueryFilterOptions()\n#6 /var/www/html/zabbix/include/classes/db/DB.php(1013): DB::createSelectQueryParts()\n#7 /var/www/html/zabbix/include/classes/db/DB.php(1029): DB::makeSql()\n#8 /var/www/html/zabbix/include/classes/api/services/CUser.php(1688): DB::select()\n#9 /var/www/html/zabbix/include/classes/api/clients/CLocalApiClient.php(121): CUser->checkAuthentication()\n#10 /var/www/html/zabbix/include/classes/api/wrappers/CFrontendApiWrapper.php(97): CLocalApiClient->callMethod()\n#11 /var/www/html/zabbix/include/classes/api/wrappers/CApiWrapper.php(94): CFrontendApiWrapper->callClientMethod()\n#12 /var/www/html/zabbix/include/classes/api/wrappers/CFrontendApiWrapper.php(63): CApiWrapper->callMethod()\n#13 /var/www/html/zabbix/include/classes/api/wrappers/CApiWrapper.php(82): CFrontendApiWrapper->callMethod()\n#14 /var/www/html/zabbix/include/classes/user/CWebUser.php(99): CApiWrapper->__call()\n#15 /var/www/html/zabbix/include/classes/core/ZBase.php(464): CWebUser::checkAuthentication()\n#16 /var/www/html/zabbix/include/classes/core/ZBase.php(187): ZBase->authenticateUser()\n#17 /var/www/html/zabbix/include/config.inc.php(25): ZBase->run()\n#18 /var/www/html/zabbix/index.php(24): require_once('...')\n#19 {main}\n  thrown in /var/www/html/zabbix/include/db.inc.php on line 816
        解决方法(编译安装完成php后需要扩展模块的安装方法):
        进入PHP源码包目录下的ext/bcmath目录。
/usr/local/src/php-8.1.6/ext/bcmath
        执行phpize命令,phpize命令在PHP安装目录的bin目录下
/usr/local/php8/bin/phpize
        报了错误:
[root@zabbix bcmath]# /usr/local/php8/bin/phpize
Configuring for:
PHP Api Version:         20210902
Zend Module Api No:      20210902
Zend Extension Api No:   420210902
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
        需要安装autoconf
yum install autoconf
        重新编译安装进去
./configure --with-php-config=/usr/local/php8/bin/php-config
make && make install
        添加php.ini扩展bcmath
vim /usr/local/php8/php.ini
#添加一行
extension=bcmath
        重启httpd

4.5. 错误四

        打开网页登陆zabbix,出现报错:
Return type of CCookieSession::open($save_path, $session_name) should either be compatible with SessionHandlerInterface::open(string $path, string $name): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice [zabbix.php:22 → require_once() → ZBase->run() → ZBase->authenticateUser() → CAutoloader->loadClass() → require() → CAutoloader->loadClass() → require() in include/classes/core/CCookieSession.php:25]
Return type of CCookieSession::close() should either be compatible with SessionHandlerInterface::close(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice [zabbix.php:22 → require_once() → ZBase->run() → ZBase->authenticateUser() → CAutoloader->loadClass() → require() → CAutoloader->loadClass() → require() in include/classes/core/CCookieSession.php:25]
Return type of CCookieSession::read($session_id) should either be compatible with SessionHandlerInterface::read(string $id): string|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice [zabbix.php:22 → require_once() → ZBase->run() → ZBase->authenticateUser() → CAutoloader->loadClass() → require() → CAutoloader->loadClass() → require() in include/classes/core/CCookieSession.php:25]
Return type of CCookieSession::write($session_id, $session_data) should either be compatible with SessionHandlerInterface::write(string $id, string $data): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice [zabbix.php:22 → require_once() → ZBase->run() → ZBase->authenticateUser() → CAutoloader->loadClass() → require() → CAutoloader->loadClass() → require() in include/classes/core/CCookieSession.php:25]
Return type of CCookieSession::destroy($session_id) should either be compatible with SessionHandlerInterface::destroy(string $id): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice [zabbix.php:22 → require_once() → ZBase->run() → ZBase->authenticateUser() → CAutoloader->loadClass() → require() → CAutoloader->loadClass() → require() in include/classes/core/CCookieSession.php:25]
Return type of CCookieSession::gc($maxlifetime) should either be compatible with SessionHandlerInterface::gc(int $max_lifetime): int|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice [zabbix.php:22 → require_once() → ZBase->run() → ZBase->authenticateUser() → CAutoloader->loadClass() → require() → CAutoloader->loadClass() → require() in include/classes/core/CCookieSession.php:25]
        解决方法:
        php8.1.6适配型不好,改为php7.4.29可以解决。

4.6. 错误五

        扩展php的ldap编译时报错:
configure: error: Cannot find ldap libraries in /usr/lib.
        解决方法:
cp -frp /usr/lib64/libldap* /usr/lib/
        重新编译

4.7. 错误六

        网页执行/zabbix/setup.php时环境失败:
- PHP gd JPEG 图片格式不支持
- PHP gd FreeType不支持
        解决方法:
        重新编译gd
 /usr/local/php8/bin/phpize./configure --with-php-config=/usr/local/php8/bin/php-config --with-jpeg --with-freetype
        遇到报错:
checking for libjpeg... no
configure: error: Package requirements (libjpeg) were not met:
Package 'libjpeg', required by 'virtual:world', not found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables JPEG_CFLAGS
and JPEG_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
        解决方法:
yum install libjpeg-devel freetype-devel

银河麒麟server v10sp1编译安装php8.1.6相关推荐

  1. 2022-02-03--银河麒麟-银河麒麟v4与.netcore安装

    title categories tags abbrlink date updated 银河麒麟v4与.netcore安装 Linux 银河麒麟 .net core 1904 2022-02-03 1 ...

  2. 银河麒麟v4.0.2安装

    银河麒麟v4.0.2安装 一.下载银河麒麟系统 二.制作USB的启动镜像 三.安装银河麒麟系统 1.设置要被安装的机器bios启动模式为USB启动后,选择第一项:图形安装银河麒麟服务器操作系统 2.设 ...

  3. 【银河麒麟V10 SP2 x86安装mysql8.0.29】

    目录 前言 一.Mysql是什么? 二.在线安装步骤 1.下载Mysql8.0.29源 2.安装源文件 3.安装Mysql-8.0.29 4.启动Mysql 5.查看默认密码 6.初始化 前言 在关系 ...

  4. 快速部署银河麒麟v10 SP1并安装dm8

    目录 一.安装银河麒麟v10 SP1 二.下载DM8 三.参数配置 四.安装达梦数据库 方法一.图形化安装 方法二.命令行安装 一.安装银河麒麟v10 SP1 选择安装银河麒麟操作系统.  选择语言中 ...

  5. 银河麒麟系统Arm64 编译Gdal

    银河麒麟系统Arm64 编译Gdal GDAL 官网下载版本:我这边下载的是2.4.2 Download - GDAL documentation 拷贝到麒麟用户目录下:并解压 打开命令行:输入 ma ...

  6. 银河麒麟操作系统v10sp1安装eclipse

    前言 本文介绍银河麒麟桌面操作系统V10sp1的2203版本上安装部署eclipse集成开发环境. 1 系统信息查看 右键点击我的电脑,选择属性,进行查看系统信息 或者也可以在终端输入命令来查看系统信 ...

  7. 银河麒麟服务器操作系统V10SP2安装搭建OpenVP

    文章目录 系统环境 搭建步骤 安装OpenVPN服务端 安装Easy RSA套件 生成私钥和证书 OpenVPN服务端配置 OpenVPN客户端配置 连接测试 系统环境 一.OpenVPN服务器系统配 ...

  8. 编译安装php8,[PHP] 最新抢先编译安装PHP8.0.0 alph1以及FPM

    (麻烦各位转载请注明出处和地址:陶士涵的菜地 , 谢谢 --2020年6月28日) 所有操作需要在root用户下 本机测试案例系统信息:ubuntu 安装路径:/usr/local/php8 解压缩: ...

  9. 银河麒麟桌面操作系统v10安装QT5.12.8插件

    目录 0. 环境说明 1. 安装步骤 0. 环境说明 项目 版本 CPU 龙芯3A4000 操作系统 银河麒麟桌面操作系统v10(龙芯版) QT QT5.12.8(操作系统自带版本) 1. 安装步骤 ...

最新文章

  1. 格灵深瞳CTO邓亚峰:AI学习的三种路线
  2. Android5.0新特性:全新的动画
  3. JS 获取 鼠标 坐标
  4. 计算机视觉与深度学习 | 基于边缘与形态学的细胞检测
  5. 【完整代码】Scala AKKA实现两个Actor之间的通信代码示例
  6. 37.rust属性.txt
  7. JavaSE中Map框架学习笔记
  8. 阅读react-redux源码(六) - selectorFactory处理store更新
  9. MVC与三层架构区别
  10. PHP underlying structure
  11. 【7】测试用例设计-等价类分析法
  12. c++gdal如何在大图像中截取小图像并获取其图像信息_如何模拟不规则形状并构建几何模型
  13. 《Shell脚本学习指南》
  14. 算法设计与分析——算法分析基础
  15. md5和sha256算法的区别,哪个比较安全
  16. 找回 坚果云 的 选择性同步 功能
  17. java 京东秒杀系统_京东秒杀浪费坑位惩罚你可知道?
  18. 失焦事件触发_js中表单的聚焦失焦事件
  19. 使用opencv将16位深度图转灰度图
  20. Sun Java认证考试介绍

热门文章

  1. fastapi_No.23_事件_启动和关闭事件
  2. git pull不用每次都输入密码了。
  3. run as java application和run as Spring boot app
  4. Flutter 沉浸式状态栏
  5. Java代码实现朋友圈动态查询-数据分组查询再合并
  6. python内存机制
  7. C#点击事件缩放图片
  8. 字体个人商用构成侵权吗
  9. 大数据、云计算系统顶级架构师课程学习路线图
  10. 强化学习笔记(二)马尔可夫决策过程