一、下载Nginx Key
wget http://nginx.org/keys/nginx_signing.key
二、apt添加key
apt-key add nginx_signing.key
三、需要添加Nginx源
sed -i '$a deb http://nginx.org/packages/ubuntu/ xenial nginx' /etc/apt/sources.list
sed -i '$a deb-src http://nginx.org/packages/ubuntu/ xenial nginx' /etc/apt/sources.list
四、更新Nginx源
apt update
五、安装
apt install nginx
六、查看Nginx是否安装成功
nginx -v
七、重启Nginx服务
/etc/init.d/nginx restart
八、外网访问
http://当前主机IP
注意:防火墙开启状态,需要对外网开放80端口