Giter VIP home page Giter VIP logo

hexo-service-cli's Introduction

Hexo-service-cli

自动部署hexo博客站点

效果预览:ithen.cn

Hexo在私有服务器自动部署指南

前置工作

本地电脑生成ssh密钥

# -C 设置注释文字,比如你的邮箱
ssh-keygen -t rsa -C  '[email protected]'

# 查看公钥
cat ~/.ssh/id_rsa.pub

服务器配置

使用ssh登录服务器,然后执行以下命令:

su
git clone https://github.com/urnotzane/hexo-service-cli.git

cd hexo-service-cli
# 执行安装程序
sh +x ./install.sh

根据脚本步骤进行配置,在ssh公钥步骤中输入前置工作生成的公钥内容: hexo-service-cli.png

当输出服务器端Hexo已配置完成!时配置服务器成功。

配置Nginx

  1. 安装
sudo apt install nginx

若输入nginx -V可以看到nginx版本信息,则安装成功。

  1. 配置nginx
vim /etc/nginx/conf.d/blog.conf

输入:

# blog.conf
server {
  # 默认端口
  listen 80 default_server;
  # 若是https,还要加下面一行
  # listen 443 ssl http2;
  # 站点根目录
  root /var/blog;
  # 首页
  index index.htm index.html index.php;
  # 域名
  server_name ithen.cn  www.ithen.cn;
  # nginx用来路由的入口
  location / {
    try_files $uri $uri/ /index.html;
  }
}
  1. 设置开机启动nginx
chkconfig nginx on
# 启动nginx
service nginx start

其他关于nginx的命令

# 查看服务器状态
service nginx status
# 关闭服务器
service nginx stop
# 重启服务器
service nginx restart

创建Hexo项目

  1. 安装

npm install hexo-cli -g 2. 初始化

hexo init hexo-project
cd hexo-project
# 安装依赖
npm install
# 本地查看网站
hexo server
  1. 配置Hexo 打开Hexo项目根目录下的_config.yml文件,找到最后的deploy配置,修改为:
deploy:
- type: git
  repo: git@V服务器的IP:/home/${`服务器配置步骤`用户名}/blog.git
  branch: master
# 还可以同时部署到github
-type: git
  repo: [email protected]:xxxx/xxxx.github.io.git
  branch: master  

现在,使用命令hexo d就可以将网站部署到配置好的服务器上了。

常用Hexo命令

# 新建文章
hexo new <title>
# 清除缓存文件db.json和已生成的静态文件public
hexo clean
# 生成静态文件
hexo generate
# 本地运行服务器
hexo server
# 部署网站
hexo deploy

完结

hexo-service-cli's People

Contributors

urnotzane avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.