docker和nginx安装命令

本文介绍如何在CentOS上使用阿里云镜像安装指定版本的Docker及Docker Compose,并提供了Nginx从下载到配置的完整过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

docker

#!/bin/bash

# need by yum-config-manager
if [ -z "$(rpm -qa | grep yum-utils)" ]; then
    yum install -y yum-utils
fi

# help blog https://developer.aliyun.com/mirror/docker-ce
sudo yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

sudo yum makecache fast

sudo yum -y install docker-ce docker-compose

# 安装指定版本的Docker-CE:
# Step 1: 查找Docker-CE的版本:
# yum list docker-ce.x86_64 --showduplicates | sort -r
#   Loading mirror speeds from cached hostfile
#   Loaded plugins: branch, fastestmirror, langpacks
#   docker-ce.x86_64            17.03.1.ce-1.el7.centos            docker-ce-stable
#   docker-ce.x86_64            17.03.1.ce-1.el7.centos            @docker-ce-stable
#   docker-ce.x86_64            17.03.0.ce-1.el7.centos            docker-ce-stable
#   Available Packages
# Step2: 安装指定版本的Docker-CE: (VERSION例如上面的17.03.0.ce.1-1.el7.centos)
# sudo yum -y install docker-ce-[VERSION]

nginx

#!/bin/bash

nginx_name="nginx-1.18.0.tar.gz"

if [ -z "$(rpm -qa | grep wget)" ]; then
    yum install -y wget
fi

wget -c http://nginx.org/download/${nginx_name}

tar -zxf ${nginx_name}

cd ${nginx_name%%.tar.gz}

# install some need library
yum install -y openssl-devel    # for https model

./configure \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_auth_request_module \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/run/nginx/nginx.lock \
--error-log-path=/var/log/nginx/error.log

make

make install

echo "Check whether nginx default config contain aliyun setting?"
grep -rn -A 3 -B 2 "listen 3000" /usr/local/nginx/conf/nginx.conf

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值