1.下载镜像

pull php 镜像

docker pull php:7.3-alpine3.8

创建容器

docker run -it --name -p 9501:9501 test php:7.3-alpine3.8 sh

2.进入容器安装swoole

下载swoole

pecl install swoole-4.3.1 # 或 pecl install swoole

开启扩展

docker-php-ext-enable swoole

查看扩展

php -m

将目前环境打包成新镜像

docker commit test swoole:4.3.1

3.创建swoole容器

docker run -it --name swoole

-p 80:80

-v /home/my/lujing:/pro

swoole:4.3.1 sh

4.设置基本目录(app)

"autoload": {

"psr-4": {

"App\": "app/"

}

}

执行composer dump-autoload映射app目录

创建一个http服务

math?formula=http%20%3D%20new%20Swoole%5CHttp%5CServer(%220.0.0.0%22%2C%2080)%3Bhttp->on('request', function (

math?formula=request%2CSwoole%5CHttp%5CResponseresponse) {

math?formula=response-%3Eend(%22%3Ch1%3Ehello%3C%2Fh1%3E%22)%3B%20%7D)%3Bhttp->start();

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐