(麒麟Linux+PHP8+KingBase)麒麟Linux系统安装PHP8及人大金仓KingBase应用

一、PHP8安装

1.1 环境

CPU内核:aarch64

OS:麒麟V10 4.19.90-23.34.v2101.ky10

Web中间件: 东方通THS/V6

php : 8.2.0

db: KingbaseES V8R6

1.2 下载

https://www.php.net/releases/

下载地址:https://www.php.net/distributions/php-8.2.0.tar.gz

1.3 解压

cd /opt
sudo tar -zxvf php-8.2.0.tar.gz   #解压
sudo mv php-8.2.0 php8  #将解压后的目录php-8.2.0 重命名为 php8
cd  php8

1.4 安装依赖

接下来的编译过程可能多多少少会遇到一些问题,基本上是缺少依赖,逐个解决就可以了,直到编译通过为止。

编译配置的时候,这里如果某些依赖包没有安装好,就会遇到很多 configure error,安装相关软件开发包即可;以下为可能需要安装的包:

yum -y install libxml2-devel
yum -y install  openssl-devel
yum -y install sqlite-devel/sqlite3-devel
yum -y install bzip2-devel
yum -y install libcurl-devel
yum -y install gmp-devel
yum -y install oniguruma-devel
yum -y install readline-devel
yum -y install libxslt-devel
yum -y install libpng-devel
yum -y install libjpeg-devel
yum -y install freetype-devel

1.5 编译前配置

如果不需要原来的 PHP 版本,可以将编译配置中以下内容修改为单个 PHP 的设置

--prefix=/usr/local/php8 替换为 --prefix=/usr/local/php

--with-config-file-path=/etc/php8 替换为 --with-config-file-path=/etc/php

./configure \
--prefix=/usr/local/php8 \
--with-config-file-path=/etc/php8 \
--enable-fpm \
--with-fpm-user=apache  \
--with-fpm-group=apache \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared  \
--enable-soap \
--with-libxml-dir \
--with-xmlrpc \
--with-openssl \
--with-mcrypt \
--with-mhash \
--with-pcre-regex \
--with-sqlite3 \
--with-zlib \
--enable-bcmath \
--with-iconv \
--with-bz2 \
--enable-calendar \
--with-curl \
--with-cdb \
--enable-dom \
--enable-exif \
--enable-fileinfo \
--enable-filter \
--with-pcre-dir \
--enable-ftp \
--enable-gd \
--with-jpeg  \
--with-gettext \
--with-freetype \
--with-openssl-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib-dir  \
--with-freetype-dir \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--with-gettext \
--with-gmp \
--with-mhash \
--enable-json \
--enable-mbstring \
--enable-mbregex \
--enable-mbregex-backtrack \
--with-libmbfl \
--with-onig \
--enable-pdo \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-zlib-dir \
--with-pdo-sqlite \
--with-readline \
--enable-session \
--enable-shmop \
--enable-simplexml \
--enable-sockets  \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-wddx \
--with-libxml-dir \
--with-xsl \
--enable-zip \
--with-zip \
--enable-mysqlnd-compression-support \
--with-pear \
--enable-opcache

**配置过程中的报错和解决办法

  1. libxml依赖错误

错误:

checking for libxml-2.0 >= 2.9.0... no

configure: error: Package requirements (libxml-2.0 >= 2.9.0) were not met:

Package 'libxml-2.0', required by 'virtual:world', not found

解决:

sudo dnf install libxml2-devel

 

  1. openssl依赖错误

错误:

checking for openssl >= 1.0.2... no

configure: error: Package requirements (openssl >= 1.0.2) were not met:

Package 'openssl', required by 'virtual:world', not found

解决:

sudo dnf install openssl-devel

 

  1. sqlite3依赖错误

错误:

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

解决:

sudo dnf install sqlite-devel

 

  1. sqlite3依赖错误

错误:

checking whether to enable bc style precision math functions... yes

checking for BZip2 support... yes

checking for BZip2 in default path... not found

configure: error: Please reinstall the BZip2 distribution

解决:

sudo dnf -y install bzip2-devel

 

  1. libcurl依赖错误

错误:

checking for libcurl >= 7.29.0... no

configure: error: Package requirements (libcurl >= 7.29.0) were not met:

Package 'libcurl', required by 'virtual:world', not found

解决:

sudo dnf -y install libcurl-devel

 

  1. gmp依赖错误

错误:

checking for __gmpz_rootrem in -lgmp... no

configure: error: GNU MP Library version 4.2 or greater required.

解决:

sudo dnf -y install gmp-devel

 

  1. oniguruma依赖错误

错误:

configure: error: Package requirements (oniguruma) were not met:

Package 'oniguruma', required by 'virtual:world', not found

解决:

sudo yum install oniguruma-devel

 

  1. readline 依赖错误

错误:

checking for libedit readline replacement... no

checking for readline support... yes

configure: error: Please reinstall readline - I cannot find readline.h

解决:

sudo yum -y install readline-devel

 

  1. libxslt 依赖错误

错误:

checking for libxslt >= 1.1.0... no

configure: error: Package requirements (libxslt >= 1.1.0) were not met:

Package 'libxslt', required by 'virtual:world', not found

解决:

sudo dnf -y install libxslt-devel

 
  1. libpng 依赖错误

错误:

checking for libpng... no

configure: error: Package requirements (libpng) were not met:

Package 'libpng', required by 'virtual:world', not found

解决:

sudo dnf -y install libpng-devel

 

  1. libjpeg 依赖错误

错误:

checking for libjpeg... no

configure: error: Package requirements (libjpeg) were not met:

Package 'libjpeg', required by 'virtual:world', not found

解决:

sudo dnf -y install libjpeg-devel

 

  1. freetype2 依赖错误

错误:

checking for freetype2... no

configure: error: Package requirements (freetype2) were not met:

Package 'freetype2', required by 'virtual:world', not found

解决:

sudo dnf -y install freetype-devel

 

  1. libzip 依赖错误

错误:

configure: error: Package requirements (libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0) were not met:

Package 'libzip', required by 'virtual:world', not found

解决:

sudo dnf -y install libzip-devel

 

1.6 编译安装

运行 make && make install 等待编译安装成功

如下为安装成功。

1.7 配置 php-fpm

mkdir /etc/php8
cp php.ini-production /etc/php8/php.ini
cp /usr/local/php8/etc/php-fpm.conf.default /usr/local/php8/etc/php-fpm.conf
cp /usr/local/php8/etc/php-fpm.d/www.conf.default /usr/local/php8/etc/php-fpm.d/www.conf
cp sapi/fpm/init.d.php-fpm /etc/init.d/php8-fpm
chmod +x /etc/init.d/php8-fpm


#如果不需要原来的 PHP 版本,可以将编译配置中以下内容修改为单个 PHP 的设置
/usr/local/php8 替换为 /usr/local/php
/etc/php8 替换为 /etc/php
php8-fpm 替换为 php-fpm

一般安装完成后 /etc/php8/这个目录是不存在的,执行以下这条复制命令会报这个错:需要创建这个php8目录

sudo cp php.ini-production /etc/php8/php.ini

cp: cannot create regular file '/etc/php8/php.ini': No such file or directory

1.8 设置php-fpm用户

#编辑文件
sudo vim /usr/local/php8/etc/php-fpm.d/www.conf

user = nginx    
group = nginx
listen = 127.0.0.1:9000

#修改为
user = apache 
group = apache
listen = 127.0.0.1:9000

1.9 启动php-fpm

/etc/init.d/php8-fpm start/stop/restart

在服务器端(东方通THS/Nginx)站点创建一个php文件info.php。打印phpinfo();

浏览器输入:http://192.168.0.100/info.php,当前的php版本是8.2。

 

#将人大金仓kingbase的php的数据库驱动文件拷贝到扩展目录下
cp pdo_kdb.so /usr/local/php8/lib/php/extensions/no-debug-non-zts-20220829/

#编辑文件,添加扩展
sudo vim /etc/php8/php.ini
extension=pdo_kdb

配置完成,重启php8-fpm

/etc/init.d/php8-fpm restart

浏览器测试打印php信息,pdo_kdb已经添加成功了。

 

posted @ 2024-07-08 09:35  柴高八斗  阅读(681)  评论(0编辑  收藏  举报