因为一个项目需要用到AWS的sdk,但是每次调用AWS的时候 总是输出一个php8.0马上不再支持的提示,
所以打算把php升级到最新,顺便也把其他组件和环境都升级到最新,看看效果,于是有了下面这个情况。
宝塔的英文版本在centos下面也是各种奇怪的Bug,使用面板安装swoole扩展和mongodb扩展总是出错,所以手动编译一下扩展。
php安装
先安装php8.3,使用面板来安装 aapanel这次还可以,没有出问题。
Swoole扩展
再来安装swoole5,编译的时候Swoole的最新版本是5.1.4
Github下载地址
wget https://github.com/swoole/swoole-src/archive/v5.1.4.tar.gz
如果使用 github 下载慢,请到 pecl 进行下载
wget https://pecl.php.net/get/swoole-5.1.4.tgz
下面以Github文件为例
tar -zvxf v5.1.4.tar.gz
cd swoole-src-5.1.4/
/www/server/php/83/bin/phpize
./configure --with-php-config=/www/server/php/83/bin/php-config --enable-openssl --enable-http2
编译的时候 提示了一个错误,这个错误表明你的系统缺少 libbrotlienc
库,这是 Brotli 压缩算法的编码库。Swoole 在编译时需要这个库来支持 HTTP/2 的 HPACK 头部压缩。让我们来解决这个问题:
configure: error: Package requirements (libbrotlienc) were not met:
No package 'libbrotlienc' 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 BROTLIENC_CFLAGS
and BROTLIENC_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
使用下面的命令进行安装
sudo yum install brotli-devel
然后继续安装
#重新编译
./configure --with-php-config=/www/server/php/83/bin/php-config --enable-openssl --enable-http2
#make
sudo make && make install
编译成功会显示下面的
Build complete.
Don't forget to run 'make test'.
Installing shared extensions: /www/server/php/83/lib/php/extensions/no-debug-non-zts-20230831/
这个时候已经安装成功,需要修改 php
配置文件 php.ini
,在最后面增加如下内容:
[Swoole]
extension = /www/server/php/83/lib/php/extensions/no-debug-non-zts-20230831/swoole.so
当然也可以安装完所有的扩展后 再添加。
Mongodb扩展安装
最新的扩展是1.19.4 直接下载安装
wget https://pecl.php.net/get/mongodb-1.19.4.tgz
tar -zxvf mongodb-1.19.4.tgz
cd mongodb-1.19.4
/www/server/php/83/bin/phpize
./configure --with-php-config=/www/server/php/83/bin/php-config && make && make install
安装成功后,需要修改 php
配置文件 php.ini
,在最后面增加如下内容:
[mongo]
extension = /www/server/php/83/lib/php/extensions/no-debug-non-zts-20230831/mongodb.so
如果有什么问题的话,可以看这里 手动安装 php8.0 的 mongodb 扩展
EasySwoole skeleton安装
EasySwoole 是一款基于 Swoole Server 开发的常驻内存型的分布式 PHP 框架,EasySwoole skeleton是EasySwoole的骨架,基础功能和一些demo 都已经写好了示例。
cd /home
composer create-project easy-swoole-php/easyswoole-skeleton="3.7.1" project_name
安装的时候会出现一个错误
`[root@Server home]# composer create-project easy-swoole-php/easyswoole-skeleton="3.7.1" Cola
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Continue as root/super user [yes]? yes
Creating a "easy-swoole-php/easyswoole-skeleton=3.7.1" project at "./Cola"
Installing easy-swoole-php/easyswoole-skeleton (3.7.1)
- Downloading easy-swoole-php/easyswoole-skeleton (3.7.1)
Installing easy-swoole-php/easyswoole-skeleton (3.7.1): Extracting archive
Created project in /home/Cola
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Your lock file does not contain a compatible set of packages. Please run composer update.
Problem 1- easyswoole/task is locked to version 2.0.2 and an update of this package was not requested.
- easyswoole/task 2.0.2 requires ext-sysvmsg * -> it is missing from your system. Install or enable PHP's sysvmsg extension.
Problem 2 - easyswoole/task 2.0.2 requires ext-sysvmsg * -> it is missing from your system. Install or enable PHP's sysvmsg extension.
- easyswoole/easyswoole 3.7.1 requires easyswoole/task ^2.0 -> satisfiable by easyswoole/task[2.0.2].
- easyswoole/easyswoole is locked to version 3.7.1 and an update of this package was not requested.
To enable extensions, verify that they are enabled in your .ini files: - /www/server/php/83/etc/php-cli.ini
You can also run php --ini in a terminal to see which files are used by PHP in CLI mode.
Alternatively, you can run Composer with --ignore-platform-req=ext-sysvmsg to temporarily ignore these required extensions.`
出现这个错误的原因,是安装 EasySwoole 时遇到了一些问题。主要问题是缺少 sysvmsg
PHP 扩展。使用aapanel的php的控制面板 安装 sysvmsg
, 但是 安装完了以后,依旧会出现这个问题,不知道为什么。
使用 下面的命令,跳过这个错误。
composer update --ignore-platform-req=ext-sysvmsg
总有奇葩的问题,如果是这样的话 就可以正常安装
extension = zip.so
extension = /www/server/php/83/lib/php/extensions/no-debug-non-zts-20230831/igbinary.so
[redis]
extension = /www/server/php/83/lib/php/extensions/no-debug-non-zts-20230831/redis.so
extension = /www/server/php/83/lib/php/extensions/no-debug-non-zts-20230831/sysvmsg.so
[mongo]
extension = /www/server/php/83/lib/php/extensions/no-debug-non-zts-20230831/mongodb.so
[swoole]
extension = /www/server/php/83/lib/php/extensions/no-debug-non-zts-20230831/swoole.so
具体原因不知道,反正 这样的顺序就可以正常安装EasySwoole skeleton,不会报错。