在騰訊雲上面特價買了一個服務器,而後就想把博客遷移到本身的服務器上。html
下面是折騰的過程:前端
服務器系統:Cen他OS7,node
前端框架:Vue.jsnginx
在域名中添加一條解析記錄,記錄值是服務器的ip地址。git
利用Xshell鏈接上服務器。mongodb
// 剛開的服務器能夠更新一下yum
yun -s update複製代碼
sudo yum install nginx複製代碼
在根目錄下,新建 datawww
文件夾。shell
而後再配置nginx.conf
:centos
server {
root /data/www;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
root /data/www/blog(你的項目名字)/dist;
index index.html;
// 這裏是配置Vue-router的history模式的
try_files $uri $uri/ /index.html;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
複製代碼
由於想安裝最新的Node.js。因此我是經過下載源代碼,編譯安裝的Node.js。瀏覽器
// 下載源碼
wget https://nodejs.org/dist/v10.16.3/node-v10.16.3.tar.gz
// 解壓
tar zxvf node-v10.16.3.tar.gz
// 進入解壓目錄
cd node-v10.16.3
// 配置
./configure
// 安裝
sudo make install
// 查看版本
node -v複製代碼
curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
// 若是安裝了NOde.js,能夠跳過這一步
curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -
sudo yum install yarn
yarn --version複製代碼
經過GIt把倉庫的代碼更新到新建的 datawww
下面。我是用 Vue.js
寫的項目,因此運行:bash
git pull
yarn install
yarn build複製代碼
而後就大功告成。在瀏覽器輸入你的域名,就能夠看到你寫的頁面了。
若是想用https的能夠去看看騰訊雲的文檔。
注意:https默認端口是443,不能用80。
再安裝的過程當中可能會跟我同樣遇到說gcc版本過低的錯誤。
能夠用yum來升級gcc,目前只能升級到7.3,不過對我來講夠了。若是你想使用特定版本或者最新版的自行百度源碼編譯。
yum install centos-release-scl -y
yum install devtoolset-7 -y
scl enable devtoolset-7 bash
gcc --version
// 在centos的devtoolset庫中 最新的爲 devtoolset-7,因此咱們之後能夠本身改數字安裝最新的版本
// scl enable devtoolset-7 bash 若是使用的是zsh則使用
// scl enable devtoolset-7 zsh
// 若是不知道什麼是zsh那麼默認的就行了複製代碼
至於爲何用 Mongodb 是由於有一個免費的沙盒,有512MB大小,本身能夠隨便玩。
安裝流程請看文檔中心。
歡迎瀏覽個人我的網站