Laradock swoole加速laravel

安装 laravel swoole

laravel-swoole

composer require swooletw/laravel-swoole
php artisan vendor:publish --tag=laravel-swoole

或者 laravels

composer require hhxsv5/laravel-s
php artisan laravels publish

打开workspace 端口

在 laradock/wrokspace/Dockerfile 最后追加

EXPOSE 端口号

修改 nginx 配置

upstream swoole {
    server workspace:5200 weight=5 max_fails=3 fail_timeout=30s;
    keepalive 16;
}
server {
    listen 80;
    #listen 443 ssl http2;
    server_name shop.test;
    root /var/www/shop/public;

    index index.html index.htm index.php;

    charset utf-8;

    location / {
        try_files $uri @laravels;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/shop.test-error.log error;

    sendfile off;

    client_max_body_size 100m;
     location @laravels {
        # proxy_connect_timeout 60s;
        # proxy_send_timeout 60s;
        # proxy_read_timeout 120s;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Real-PORT $remote_port;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header Scheme $scheme;
        proxy_set_header Server-Protocol $server_protocol;
        proxy_set_header Server-Name $server_name;
        proxy_set_header Server-Addr $server_addr;
        proxy_set_header Server-Port $server_port;
        charset utf-8;
        proxy_pass http://swoole;
    }

    location ~ /\.ht {
        deny all;
    }

    #ssl_certificate     /etc/nginx/ssl/larabbs.test.crt;
    #ssl_certificate_key /etc/nginx/ssl/larabbs.test.key;
    }

修改 laravel env

SWOOLE_HTTP_HOST=workspace

其他

参考链接:CSDN

本作品采用《CC 协议》,转载必须注明作者和本文链接
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!