windows 运行 swoole

windows 运行 swoole
1 下载docker19.03
https://download.docker.com/win/stable/Docker%20Desktop%20Installer.exe

2 docker下 安装 ubuntu镜像 [ windows 下 swoole_set_process_name会报错]
docker pull ubuntu

简单启动
docker run -it -d ubuntu /bin/bash

复杂点的启动(安装环境可以忽略 -p 映射容器端口到本机 -v 挂载本地目录到容器)
docker run -it -d -p 本机端口:容器端口 -v "本机路径":容器路径 ubuntu /bin/bash

查看容器名称
docker ps -a

进入容器
docker attach 4c3
容器名只要唯一就行, 可以打部分字符串

进入容器后更新ubuntu 源
apt-get update &&
apt-get -y install vim

修改源
cp /etc/apt/sources.list /etc/apt/sources.list.bak
vim /etc/apt/sources.list
把下面的阿里镜像覆盖sources.list
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

修改完后更新源
apt-get update
安装必要工具 net-tools 包含netstat iputils-ping 包含ping
apt-get -y install net-tools &&
apt-get -y install wget &&
apt-get -y install curl &&
apt-get -y install iputils-ping

3 ubuntu下安装php7.1
apt-get -y install software-properties-common &&
add-apt-repository ppa:ondrej/php &&
apt-get update &&
apt -y install php7.1-dev php7.1-mcrypt php7.1-cli php7.1-xml php7.1-mysql php7.1-gd php7.1-imagick php7.1-recode php7.1-tidy php7.1-xmlrpc php7.1-mbstring php7.1-curl

4 swoole扩展简单安装
mkdir -p /usr/local/tmp &&
cd /usr/local/tmp &&
wget https://pecl.php.net/get/swoole-4.5.1.tgz &&
tar zxvf swoole-4.5.1.tgz &&
cd swoole-4.5.1 &&
phpize &&
./configure &&
make && make install

5 提交安装过环境的ubuntu容器为新的镜像
另起一个命令行
docker commit 容器关键词 新的镜像名
docker images 可以查看新镜像名
按照步骤2中的方式启动新镜像

6 laravel 安装 laravel-swoole
https://hughsite.com/post/laravel-swoole-tutorial.html
假如上面laravel项目挂载在/data/www 下
启动挂载对应目录后服务
php /data/www/artisan swoole:http start

启动挂载对应目录后服务
php /data/www/artisan swoole:http start

你可能感兴趣的:(php,swoole)