腾讯云服务器Nginx等安装和配置

云服务器配置的镜像为Ubuntu Server 18.04.1 64位

连接服务器之后输入命令

apt show nginx //查看nginx包
sudo apt update //查看更新
sudo apt upgrade //更新软件包
sudo apt install nginx -y //安装nginx

安装完成后可以直接通过服务器外网IP地址或解析的域名访问到nginx页面,如下

安装mongoDB数据库 

输入命令

sudo apt install -y mongodb-server
mongo//进入mongoDB客户端
   show dbs//显示数据库

安装git

sudo apt install -y git
   ssh-keygen//创建ssh key
   cat /home/ubuntu/.ssh/id_rsa.pub//查看sshkey

安装nodejs和npm

sudo apt install -y nodejs //安装nodejs
sudo apt install -y npm  //安装npm

安装淘宝镜像和升级nodejs

npm config set registry https://registry.npm.taobao.org //安装淘宝镜像
npm i -g nrm  //nrm 快速切换npm 镜像
nrm use taobao/npm   //切换npm
npm install  -g n //升级node
n latest //升级最新版node

 安装完成需要的插件,可以开始配置nginx

推荐使用网站 https://www.digitalocean.com/community/tools/nginx

根据需求一步一步的进行快速的配置,配置完成后将生成的配置文件放入服务器的etc/nginx目录里

然后重启nginx服务

service nginx restart

最后将编译成生产环境的项目放入服务器

使用pm2启动项目

npm install -g pm2

pm2 start index.js //进入项目目录

 

posted on 2020-03-13 15:44  ShawYoi  阅读(1347)  评论(0编辑  收藏  举报