騰訊雲服務器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 //進入項目目錄

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM