ECS云服务器 Ubuntu 18.04.4 配置

更新资源库

$ sudo apt update

安装Node

$ sudo apt-get install nodejs-legacy

安装Npm

$ sudo apt-get install npm

安装pm2

$ npm install -g pm2

安装Nginx

Nginx的软件包在Ubuntu默认软件仓库中可用。 安装非常简单,只需键入以下命令:

$ sudo apt install nginx

安装完成后,请检查Nginx服务的状态和版本:

$ sudo systemctl status nginx
状态.png
$ sudo nginx -v
# nginx version: nginx/1.14.0 (Ubuntu)

配置防火墙:

如果您正在运行防火墙,则还需要打开端口80和443。

$ sudo ufw allow 'Nginx Full'  
$ sudo ufw status # 验证更改

在线测试:

在您选择的浏览器中打开http://YOUR_IP,您应该能够看到默认的Nginx登录页面,如下所示:

localhost.png

使用systemctl管理Nginx服务:

您可以像任何其他systemd单位一样管理Nginx服务。

  • 要停止Nginx服务,请运行:
$ sudo systemctl stop nginx
  • 再次启动,请运行:
$ sudo systemctl start nginx
  • 重新启动Nginx服务,请运行:
$ sudo systemctl restart nginx
  • 配置更改后重新加载Nginx服务,请运行:
$ sudo systemctl reload nginx
  • 禁用Nginx服务在启动时启动,请运行:
$ sudo systemctl disable nginx
  • 重新启用它,请运行:
$ sudo systemctl enable nginx

你可能感兴趣的:(ECS云服务器 Ubuntu 18.04.4 配置)