pull php 镜像
docker pull php:7.3-alpine3.8
创建容器
docker run -it --name test php:7.3-alpine3.8 sh
# 安装依赖的第三方包 echo http://mirrors.ustc.edu.cn/alpine/v3.7/main > /etc/apk/repositories && echo http://mirrors.ustc.edu.cn/alpine/v3.7/community >> /etc/apk/repositories apk --no-cache add autoconf gcc g++ make openssl openssl-dev #下载swoole pecl install swoole-4.3.1 #开启扩展 docker-php-ext-enable swoole #查看扩展 php -m #将目前环境打包成新镜像 docker commit test swoole:4.3.1
docker run -it --name swoole -p 80:80 -v /home/my/lujing:/pro swoole:4.3.1 sh
"autoload": { "psr-4": { "App\\": "app/" } }
执行composer dump-autoload映射app目录
$http = new Swoole\Http\Server("0.0.0.0", 80); $http->on(‘request‘, function ($request,Swoole\Http\Response $response) { $response->end("<h1>hello</h1>"); }); $http->start();
原文:https://www.cnblogs.com/8013-cmf/p/11811158.html