Compile and install nginx

2.3.2:编译安装 nginx:
[root@86a48908bb97 yum.repos.d]# yum install -y vim wget tree lrzsz gcc gccc++ automake pcre pcre-devel zlib zlib-devel openssl openssl-devel iproute net-tools
iotop #安装基础包
[root@86a48908bb97 yum.repos.d]# cd /usr/local/src/
[root@86a48908bb97 src]# wget http://nginx.org/download/nginx-1.16.1.tar.gz
[root@86a48908bb97 src]# tar xvf nginx-1.16.1.tar.gz
[root@86a48908bb97 src]# cd nginx-1.16.1
[root@86a48908bb97 nginx-1.16.1]# ./configure --prefix=/apps/nginx --withhttp_sub_module
[root@86a48908bb97 nginx-1.16.1]# make && make install
[root@86a48908bb97 nginx-1.16.1]# cd /apps/nginx/

2.33: Close nginx background

[@ 86a48908bb97 the root Nginx] # Vim /apps/nginx/conf/nginx.conf
User Nginx;
worker_processes Auto;
daemon OFF;
[@ 86a48908bb97 the root Nginx] LN # -sv / Apps / Nginx / sbin / Nginx / usr / sbin / ng
INX # create the n-
ginx command even soft

2.3.4: Custom web interface:
[root @ 86a48908bb97 nginx] # mkdir / Apps / nginx / HTML / magedu
[root @ 86a48908bb97 nginx] # echo "magedu">
/apps/nginx/html/magedu/index.html

2.3.5: create user and authorization:
[root @ 86a48908bb97 nginx] # useradd -u 2019 nginx -s / sbin / nologin
[root @ 86a48908bb97 nginx] # chown nginx.nginx / usr / local / nginx / -R

2.3.6: Submit a mirror image of the host:
[root @ Docker-server1 ~] # Docker the commit -m "the Test nginx" 86a48908bb97 magedu nginx:? V1
sha256: fce6e69410e58b8e508c7ffd2c5ff91e59a1144847613f691fa5e80bb68efbfa

2.3.:7: starting container from its own image:
[Docker the root-server1 @ ~] RUN # Docker -d -p-CentOS-80:80 --name magedu Nginx
magedu-Nginx: V1 / usr / sbin / Nginx
8042aedec1d6412a79ac226c9289305087fc062b0087955a3a0a609c891e1122
Note: -name is the name of the specified container, -d is running in the background, -p is port mapping, jack / nginx-test image is the version xx xx xx mirrored in the warehouse, you can not add version, version without default? using the
latest, the final surface nginx command is run, i.e., from a mirror command to run a nginx, so
only the front of the / usr / local / nginx / sbin / nginx flexible connection to the / usr / sbin / nginx, the purpose is to
the system can execute this command.

2.4: Tomcat Custom Business Mirror:
Based on centos official offer, debain, ubuntu, alpine and other basic image build JDK (Java environment), and then based on JDK mirror custom build business needs tomcat image.
2.4.1: Construction JDK mirror: first base image based on the official, to produce a custom installation base image commonly used commands, then
the base image on the basis of, reproduce image JDK, Tomcat mirroring.
2.4.1.1: Custom Centos base image:

docker pull centos

mkdir

/opt/dockerfile/{web/{nginx,tomcat,jdk,apache},system/{centos,ubuntu,redhat}} -
pv

cd /opt/dockerfile/system/centos/

cat Dockerfile

Centos Base Image

FROM centos:latest
MAINTAINER zhangshijie [email protected]
RUN rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
RUN yum install -y vim wget tree lrzsz gcc gcc-c++ automake pcre pcre-devel zlib
zlib-devel openssl openssl-devel iproute net-tools iotop
RUN groupadd www -g 2019 && useradd www -u 2019 -g www #添加系统账户

cat build-command.sh # building image by script

#!/bin/bash
docker build -t centos-base:v1 .

bash build-command.sh # mirrored by a build script okay

Custom base image production process:

2.4.1.2: Building the JDK implementation of the mirror:

cd /opt/dockerfile/web/jdk/

cat Dockerfile

#JDK Base Image
FROM centos-base:v1
MAINTAINER zhangshijie “[email protected]
ADD jdk-8u212-linux-x64.tar.gz /usr/local/src/
RUN ln -sv /usr/local/src/jdk1.8.0_212 /usr/local/jdk
ADD profile /etc/profile
ENV JAVA_HOME /usr/local/jdk
ENV JRE_HOME $JAVA_HOME/jre
ENV CLASSPATH J A V A H THE M E / l i b / : JAVA_HOME/lib/: JRE_HOME/lib/
ENV PATH P A T H : PATH: JAVA_HOME/bin

Published 52 original articles · won praise 1 · views 1688

Guess you like

Origin blog.csdn.net/wx25051/article/details/104443176