ubuntu下php扩展的曲线救国计划
通过apt安装直接安装了php8.1版本,php-fpm加载不了。问题是我并不记得安装8版本的php,所以这个版本不知道是什么时候安装上的。其实出现这个问题在最开始配置jieba分词的扩展的时候就发现这个问题了,最终通过把服务器的so文件下载下来直接替换实现的。同理,这次也采用了同样的办法在虚拟机上编译了一个redis.so放到扩展目录配置php.ini实现加载。
既然这个问题解决了,顺便想到了之前后台提示的exif和imagick插件的问题,于是想着一块解决。
这个主要是为了解决姐姐的强迫症,不过由于现在的服务器没法创建快照,所以一切操作都得务必小心,免得需要把整个系统重装,那代价就高了。exif通过编译拷贝的方法解决了,但是到了imagic的时候这个办法行不通了:
obaby@h4ck:~/lnmp1.9$ sudo lnmp php-fpm restart
+-------------------------------------------+
| Manager for LNMP, Written by Licess |
+-------------------------------------------+
| https://lnmp.org |
+-------------------------------------------+
Gracefully shutting down php-fpm . done
Starting php-fpm [29-Mar-2023 21:23:31] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library 'imagick.so' (tried: /usr/local/php/lib/php/extensions/no-debug-non-zts-20190902/imagick.so (libMagickWand-6.Q16.so.6: cannot open shared object file: No such file or directory), /usr/local/php/lib/php/extensions/no-debug-non-zts-20190902/imagick.so.so (/usr/local/php/lib/php/extensions/no-debug-non-zts-20190902/imagick.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
done
看提示是缺少libMagickWand-6.Q16.so这个文件,但是搜索了一下并没有找到这个文件。本来就想放弃了,结果看了下虚拟机的日志,发现列出了php-imagic扩展的依赖:
dbuser@ubuntu:~/redis-5.2.1$ sudo apt install php7.4-imagick
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'php-imagick' instead of 'php7.4-imagick'
The following packages were automatically installed and are no longer required:
linux-headers-5.13.0-39-generic linux-headers-5.15.0-46-generic linux-hwe-5.13-headers-5.13.0-39
linux-hwe-5.15-headers-5.15.0-46 linux-image-5.13.0-39-generic linux-image-5.15.0-46-generic linux-modules-5.13.0-39-generic
linux-modules-5.15.0-46-generic linux-modules-extra-5.13.0-39-generic linux-modules-extra-5.15.0-46-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
gsfonts imagemagick-6-common libfftw3-double3 liblqr-1-0 libmagickcore-6.q16-6 libmagickwand-6.q16-6 ttf-dejavu-core
Suggested packages:
libfftw3-bin libfftw3-dev libmagickcore-6.q16-6-extra
The following NEW packages will be installed:
gsfonts imagemagick-6-common libfftw3-double3 liblqr-1-0 libmagickcore-6.q16-6 libmagickwand-6.q16-6 php-imagick
ttf-dejavu-core
0 upgraded, 8 newly installed, 0 to remove and 217 not upgraded.
Need to get 5,987 kB of archives.
After this operation, 16.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
关键是这两行:
The following additional packages will be installed:
gsfonts imagemagick-6-common libfftw3-double3 liblqr-1-0 libmagickcore-6.q16-6 libmagickwand-6.q16-6 ttf-dejavu-core
既然知道了依赖项,那么就可以直接安装这些组建了(最后一个不需要):
sudo apt install gsfonts imagemagick-6-common libfftw3-double3 liblqr-1-0 libmagickcore-6.q16-6 libmagickwand-6.q16-6
安装之后重新启用扩展的imagick扩展就ok啦:
已经找不到原有的扩展提示了,通过php探针也可以看到加载的扩展生效了:
另外说下几个网页上的方法我都失败了:
1.添加php源 sudo add-apt-repository -r ppa:jczaplicki/xenial-php74-temp
添加之后无法访问,直接删除了
2.源码编译,由于php和php-fpm版本不一致导致编译的扩展没法加载(这个和我的系统环境有关系)
3.使用虚拟机的源替换服务器源(自己探索),最终也是失败了,同样是由于php版本导致的。
obaby@h4ck:~/lnmp1.9$ sudo apt install php7.4-fpm
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
php-common : Breaks: php7.4-common but 7.4.3-4ubuntu2.18 is to be installed
E: Unable to correct problems, you have held broken packages.
obaby@h4ck:~/lnmp1.9$ sudo apt install php7.4-common
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
php-common : Breaks: php7.4-common but 7.4.3-4ubuntu2.18 is to be installed
E: Unable to correct problems, you have held broken packages.
基本错误是一环套一环,解决不了,所以最终采用了曲线救国的方式,那就是异地编译打包,本地安装配置。整体说来虽然麻烦点,但是问题是解决了。这个目前来说看来就比较ok啦,也没什么太大问题。
☆文章版权声明☆
* 网站名称:obaby@mars * 网址:https://h4ck.org.cn/ * 本文标题: 《ubuntu下php扩展的曲线救国计划》 * 本文链接:https://h4ck.org.cn/2023/03/ubuntu%e4%b8%8bphp%e6%89%a9%e5%b1%95%e7%9a%84%e6%9b%b2%e7%ba%bf%e6%95%91%e5%9b%bd%e8%ae%a1%e5%88%92/ * 转载文章请标明文章来源,原文标题以及原文链接。请遵从 《署名-非商业性使用-相同方式共享 2.5 中国大陆 (CC BY-NC-SA 2.5 CN) 》许可协议。
相关文章
- 谈谈php一句话木马的免杀
- PhpSpreadsheet_php标准输入流stdin
- Golang比php开发好在哪?
- PHP开启MySQL扩展的必要性(php开启mysql扩展)
- 开发Linux下PHP模块开发:实现程序性能最大化(linux下php模块)
- 探索Linux下查看PHP扩展的奥秘(linux查看php扩展)
- 测试Linux下PHP应用的实现(linux测试php)
- 基于MySQL的PHP留言板系统开发(php留言板mysql)
- 数据如何使用PHP在MySQL中添加数据(php添加mysql)
- 效率Linux 下 PHP 执行效率优化之路(linuxphp执行)
- PHP连接MSSQL库的方法(php链接mssql)
- 库学会使用PHP操作MSSQL类库,輕鬆完成高效工作(php操作mssql类)
- PHP操纵Redis实例:快速高效存储数据(php操作redis实例)
- 用PHP操作Oracle:实现强大的数据库能力(php支持oracle)
- MySQL与PHP的连接:实现快速数据库访问(mysql连接php)
- 深入理解PHP操作MySQL类库的精髓(php操作mysql类库)
- PHP连接MSSQL数据库:探索新的接口(php连接mssql接口)
- PHP无法连接MSSQL服务器(php 读不到mssql)
- 简便快捷:在PHP服务器上使用MSSQL(php服务器 mssql)
- 使用PHP扩展开发MSSQL应用(php扩展使用mssql)
- PHP如何连接MSSQL服务器(php怎么连mssql)
- 如何在PHP中使用MySQL数据库(mysql中php)
- 安装PHP扩展程序让网站支持Redis(安装php-redis)
- 使用PHP和XSLstylesheets转换XML文档
- php数组的指针操作实现代码
- PHP和Mysqlweb应用开发核心技术第1部分Php基础-1开始了解php
- PHP数组实例总结与说明
- php页面防重复提交方法总结
- Windows下的PHP安装pear教程