• docker制作cenos+php56+nginx镜像


    首先你环境要安装好docker

     1 获取centos镜像。

    docker search centos
    

     选取第一个官方镜像。

    docker pull  docker.io/centos
    

     

     新建镜像挂载目录,放入php56 nginx 以及php的redis扩展源码。

     2 启动镜像。

     docker run -v /root/php56:/root/php56 --name centos-php56-nginx docker.io/centos tailf /etc/hosts
    

     启动后终端会挂起,我们再开一个终端,查看镜像启动情况。

     说明镜像启动成功

     进入容器:

    docker exec -it  centos-php56-nginx  /bin/bash
    

     目录也映射成功。

     解压各个源码包,解压zip是发现没有安装unzip

     安装unzip

    yum install unzip
    

     再次尝试解压,成功。

    安装php依赖包

    yum install -y autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libpng libpng-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel curl curl-devel gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp-devel readline-devel libxslt-devel expat-devel
    

    进入php源码目录

    ./configure --prefix=/usr/local/webserver/php/  --localstatedir=/usr/local/var --sysconfdir=/usr/local/webserver/php/ --with-config-file-path=/usr/local/webserver/php/ --with-config-file-scan-dir=/usr/local/webserver/php/etc/ --with-pear=/usr/local/webserver/php/pear --enable-bcmath --enable-calendar --enable-dba --enable-exif --enable-ftp --enable-fpm --enable-intl --enable-mbregex --enable-mbstring --enable-mysqlnd --enable-pcntl --enable-phpdbg --enable-shmop --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm  --enable-zip  --with-curl --with-fpm-user=_www --with-fpm-group=_www --with-freetype-dir=/usr/local/webserver/freetype --with-gd --with-gettext=/usr/local/webserver/gettext  --with-jpeg-dir=/usr/local/webserver/jpeg    --with-mcrypt --with-mhash --with-mysqli=mysqlnd --with-mysql=mysqlnd  --with-openssl  --with-pdo-mysql=mysqlnd  --with-pic --with-png-dir=/usr/local/webserver/libpng  --with-xmlrpc
    

    报错 configure: error: no acceptable C compiler found in $PATH

    yum install gcc
    

     报错

    configure: error: Cannot find OpenSSL's <evp.h>

    yum install openssl openssl-devel libmcrypt
    

    报错

    configure: error: Unable to detect ICU prefix or no failed. Please verify ICU install prefix and make sure icu-config works.

    yum install -y libicu-devel
    

     报错

    configure: error: C++ preprocessor "/lib/cpp" fails sanity check

    yum -y install gcc+ gcc-c++
    

    报错

    configure: error: mcrypt.h not found. Please reinstall libmcrypt.

    https://www.cnblogs.com/achengmu/p/9312019.html

    指定,mcrypt 目录

    ./configure --prefix=/usr/local/webserver/php/  --localstatedir=/usr/local/var --sysconfdir=/usr/local/webserver/php/ --with-config-file-path=/usr/local/webserver/php/ --with-config-file-scan-dir=/usr/local/webserver/php/etc/ --with-pear=/usr/local/webserver/php/pear --enable-bcmath --enable-calendar --enable-dba --enable-exif --enable-ftp --enable-fpm --enable-intl --enable-mbregex --enable-mbstring --enable-mysqlnd --enable-pcntl --enable-phpdbg --enable-shmop --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm  --enable-zip  --with-curl --with-fpm-user=_www --with-fpm-group=_www --with-freetype-dir=/usr/local/webserver/freetype --with-gd --with-gettext=/usr/local/webserver/gettext  --with-jpeg-dir=/usr/local/webserver/jpeg    --with-mcrypt=/usr/local/libmcrypt --with-mhash --with-mysqli=mysqlnd --with-mysql=mysqlnd  --with-openssl  --with-pdo-mysql=mysqlnd  --with-pic --with-png-dir=/usr/local/webserver/libpng  --with-xmlrpc
    

     通过

    make && make install
    

     

     安装PHP redis 扩展

     cd /root/php56/phpredis-develop/
    
    /usr/local/webserver/php/bin/phpize
    
    ./configure --with-php-config=/usr/local/webserver/php/bin/php-config 
    

     3 安装nginx

     进入nginx源码目录

    ./configure --prefix=/usr/local/webserver/nginx
    
    make && make install
    

     启动

     /usr/local/webserver/nginx/sbin/nginx
    

     

     制作完成,查看容器id.

    docker ps -a
    

     

    将此容器存储为镜像

    docker commit -m 'php5.6.39 phpredis nginx1.14.2' 121e08887e3d centos-php56-nginx:v1.0
    

     启动测试

    docker run  -d  centos-php56-nginx:v1.0 tailf /etc/hosts
    

    正式启动时要将php.ini和nginx配置文件映射至容器的 /usr/local/webserver/ 目录中

  • 相关阅读:
    HDU 1286(欧拉函数||筛选法)
    因数打表(HDU1215)
    HDU 1003
    T行数据跟着N个数据
    15校赛
    HDU 1002
    简单大数相加
    (质因子打表记录素数的位置)HDU Largest prime factor
    HDU cake
    【转】 cin、cin.get()、cin.getline()、getline()、gets()等函数的用法
  • 原文地址:https://www.cnblogs.com/kala00k/p/11563800.html
Copyright © 2020-2023  润新知