ITPub博客

首页 > IT职业 > IT职场 > 制作php+swoole的Docker环境

制作php+swoole的Docker环境

IT职场 作者:mouser 时间:2021-09-09 09:40:05 0 删除 编辑
  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

    来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/3173/viewspace-2805821/ ,如需转载,请注明出处,否则将追究法律责任。

    下一篇: 神经网络
    请登录后发表评论 登录
    全部评论

    注册时间:2019-08-30

    • 博文量
      84
    • 访问量
      627