一. 购买云服务器 打开 腾讯云 ,选购你想要的云服务器,我感觉购买的时候选择包年包月计费会好一点。
二. Hexo 博客部署到腾讯云 1. 进入到云服务器中 登录之后可以选择密码或者秘钥,默认密码好像就是你腾讯云账号的密码。
我选择的是秘钥的登录方式,你获取秘钥的时候会在你的电脑上生成一个秘钥文件,每次登录的时候使用它就好,我觉得很方便。
2. 云服务器端配置 git ① 安装依赖库和编译工具
1 2 3 4 5 yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel yum install gcc perl-ExtUtils-MakeMaker package
② 下载 git
1 2 3 4 5 cd /usr/local/src wget https:
③ 解压编译 git
1 2 3 4 5 6 7 8 9 10 11 tar -zvxf git-2.16 .2 .tar.gz cd git-2.16 .2 make all prefix=/usr/local/git make install prefix=/usr/local/git
④ 配置 git 环境变量
1 2 3 4 5 echo 'export PATH=$PATH:/usr/local/git/bin' >> /etc/bashrc source /etc/bashrc
⑤ 查看 git 版本
⑥ 创建 git 仓库,用于存放博客网站资源。
1 2 3 4 5 6 7 8 9 mkdir /home/git/ chown -R $USER:$USER /home/git/ chmod -R 755 /home/git/ cd /home/git/ git init --bare hexoBlog.git
⑦ 创建一个新的 git 钩子,用于自动部署。
1 2 3 4 5 6 7 8 9 10 vim /home/git/hexoBlog.git/hooks/post-receive #!/bin/bash git --work-tree=/home/hexoBlog --git-dir=/home/git/hexoBlog.git checkout -f chmod +x /home/git/hexoBlog.git/hooks/post-receive
三. 云服务器端配置 Nginx 1. 安装 Nginx
2. 启动 Nginx
3. 测试 Nginx 服务器
4. 正常获取以下欢迎页面说明Nginx安装成功。 1 2 3 4 5 6 7 8 Connecting to 127.0 .0 .1 :80. .. connected. HTTP request sent, awaiting response... 200 OK Length: 43704 (43K) [text/html] Saving to: ‘index.html’ 100 %[=======================================>] 43 ,704 --.-K/s in 0s2018 -03 -09 23 :04 :09 (487 MB/s) - ‘index.html’ saved [43704 /43704 ]
5. 测试网页是否能打开 在浏览器中输入服务器 ip 地址,就是服务器的公网 ip。
6. 配置 Nginx 托管文件目录 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 mkdir /home/hexoBlog/ chown -R $USER:$USER /home/hexoBlog/ chmod -R 755 /home/hexoBlog/ nginx -t vim /etc/nginx/nginx.conf server { listen 80 default_server; listen [::]:80 default_server; root /home/hexoBlog; #需要修改 server_name _; #有个人域名可以修改 # Load configuration files for the default server block. include /etc/nginx/default .d
7. 重启 Nginx 服务
四. 修改 hexo 站点配置文件 git 相关设置 1. 打开站点配置文件 1 2 3 4 5 6 7 8 deploy: type: git repo: wwh: root@139.155 .13 .185 :/home/git/hexoBlog coding: git@e .coding.net:xiaoshitounen/xiaoshitounen.coding.me.git github: git@github .com:xiaoshitounen/xiaoshitounen.github.io.git gitee: git@gitee .com:xuxiaoshi/xuxiaoshi.git branch: master
2. 运行测试 1 2 3 4 cd 你的 hexo 目录 hexo clean hexo generate hexo deploy
① hexo d 的时候需要输入密码,我没有设置过密码,密码就是我腾讯云的密码。
② 提交结束后,在云服务器中可以看到内容的确提交上来了。
3. 打开你的公网 IP,看是不是已经部署成功了。
四. 通过 SCP 上传文件到 Linux 云服务器 ① 官方文档:Linux 系统通过 SCP 上传文件到 Linux 云服务器
② 测试的结果如下:
参考博客 Hexo 教程:Hexo 博客部署到腾讯云教程
Hexo 博客部署到腾讯云服务器全流程
在腾讯云上部署Hexo博客
用mac终端连接阿里云服务器出现permission denied