获取官方PHP7.1-cli镜像,并在此基础上进行修改
修改apt源为163的源
echo "deb http://mirrors.163.com/debian/ jessie main non-free contrib" > /etc/apt/sources.list \ && echo "deb http://mirrors.163.com/debian/ jessie-updates main non-free contrib" >> /etc/apt/sources.list \ && echo "deb http://mirrors.163.com/debian/ jessie-backports main non-free contrib" >> /etc/apt/sources.list \ && echo "deb-src http://mirrors.163.com/debian/ jessie main non-free contrib" >> /etc/apt/sources.list \ && echo "deb-src http://mirrors.163.com/debian/ jessie-updates main non-free contrib" >> /etc/apt/sources.list \ && echo "deb-src http://mirrors.163.com/debian/ jessie-backports main non-free contrib" >> /etc/apt/sources.list \ && echo "deb http://mirrors.163.com/debian-security/ jessie/updates main non-free contrib" >> /etc/apt/sources.list
安装php71-redis扩展
pecl方式
pecl install -o -f redis \ && rm -rf /tmp/pear \ && echo "extension=redis.so" > /usr/local/etc/php/conf.d/redis.ini
源代码编译方式
curl -L -o /tmp/redis.tar.gz https://github.com/phpredis/phpredis/archive/3.1.6.tar.gz \ && tar xfz /tmp/redis.tar.gz \ && rm -r /tmp/redis.tar.gz \ && mv phpredis-3.1.6 /usr/src/php/ext/redis \ && docker-php-ext-install redis
安装php-igbinary扩展
pecl install -o -f igbinary \ && rm -rf /tmp/pear \ && docker-php-ext-enable igbinary
pecl方式
安装pdo_mysql扩展
docker-php-ext-install pdo_mysql
官方脚本方式(pdo_mysql依赖igbinary)
安装swoole v1.10.1
docker cp /tmp/v1.10.1.zip 5538061f5c26:/tmp/unzip /tmp/v1.10.1.zip phpize ./configure make && make install
源代码方式
完整的Dockerfile
Dockerfile
FROM php:7.1-cli COPY swoole-v1.10.1.tar.gz /tmp/ WORKDIR /usr/src/swoole RUN buildDeps='unzip wget' \ && echo "deb http://mirrors.163.com/debian/ jessie main non-free contrib" > /etc/apt/sources.list \ && echo "deb http://mirrors.163.com/debian/ jessie-updates main non-free contrib" >> /etc/apt/sources.list \ && echo "deb http://mirrors.163.com/debian/ jessie-backports main non-free contrib" >> /etc/apt/sources.list \ && echo "deb-src http://mirrors.163.com/debian/ jessie main non-free contrib" >> /etc/apt/sources.list \ && echo "deb-src http://mirrors.163.com/debian/ jessie-updates main non-free contrib" >> /etc/apt/sources.list \ && echo "deb-src http://mirrors.163.com/debian/ jessie-backports main non-free contrib" >> /etc/apt/sources.list \ && echo "deb http://mirrors.163.com/debian-security/ jessie/updates main non-free contrib" >> /etc/apt/sources.list \ && apt-get update \ && apt-get install -y $buildDeps \ #安装igbinary扩展 && pecl install -o -f igbinary \ && rm -rf /tmp/pear \ && docker-php-ext-enable igbinary \ #安装redis扩展 && pecl install -o -f redis \ && rm -rf /tmp/pear \ && docker-php-ext-enable redis \ #安装mysql扩展 && docker-php-ext-install pdo_mysql \ #安装swoole1.10.1 && tar -xzf /tmp/swoole-v1.10.1.tar.gz -C /usr/src/swoole --strip-components=1 \ && phpize \ && ./configure \ && make \ && make install \ && docker-php-ext-enable swoole \ && rm -rf /var/lib/apt/lists/* \ && rm -f /tmp/swoole-v1.10.1.tar.gz \ && rm -r /usr/src/swoole \ && apt-get purge -y --auto-remove $buildDeps WORKDIR /
作者:whisshe
链接:https://www.jianshu.com/p/d1bfe6edbb43
点击查看更多内容
为 TA 点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦