首页 > 解决方案 > 如何在 PHP7.4 中使用 inotify

问题描述

我在 PHP 7.3.x 中使用 PECL 扩展inotify没有任何问题。我更新到 PHP 7.4 但我没有成功获得inotify为构建编译的扩展,20190902因为 PECL 命令sudo pecl upgrade inotify说有

没什么可升级的

那么我怎样才能获得这个扩展呢?

标签: inotifyphp-7.4

解决方案


我通过从源代码编译它来工作。你可以在这里下载最新版本(我应该>=2.0.0相信)。

解压下载的文件.tgz,进入解压后的文件夹,然后继续执行以下命令:

phpize7.4  # this is the important command
./configure
make clean
make
make install

这将编译库20190902并将其安装在/usr/lib/php/20190902

$ ls /usr/lib/php/20190902/ | grep inotify
inotify.so

我相信你知道如何启用扩展;但如果你不这样做,首先你需要创建一个/etc/php/7.4/mods-available名为的文件,inotify.ini其中包含以下内容:extension=inotify.so为了引用 mod。所以它看起来像这样:

$ cat /etc/php/7.4/mods-available/inotify.ini 
extension=inotify.so

然后您可以在 7.4 版中为每个 SAPI 启用该 mod phpenmod -v 7.4 -s ALL inotify:. 可能然后重置php7.4-fpm等。


推荐阅读