1、下载安装,直接在linux 根目录下:wget https://pecl.php.net/get/swoole-4.8.4.tgz, 再解压:tar -zxvf swoole-4.8.4.tgz 把解压后的文件夹名称改为swoole:mv swoole-4.8.4 swoole
2、执行下面的命令进行编译和安装: cd swoole && \ phpize && \ ./configure && \ make && sudo make install 3、启用扩展,php.ini 中加入一行 extension=swoole.so 来启用 Swoole 扩展
4、重启apache或者nginx服务,同时还需要重启PHP服务 service php-fpm restart service nginx restart
重启PHP服务提示:
Starting php-fpm [04-Jan-2022 14:33:27] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library ‘swoole.so’ (tried: /usr/local/php/lib/php/extensions/no-debug-non-zts-20180731/swoole.so (/usr/local/php/lib/php/extensions/no-debug-non-zts-20180731/swoole.so: cannot open shared object file: No such file or directory), /usr/local/php/lib/php/extensions/no-debug-non-zts-20180731/swoole.so.so (/usr/local/php/lib/php/extensions/no-debug-non-zts-20180731/swoole.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
大概就是说我/usr/local/php/lib/php/extensions/no-debug-non-zts-20180731目录下没这个扩展,
然后搜了搜网上好多都说什么编辑/etc/ld.so.conf添加一行/usr/local/lib,保存后执行ldconfig命令即可, 然并卵~~~~~
然后输入 find / -name swoole.so 找一下,发现在 /usr/local/php7324/lib/php/extensions/no-debug-non-zts-20180731/swoole.so有这个扩展,果断把这个swoole.so复制到/usr/local/php/lib/php/extensions/no-debug-non-zts-20180731目录下,重启php,即ok了
然后php-m 就能看到swoole了,查看phpinfo()也能看到
|