php的docker容器中配置swoole
1.获取swoole安装包 PECL :: Package :: swoole
2.解压swoole安装包
tar –zxvf swoole-4.6.6.tar
3.将解压出来的安装包copy到php容器
docker cp /home/swoole php:/usr/src/php/ext/swoole
4.安装swoole
docker-php-ext-install swoole
5.完成安装后,查看swoole信息
php --ri swoole
laravel配置swoole
1.在 Laravel 应用中使用 Swoole 之前,先通过 Composer 安装 LaravelS 扩展包
composer require hhxsv5/laravel-s
2.运行如下 Artisan 命令相应脚本和配置文件发布到根目录下:
php artisan laravels publish
3.在.env 修改工作进程数并重启服务
LARAVELS_LISTEN_IP=0.0.0.0
LARAVELS_LISTEN_PORT=5200
LARAVELS_WORKER_NUM=4
4.启动 LaravelS
php bin/laravels start
5.通过 Supervisor 管理 LaravelS
[program:laravel-s-test]
command=php /www/wwwroot/lms/blog/bin/laravels start -i
numprocs=1
autostart=true
autorestart=true
startretries=3
user=root
redirect_stderr=true
stdout_logfile=/www/wwwroot/lms/blog/storage/logs/supervisord-stdout.log
nginx反向代理swoole使用
1.nginx.conf配置
upstream swoole {
server 172.17.0.3:5200 weight=5 max_fails=3 fail_timeout=30s;
keepalive 16;
}
?
server {
listen 80;
listen [::]:80;
server_name localhost;
root /docker/www/lmrs-2008/public;
index index.php index.html;
?
location / {
try_files $uri @laravels;
}
?
location @laravels {
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;
proxy_pass http://swoole;
}
}
|