1.進入終端,輸入ssh ubuntu@111.***.***.***,登錄,登錄完切換為root權限用戶,sudo -s
2.輸入pwd看目錄結構,接着執行以下命令
mkdir git cd git git clone https://github.com/creationix/nvm.git
找到.bashrc文件,用find . -name "*.bashrc" -print命令,編輯.bashrc文件在最后添加,(建議用sublime sftp插件編輯)
export NVM_NODEJS_ORG_MIRROR=https://npm.taobao.org/mirrors/node source ~/git/nvm/nvm.sh
用source .bashrc 命令使其保持生效。
3.nvm安裝node
nvm install node
安裝成功,node -v或npm -v將看到分別對應的版本號。
4.安裝nginx
要先安裝 gcc-c++ 和 libpcre3-dev
aptitude install gcc-c++ libpcre3-dev
如果提示
The program 'aptitude' is currently not installed. You can install it by typing:
apt install aptitude
那就按提示安裝aptitude
apt install aptitude
安裝再回頭安裝上面那個。
接着安裝以下(nginx的依賴模塊)
wget https://ftp.pcre.org/pub/pcre/pcre-8.36.tar.gz
wget http://prdownloads.sourceforge.net/libpng/zlib-1.2.8.tar.gz
wget https://www.openssl.org/source/openssl-1.1.0c.tar.gz
並解壓
tar -xzvf pcre-8.36.tar.gz
tar -xzvf zlib-1.2.8.tar.gz
tar -xzvf openssl-1.1.0c.tar.gz
再接着安裝nginx
wget http://nginx.org/download/nginx-1.10.2.tar.gz
tar -xzvf nginx-1.10.2.tar.gz
解壓完進入文件目錄
cd nginx-1.10.2
執行以下命令(是編譯)
./configure --prefix=/home/ubuntu/nginx --with-pcre=/home/ubuntu/pcre-8.36 --with-zlib=/home/ubuntu/zlib-1.2.8 --with-openssl=/home/ubuntu/openssl-1.1.0c --with-http_ssl_module
正式安裝
make
make install
自此,nginx安裝完畢。
5.啟動nginx,執行以下這句
/home/ubuntu/nginx/sbin/nginx
在瀏覽器打開騰訊雲分配ip地址:111.***.***.***,就可以看到nginx歡迎頁。
修改nginx配置文件,位於/home/ubuntu/nginx/conf/nginx.conf
關閉nginx,執行以下這個強制停止Nginx
pkill -9 nginx
重啟再執行
/home/ubuntu/nginx/sbin/nginx
6.將github上的代碼(node后台代碼)部署到nginx
cd git
git clone https://github.com/xxxx/xxx.git
cd xxx
npm install
7.安裝mongoDB
mkdir db
cd db
sudo apt-get install mongodb
安裝完
mongod
啟動!
8.建議
不要用node app.js,終端關了,node服務就關了,用pm2替代node
npm install -g pm2
用以下命令
pm2 start app.js 啟動node服務
pm2 list 查看node服務進程
pm2 stop 終止node服務
下載filezilla,點擊文件---->站點管理器,登陸到雲服務器上。如圖:
參考了一下文章
http://www.cnblogs.com/vajoy/p/6084079.html
http://www.jb51.net/article/54761.htm
http://blog.csdn.net/u011121046/article/details/62444025