ubuntu通过apt命令快速安装指定版本的nginx
![](https://ask.qcloudimg.com/http-save/yehe-8223537/0790a34df53f3355eea0372d89c44995.png)
先安装nginx依赖的第三方包
![](https://ask.qcloudimg.com/http-save/yehe-8223537/4ebb3edc7bb5d0da6e5eebae8458b471.png)
sudo apt install curl gnupg2 ca-certificates lsb-release
![](https://ask.qcloudimg.com/http-save/yehe-8223537/1565b29657f53dd90b5d2f78b64d1cee.png)
添加nginx官方的ubuntu的apt源
echo "deb http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \
| sudo tee /etc/apt/sources.list.d/nginx.list
新增nginx apt源的密钥,并检验是否成功
curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo apt-key add -
sudo apt-key fingerprint ABF5BD827BD9BF62
4. 更新自己ubuntu系统的apt源
sudo apt update
查找nginx官网提供可安装的版本
apt-cache madison nginx
6. 以选定安装1.18.0-1~xenial版本为例
sudo apt install nginx=1.18.0-1~xenial
7.启动nginx,并查看版本
sudo nginx -c /etc/nginx/nginx.conf
nginx -V
8.nginx常用命令
sudo nginx -c /etc/nginx/nginx.conf #启动
sudo nginx -s stop #关闭
sudo nginx -s reload #修改配置文件后重新加载
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/hz/143756.html