Laradock swoole加速laravel

Laravel框架
441
0
0
2022-04-18

安装 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