栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > PHP

制作php+swoole的Docker环境

PHP 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

制作php+swoole的Docker环境

  1. 获取官方PHP7.1-cli镜像,并在此基础上进行修改

  2. 修改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
  1. 安装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
  1. 安装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

    转载请注明:文章转载自 www.mshxw.com
    本文地址:https://www.mshxw.com/it/227030.html
    我们一直用心在做
    关于我们 文章归档 网站地图 联系我们

    版权所有 (c)2021-2022 MSHXW.COM

    ICP备案号:晋ICP备2021003244-6号