一、Docker部署
1.复制Nginx配置文件
docker pull nginx
docker run --restart=always --name=nginx -p 80:80 -p 443:443 -d nginx
mkdir /root/docker/nginx -p
docker cp nginx:/etc/nginx /root/docker/nginx/conf
docker cp nginx:/usr/share/nginx/html /root/docker/nginx/html
docker cp nginx:/var/log/nginx /root/docker/nginx/logs
mkdir /home/pre_server -p
docker stop nginx
docker rm nginx
2.启动Nginx容器
docker run --restart=always --name=nginx -p 80:80 \
-v /root/docker/nginx/conf:/etc/nginx \
-v /root/docker/nginx/html:/usr/share/nginx/html \
-v /root/docker/nginx/logs:/var/log/nginx \
-v /home/pre_server:/home/pre_server \
-d nginx
二、Arm64最新版Nginx部署
1.镜像拉取
docker pull --platform=linux/arm64 nginx:latest
docker inspect nginx:latest | grep NGINX_VERSION
docker inspect nginx:latest | grep Architecture
2.打包镜像
docker save -o nginx-arm64.tar nginx:latest && tar -czvf nginx-arm64.tar.gz nginx-arm64.tar && rm nginx-arm64.tar
3.加载镜像
tar -xzvf nginx-arm64.tar.gz && docker load -i nginx-arm64.tar
4.启动nginx
docker run --restart=always --name=nginx -p 80:80 -p 443:443 \
-v /root/docker/nginx/conf:/etc/nginx \
-v /root/docker/nginx/html:/usr/share/nginx/html \
-v /root/docker/nginx/logs:/var/log/nginx \
-v /home/pre_server:/home/pre_server \
-d nginx:latest