在腾讯云上面特价买了一个服务器,而后就想把博客迁移到本身的服务器上。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大小,本身能够随便玩。
安装流程请看文档中心。
欢迎浏览个人我的网站