美文网首页
lumen+swoole

lumen+swoole

作者: 顶尖少爷 | 来源:发表于2019-03-28 14:27 被阅读0次
    1. php版本要求7.2+
    2. php添加 swool扩展
    3. 请使用最新扩展 2.6+
    测试2.5版本 内存溢出
    

    安装

    composer require swooletw/laravel-swoole 
    

    在bootstrap/app.php添加

    $app->register(\SwooleTW\Http\LumenServiceProvider::class);
    $app->configure('swoole_http');
    $app->configure('swoole_websocket');
    

    执行命令

    php artisan swoole:http start //开启http服务
    php artisan swoole:http stop  //停止
    php artisan swoole:http restart  //重新启动
    php artisan swoole:http reload  //重新加载,每次改完代码都需运行此命令
    php artisan swoole:http infos  //运行信息
    

    nginx 配置

    map $http_upgrade $connection_upgrade {
        default upgrade;
        ''      close;
    }
    server {
        listen 80;
        server_name *****.com;
        root  ************/public;
        index index.php;
    
        location = /index.php {
            # Ensure that there is no such file named "not_exists"
            # in your "public" directory.
            try_files /not_exists @swoole;
        }
        # any php files must not be accessed
        #location ~* \.php$ {
        #    return 404;
        #}
        location / {
            try_files $uri $uri/ @swoole;
        }
    
        location @swoole {
            set $suffix "";
    
            if ($uri = /index.php) {
                set $suffix ?$query_string;
            }
    
            proxy_set_header Host $http_host;
            proxy_set_header Scheme $scheme;
            proxy_set_header SERVER_PORT $server_port;
            proxy_set_header REMOTE_ADDR $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
    
            # IF https
            # proxy_set_header HTTPS "on";
    
            proxy_pass http://127.0.0.1:1215$suffix;
        }
    }
    

    相关文章

      网友评论

          本文标题:lumen+swoole

          本文链接:https://www.haomeiwen.com/subject/zvjzpqtx.html