资讯专栏INFORMATION COLUMN

(学习到实践)一、环境搭建准备

liuchengxu / 1174人阅读

摘要:依赖准备之前编译安装时的参数编写安装脚本环境搭建使用,参考相应官网安装使用清华源安装。搭建环境初始化下载官方备用镜像制作目标是对官方安装自定义插件,参考官方安装。

1、设定目标 a.初始环境:

[注:测试主机已设置好软件源,虚拟主机默认是root用户登录]

[]:~/tmp# lsb_release -a
No LSB modules are available.
Distributor ID:    Debian
Description:    Debian GNU/Linux 9.9 (stretch)
Release:    9.9
Codename:    stretch
[]:~/tmp# 
b.目标环境:
[docker+]
    php-7.3.6
    redis-5.0.5 +主从
    memcached-1.5.16
    openresty-1.15.8.1(nginx+lua)
    mysql-8.0.16 +主从
    mongodb-4.0.10
2、前期准备 a.文件准备

(mysql选择的是debian、x64、server版)

https://www.php.net/distributions/php-7.3.6.tar.xz
http://download.redis.io/releases/redis-5.0.5.tar.gz
https://memcached.org/files/memcached-1.5.16.tar.gz
# https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-community-server-dbgsym_8.0.16-2debian9_amd64.deb
https://openresty.org/download/openresty-1.15.8.1.tar.gz
https://fastdl.mongodb.org/src/mongodb-src-r4.0.10.tar.gz

[这里是后期的注释]没用到,文章是一边写一边发的。

b.依赖准备

之前编译安装时的参数:

PHP:
apt-get install curl libxml2-dev libssl-dev libzip4 libzip-dev libbz2-dev libjpeg-dev libpng-dev libxpm-dev libfreetype6-dev libgmp-dev libgmp3-dev libcurl4-gnutls-dev librecode-dev libreadline-dev libtidy-dev libxslt1-dev -y
OpenResty:
apt-get install libpcre3-dev libssl-dev perl make build-essential curl -y
c.编写docker-ce安装脚本

环境搭建使用docker,参考相应官网:《Debian安装Docker》、《使用清华源安装docker》。准备安装脚本:

[]:~/tmp# vim docker_install.sh
#!/bin/bash
#1. 卸载旧版本
apt-get remove docker docker-engine docker.io
#2. 安装依赖
apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common -y
#3. 
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
#4. x86_64添加软件仓库
add-apt-repository "deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/debian $(lsb_release -cs) stable"
#5. 更新源并安装
apt-get update && apt-get install docker-ce -y

第一步准备完成。

3、搭建docker环境 a.初始化docker
[]:~/tmp# chmod +x docker_install.sh && ./docker_install.sh
# 下载官方备用
[]:~/tmp# docker pull php:7.3 && docker pull mysql:8.0 && docker pull redis:5.0
b.php镜像制作

目标是对官方安装自定义插件,参考官方:《alpine安装php》。

[]:~/tmp# mkdir -p dk/php
[]:~/tmp# vim dk/php/Dockerfile

# php7.3.5; Feb 7, 2019 link: https://github.com/docker-library/php/blob/master/7.3/alpine3.9/fpm/Dockerfile
# Base images 基础镜像+阿里源
FROM alpine:3.9

#MAINTAINER 维护者信息
MAINTAINER cffycls@foxmail.com

# dependencies required for running "phpize"
ENV PHP_VERSION 7.3.6
ENV PHP_URL https://secure.php.net/get/php-$PHP_VERSION.tar.xz/from/this/mirror
ENV PHPIZE_DEPS 
        autoconf 
        dpkg-dev dpkg 
        file 
        g++ 
        gcc 
        libc-dev 
        make 
        pkgconf 
        re2c

RUN sed -i "s/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g" /etc/apk/repositories 
    && apk update 
    && addgroup -g 82 -S web 
    && adduser -u 82 -D -S -G web web 
    && mkdir -p "/usr/local/etc/php/conf.d" && mkdir -p "/var/www/html" 
    && chown www-data:www-data /var/www/html && chmod 777 /var/www/html 
    && apk add --no-cache 
        ca-certificates 
        curl 
        tar 
        xz 
        openssl 
        wget 
    &&  apk add --no-cache --virtual .build-deps 
        $PHPIZE_DEPS 
        argon2-dev 
        coreutils 
        curl-dev 
        libedit-dev 
        libsodium-dev 
        libxml2-dev 
        openssl-dev 
        sqlite-dev 
        libjpeg-turbo-dev 
        libpng-dev 
        gd-dev 
        gettext-dev 
        freetype-dev 
        libxpm-dev

COPY php.tar.xz php.tar.xz
RUN set -x 
        # 下载过慢
        # && wget -O php.tar.xz "$PHP_URL" 
        && tar -Jxf php.tar.xz && cd php-$PHP_VERSION && ./configure 
        --prefix="/usr/local/php" 
        --with-config-file-path="/usr/local/php/etc" 
        --with-config-file-scan-dir="/usr/local/php/etc/conf.d" 
        
        --enable-option-checking=fatal 
        --with-mhash 
        
        --enable-ftp 
        --enable-exif 
        --enable-mbregex 
        --enable-mbstring 
        --enable-mysqlnd 
        --enable-sysvmsg 
        --enable-opcache 
        --enable-pcntl 
        --enable-sockets 
        --enable-sysvsem 
        --enable-xml 
        --with-curl 
        --with-libedit 
        --with-openssl 
        --with-zlib 
        --with-pcre-regex 
        --with-pear 
        --with-libxml-dir=/usr 
        --with-gd=/usr 
        --with-jpeg-dir 
        --with-freetype-dir 
        --with-xpm-dir 
        --with-png-dir 
        --with-gettext 
        --with-mhash 
        --with-iconv 
        --disable-fileinfo 
        
        --enable-fpm --with-fpm-user=web --with-fpm-group=www-data --disable-cgi 
    && make -j "$(nproc)" 
    && find -type f -name "*.a" -delete 
    && make install 
#    && make clean 
    && cd ../ && rm -rf php-$PHP_VERSION.tar.xz php-$PHP_VERSION

#其他插件安装,可以下载源码编译,这里使用
RUN set -x 
    # libevent
    && wget "https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz" 
        && tar -zxf libevent-2.1.8-stable.tar.gz && cd libevent-2.1.8-stable && ./configure --prefix=/usr && make && make install && cd ../ 
    && wget "http://pecl.php.net/get/event-2.4.3.tgz" && tar -zxf event-2.4.3.tgz && cd event-2.4.3 && /usr/local/php/bin/phpize 
        && ./configure --with-event-libevent-dir=/usr --with-php-config=/usr/local/php/bin/php-config && make && make install && cd ../ 
        && rm -rf libevent-2.1.8-stable.tar.gz libevent-2.1.8-stable event-2.4.3.tgz event-2.4.3 
    
    # libuuid
    && wget "http://nchc.dl.sourceforge.net/project/libuuid/libuuid-1.0.3.tar.gz" 
        && tar -zxf libuuid-1.0.3.tar.gz && cd libuuid-1.0.3 && ./configure --prefix=/usr && make && make install && cd ../ 
    && wget http://pecl.php.net/get/uuid-1.0.4.tgz && tar zxf uuid-1.0.4.tgz && cd uuid-1.0.4 && /usr/local/php/bin/phpize 
        && ./configure --with-php-config=/usr/local/php/bin/php-config && make && make install && cd ../ 
        && rm -rf libuuid-1.0.3.tar.gz libuuid-1.0.3 uuid-1.0.4.tgz uuid-1.0.4 
    
#        && wget "https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz" 
#           && tar -zxf libmemcached-1.0.18.tar.gz && cd libmemcached-1.0.18 && ./configure --prefix=/usr && make && make install && cd ../ 
#       && wget -O "http://pecl.php.net/get/memcached-3.1.3.tgz" 
#           && tar -zxf memcached-3.1.3 && cd memcached-3.1.3 && ./configure --with-event-libevent-dir=/usr --with-php-config=/usr/local/php/bin/php-config && make && make install && cd ../ 
    
    && runDeps="$( 
            scanelf --needed --nobanner --format "%n#p" --recursive /usr/local 
                | tr "," "
" 
                | sort -u 
                | awk "system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }" 
        )" 
    && apk add --no-cache $runDeps 
    
    && /usr/local/php/bin/pecl update-channels 
    # others of necessary
    && /usr/local/php/bin/pecl install igbinary swoole event uuid inotify redis 
    # memcached
    && rm -rf /tmp/pear ~/.pearrc

WORKDIR /usr/local/php/bin
[]:~/tmp# 

这里参照官方始终无法构建成功,后面继续。

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/63836.html

相关文章

  • 学习实践环境搭建准备

    摘要:依赖准备之前编译安装时的参数编写安装脚本环境搭建使用,参考相应官网安装使用清华源安装。搭建环境初始化下载官方备用镜像制作目标是对官方安装自定义插件,参考官方安装。 1、设定目标 a.初始环境: [注:测试主机已设置好软件源,虚拟主机默认是root用户登录] []:~/tmp# lsb_release -a No LSB modules are available. Distributo...

    ky0ncheng 评论0 收藏0
  • 学习实践环境搭建准备

    摘要:依赖准备之前编译安装时的参数编写安装脚本环境搭建使用,参考相应官网安装使用清华源安装。搭建环境初始化下载官方备用镜像制作目标是对官方安装自定义插件,参考官方安装。 1、设定目标 a.初始环境: [注:测试主机已设置好软件源,虚拟主机默认是root用户登录] []:~/tmp# lsb_release -a No LSB modules are available. Distributo...

    alaege 评论0 收藏0
  • (全栈学习实践环境搭建准备

    摘要:初始环境注测试主机已设置好软件源,虚拟主机默认是用户登录目标环境一前期准备文件列表选择的是版依赖准备准备环境搭建使用,参考相应官网安装使用清华源安装卸载旧版本 初始环境:[注:测试主机已设置好软件源,虚拟主机默认是root用户登录] []:~/tmp# lsb_release -a No LSB modules are available. Distributor ID: Deb...

    CocoaChina 评论0 收藏0
  • JAVA团队开发手册 - 1.环境搭建

    摘要:团队开发手册环境搭建写在前面所有公司最核心的根本就是赚钱实现老板的梦想。比如对小的公司最大的问题就是人员有限,一旦核心员工跳槽,如何招聘员工以及新来员工如何快速融入团队进行开发的问题。 JAVA团队开发手册 - 1.环境搭建 写在前面 所有公司最核心的根本就是赚钱 + 实现老板的梦想。 对于IT类技术型公司,最大的成本就是人,可以称之为知识型劳动密集型企业。 对比房地产,模糊的说,产品...

    Jason_Geng 评论0 收藏0
  • 前端学习资源

    摘要:掘金日报第四期使用怎么能不知道这些插件合集掘金日报主打分享优质深度技术内容,技术内容分前端后端产品设计工具资源和一些有趣的东西。目前已经涵盖了的相关资源链接,供大家参考与学习。 【掘金日报】第四期 使用Sublime?怎么能不知道这些 Sublime 插件合集! 掘金日报主打分享优质深度技术内容,技术内容分:前端、后端、Android、iOS、产品设计、工具资源和一些有趣的东西。 前端...

    xzavier 评论0 收藏0

发表评论

0条评论

最新活动
阅读需要支付1元查看
<