当前位置: 首页 > Linux

(边学边练)1.环境搭建准备

时间:2023-04-06 22:35:08 Linux

1.设定目标A.初始环境:【注:测试主机已设置好软件源,默认虚拟主机为root用户登录】[]:~/tmp#lsb_release-a没有可用的LSB模块。发行商ID:Debian描述:DebianGNU/Linux9.9(stretch)发行版:9.9代号:stretch[]:~/tmp#b.目标环境:[docker+]php-7.3.6redis-5.0。5+主从memcached-1.5.16openresty-1.15.8.1(nginx+lua)mysql-8.0.16+主从mongodb-4.0.102,前期准备a.文件准备(mysql选择debian,x64,服务器版本)https://www.php.net/distributions/php-7.3.6.tar.xzhttp://download.redis.io/releases/redis-5.0.5.tar.gzhttps://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.debhttps://openresty.org/download/openresty-1.15.8.1.tar.gzhttps://fastdl.mongodb.org/src/mongodb-src-r4.0.10.tar.gz[这是帖子note]没用过,文章写好了贴出来。b.取决于编译安装前准备时的参数:PHP:apt-getinstallcurllibxml2-devlibssl-devlibzip4libzip-devlibbz2-devlibjpeg-devlibpng-devlibxpm-devlibfreetype6-devlibgmp-devlibgmp3-devlibcurl4-gnutls-devlibrecode-devlibreadline-devlibtidy-devlibxslt1-dev-yOpenResty:apt-getinstalllibpcre3-devlibssl-devperlmakebuild-essentialcurl-yc。使用docker编写docker-ce安装脚本环境搭建,参考对应官网:《Debian安装Docker》、《使用清华源安装docker》。准备安装脚本:[]:~/tmp#vimdocker_install.sh#!/bin/bash#1。卸载旧版本apt-getremovedockerdocker-enginedocker.io#2。安装依赖apt-getinstallapt-transport-httpsca-certificatescurlgnupg2software-properties-common-y#3.curl-fsSLhttps://download.docker.com/linux/debian/gpg|sudoapt-keyadd-#4.x86_64添加软件仓库add-apt-repository"deb[arch=amd64]https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/debian$(lsb_release-cs)稳定”#5.更新源并安装apt-getupdate&&apt-getinstalldocker-ce-y第一步准备完成。3.搭建docker环境初始化docker[]:~/tmp#chmod+xdocker_install.sh&&./docker_install.sh#下载官方备份[]:~/tmp#dockerpullphp:7.3&&dockerpullmysql:8.0&&dockerpullredis:5.0b.php镜像制作目标为官方安装自定义插件,参考官方:《alpine安装php》。[]:~/tmp#mkdir-pdk/php[]:~/tmp#vimdk/php/Dockerfile#php7.3.5;2019年2月7日链接:https://github.com/docker-library/php/blob/master/7.3/alpine3.9/fpm/Dockerfile#Baseimages基础镜像+阿里源FROMalpine:3.9#MAINTAINER维护者信息MAINTAINERcffycls@foxmail.com#运行“phpize”所需的依赖项ENVPHP_VERSION7.3.6ENVPHP_URLhttps://secure.php.net/get/php-$PHP_VERSION.tar.xz/from/this/mirrorENVPHPIZE_DEPS\autoconf\dpkg-devdpkg\file\g++\gcc\libc-dev\make\pkgconf\re2cRUNsed-i's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g'/etc/apk/repositories\&&apk更新\&&addgroup-g82-Sweb\&&adduser-u82-D-S-Gwebweb\&&mkdir-p"/usr/local/etc/php/conf.d"&&mkdir-p"/var/www/html"\&&chownwww-data:www-data/var/www/html&&chmod777/var/www/html\&&apkadd--no-cache\ca-certificates\curl\tar\xz\openssl\wget\&&apkadd--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-devCOPYphp.tar.xzphp.tar.xzRUN设置-x\#下载过慢#&&wget-Ophp.tar.xz"$PHP_URL"\&&tar-Jxfphp.tar.xz&&cdphp-$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-typef-name'*.a'-delete\&&makeinstall\#&&makeclean\&&cd../&&rm-rfphp-$PHP_VERSION.tar.xzphp-$PHP_VERSION#其他插件安装,可以下载源码编译,这里使用RUNset-x\#libevent&&wget"https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz"\&&tar-zxflibevent-2.1.8-stable.tar.gz&&cdlibevent-2.1.8-stable&&./configure--prefix=/usr&&make&&makeinstall&&cd../\&&wget"http://pecl.php.net/get/event-2.4.3.tgz"&&tar-zxfevent-2.4.3.tgz&&cdevent-2.4.3&&/usr/local/php/bin/phpize\&&./configure--with-event-libevent-dir=/usr--with-php-config=/usr/local/php/bin/php-config&&make&&makeinstall&&cd../\&&rm-rflibevent-2.1.8-stable.tar.gzlibevent-2.1.8-stableevent-2.4.3.tgzevent-2.4.3\\#libuuid&&wget"http://nchc.dl.sourceforge.net/project/libuuid/libuuid-1.0.3.tar.gz"\&&tar-zxflibuuid-1.0.3.tar.gz&&cdlibuuid-1.0.3&&./configure--prefix=/usr&&make&&makeinstall&&cd../\&&wgethttp://pecl.php.net/get/uuid-1.0.4.tgz&&tarzxfuuid-1.0.4.tgz&&cduuid-1.0.4&&/usr/local/php/bin/phpize\&&./configure--with-php-config=/usr/local/php/bin/php-config&&make&&makeinstall&&cd../\&&rm-rflibuuid-1.0.3.tar.gzlibuuid-1.0.3uuid-1.0.4.tgzuuid-1.0.4\\#&&wget"https://launchpad.net/libmemcached/1.0/1.0.18/+下载/libmemcached-1.0.18.tar.gz"\#&&tar-zxflibmemcached-1.0.18.tar.gz&&cdlibmemcached-1.0.18&&./configure--prefix=/usr&&make&&makeinstall&&cd../\#&&wget-O"http://pecl.php.net/get/memcached-3.1.3.tgz"\#&&tar-zxfmemcached-3.1.3&&cdmemcached-3.1.3&&./configure--with-event-libevent-dir=/usr--with-php-config=/usr/local/php/bin/php-config&&make&&makeinstall&&cd../\\&&runDeps="$(\scanelf--needed--nobanner--format'%n#p'--recursive/usr/local\|tr',''\n'\|sort-u\|awk'system("[-e/usr/local/lib/"$1"]")==0{next}{print"so:"$1}'\)"\&&apkadd--no-cache$runDeps\\&&/usr/local/php/bin/peclupdate-channels\#其他必要的&&/usr/local/php/bin/peclinstalligbinaryswooleeventuuidinotifyredis\#memcached&&rm-rf/tmp/pear~/.pearrcWORKDIR/usr/local/php/bin[]:~/tmp#这里参考官网,不能构建成功,后面继续