如何在docker环境下的纯净ubuntu系统中安装最新版nginx

原文件地址:

https://www.cnblogs.com/taoshihan/p/11588269.html

视频地址:

https://www.bilibili.com/video/av68984490/

笔记:

1.拉取ubuntu镜像并运行

docker pull ubuntu
docker run -it ubuntu bash

2.更新源
apt-get update

3.安装vim
apt-get install -y vim

4.先添加阿里云的源,编辑文件/etc/apt/sources.list

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

更新源

apt-get update

安装curl wget netstat telnet,这些常用的网络命令

安装netstat是下面这个命令

apt-get install net-tools 

3.添加nginx的源并安装
Ubuntu16.04

1.安装必要的包

sudo apt install curl gnupg2 ca-certificates lsb-release

2.设置apt仓库安装最新稳定版本的nginx,执行以下命令

echo "deb http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \
    | sudo tee /etc/apt/sources.list.d/nginx.list

3.导入官方签名密钥

  curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo apt-key add -

4.验证key

  sudo apt-key fingerprint ABF5BD827BD9BF62

执行后会有如下输出

  pub   rsa2048 2011-08-19 [SC] [expires: 2024-06-14]

  573B FD6B 3D8F BC64 1079  A6AB ABF5 BD82 7BD9 BF62 

  uid   [ unknown] nginx signing key <signing-key@nginx.com>

5.安装nginx

sudo apt update
sudo apt install nginx

6.启动nginx

service nginx start

posted @ 2020-02-09 10:12  HaimaBlog  阅读(444)  评论(0编辑  收藏  举报