PHP7.4安装swoole拓展
使用yii2命令行的时候,提示:
PHP Warning 'yii\base\ErrorException' with message 'Use of undefined constant SWOOLE_BASE - assumed 'SWOOLE_BASE' (this will throw an Error in a future version of PHP)'
表示没有安装swoole拓展,需要去官网下载一下,需要注意的是如果是php 7则不能够使用最新的版本
4.8 版本需要 php-7.2 或更高版本
5.0 版本需要 php-8.0 或更高版本
可用的一个版本建议是v4.8.13:
wget https://github.com/swoole/swoole-src/archive/refs/tags/v4.8.13.tar.gz
tar zxvf v4.8.13.tar.gz
mv v4.8.13.tar.gz swoole-src-4.8.13.tar.gz
cd swoole-src-4.8.13
/usr/local/php/bin/phpize
./configure --enable-openssl --with-php-config=/usr/local/php/bin/php-config
make
执行编译安装:
----------------------------------------------------------------------
Libraries have been installed in:
/root/swoole-src-4.8.13/modules
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,--rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Build complete.
Don't forget to run 'make test'.
[root@xxxx swoole-src-4.8.13]# make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20190902/
Installing header files: /usr/local/php/include/php/
以上表示安装成功,接下来需要配置进去php.ini中:
根据php --ini
找到路径,然后在拓展中加入:
extension=swoole
wq保存即可,解决!