zoukankan      html  css  js  c++  java
  • [PHP] swoole的安装和简单使用

    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())."
    ";
    },"hello");

    php timer.php 每500毫秒执行一次

  • 相关阅读:
    Manacher-模版题poj3974 hdu3068
    拓展kmp(带注释版)
    颓の第17周
    php 递归遍历目录带缩进
    php 递归遍历目录
    php session
    apache主机配置
    php环境配置的检测方法
    php 变量
    php MVC
  • 原文地址:https://www.cnblogs.com/taoshihan/p/10029456.html
Copyright © 2011-2022 走看看