nginx 镜像
// 拉取镜像
[root@localhost ~]# docker pull centos
Using default tag: latest
latest: Pulling from library/centos
a1d0c7532777: Pull complete
Digest: sha256:a27fd8080b517143cbbbab9dfb7c8571c40d67d534bbdee55bd6c473f432b177
Status: Downloaded newer image for centos:latest
docker.io/library/centos:latest
// 创建容器,设置端口映射进入容器,编译安装nginx
[root@localhost ~]# docker run --name centos01 -it centos:7
Unable to find image 'centos:7' locally
7: Pulling from library/centos
2d473b07cdd5: Pull complete
Digest: sha256:9d4bcbbb213dfd745b58be38b13b996ebb5ac315fe75711bd618426a630e0987
Status: Downloaded newer image for centos:7
[root@1ea950782ea2 /]# useradd -r -M -s /sbin/nologin nginx
[root@1ea950782ea2 /]# id nginx
uid=999(nginx) gid=998(nginx) groups=998(nginx)
[root@1ea950782ea2 /]# yum -y install pcre-devel openssl openssl-devel gd-devel gcc gcc-c++
[root@1ea950782ea2 /]# mkdir -p /var/log/nginx
[root@1ea950782ea2 /]# chown -R nginx.nginx /var/log/nginx
// 另起一个终端,然后执行命令传输nginx源码包
[root@localhost ~]# docker cp /usr/src/nginx-1.18.0.tar.gz centos01:/usr/src
// 回到原来的终端,继续编译安装nginx
[root@1ea950782ea2 /]# cd /usr/src/
[root@1ea950782ea2 src]# ls
debug kernels nginx-1.18.0.tar.gz
[root@1ea950782ea2 src]# tar xf nginx-1.18.0.tar.gz
[root@1ea950782ea2 src]# ls
debug kernels nginx-1.18.0 nginx-1.18.0.tar.gz
[root@1ea950782ea2 src]# cd nginx-1.18.0
[root@1ea950782ea2 nginx-1.18.0]# ls
CHANGES LICENSE auto configure html src
CHANGES.ru README conf contrib man
[root@1ea950782ea2 nginx-1.18.0]# ./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-debug \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_image_filter_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--http-log-path=/var/log/nginx/access.log \
--error-log-path=/var/log/nginx/error.log
[root@1ea950782ea2 nginx-1.18.0]# make && make install
// 配置环境变量
[root@1ea950782ea2 nginx-1.18.0]# echo 'export PATH=/usr/local/nginx/sbin:$PATH' > /etc/profile.d/nginx.sh
[root@1ea950782ea2 nginx-1.18.0]# . /etc/profile.d/nginx.sh
// 没有ss命令,安装下列软件包
[root@1ea950782ea2 nginx-1.18.0]# yum install iproute iproute-doc
[root@1ea950782ea2 nginx-1.18.0]# nginx
[root@1ea950782ea2 nginx-1.18.0]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:80 *:*
// 配置php
[root@111c56820bfb /]# vi /usr/local/nginx/conf/ngi