1. 下载nginx的apt程序签名认证key文件,下载地址:http://nginx.org/keys/nginx_signing.key,添加key文件到apt程序,
sudo apt-key add nginx_signing.key
2. 修改apt源配置文件/etc/apt/sources.list文件,在该文件中添加一下两行代码,
deb http://nginx.org/packages/ubuntu/ codename nginx deb-src http://nginx.org/packages/ubuntu/ codename nginx
【codename】参考:
Version | Codename | Supported Platforms |
12.04 | precise | x86_64, i386 |
14.04 | trusty | x86_64, i386, aarch64/arm64 |
16.04 | xenial | x86_64, i386, ppc64el |
3. 通过apt安装nginx,
apt-get update apt-get install nginx
4. 启动nginx: sudo nginx, 浏览器访问http://localhost/