在虚拟机 Ubuntu 中安装Nginx
原镜像源下载速度较慢,所以先切换到阿里的镜像源
- 进入到镜像源所在文件夹
cd /etc/apt
- 将现有的sources.list文件进行备份
sudo cp sources.list sources.list.bak
- 进入sources.list修改镜像源
进入sources.list
sudo nano /etc/apt/sources.list
打开之后ctrl+k逐行清楚(抱歉,小白不知道这里应该怎么一次清除全部),清除完之后粘贴阿里云的镜像源
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
粘贴之后按键 Ctrl+X ,会提示你是否保存,输入Y,下一个提示再敲Enter键即可成功保存并退出
- 更新镜像源
sudo apt-get update
- 此时我出现了另一个错误,如果没有遇到可以忽略
执行更新的时候提示错误如下
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 3B4FE6ACC0B21F32
百度查询说原因是因为更换三方源没有对应的key,需要直接执行如下的命令
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32
执行之后再重新更新
sudo apt-get update
- 更新之后直接进行Nginx的安装即可
sudo apt-get install nginx
中途会提示Do you want to continue? [Y/n] 输入Y回车即可
安装完成之后查询Nginx版本
nginx -v
能够查询出Nginx版本则成功,Over!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统
· 【译】Visual Studio 中新的强大生产力特性
· 2025年我用 Compose 写了一个 Todo App