1.
pecl install swoole
开启http2支持需要的依赖库:apt-get install nghttp2
开启的几个参数:
enable sockets supports? [no] : yes
enable openssl support? [no] : yes
enable http2 support? [no] : no
enable mysqlnd support? [no] : yes
enable postgresql coroutine client support? [no] : no
enable kernel debug/trace log? (it will degrade performance) [no] : yes
2.
php -i|grep "php.ini"可以看到php.ini的文件路径
一般php7以上会有个/etc/php/7.0/mods-available目录,在这里建立swoole.ini比较合适
写入extension=swoole.so
3.
在cli环境下,一般在这个目录/etc/php/7.0/cli/conf.d , 建立一个软连接到/etc/php/7.0/mods-available/swoole.ini
ln -s /etc/php/7.0/mods-available/swoole.ini swoole.ini ,这样是比较规范的了
php -m|grep swoole 检测扩展安装成功
<?php
$name="taoshihan";
swoole_timer_tick(500,function($timerId,$parames)use($name){
echo $timerId."==".$parames."==".$name."==".date("Y-m-d,H:i:s",time())."\n";
},"hello");
php timer.php 每500毫秒执行一次
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有