My blog set up Hexo

Foreword


 

Recently tried to set up your own personal blog, front-end due to lack of knowledge, some after searching decided to use a simple and convenient Hexo.

My environment

  • Windows10
  • Git 2.22.0
  • Node.js 10.16.3 LTS
  • Tencent cloud CentOS 7.6 64 bit

Hexo Profile

Hexo is a fast, simple and efficient framework blog. Hexo use Markdown (or other rendering engine) analytical articles, in a few seconds, you can use beautiful themes to generate static pages.

 

first part


 

1.Hexo installation

  • Install git

  Under Windows directly into git official website to download it

  • Install Node.js

  Also, under Windows directly into Node.js official website to download, no brain to the next step

  • Installation Hexo

  Open GIt Bash

$ npm install -g hexo-cli

2. Start station

After installing Hexo, then execute the following commands HEXO will require a new file in the specified folder

HEXO the init $ <Folder> # <Folder> is the site where the folder 
$ cd <Folder> 
$ npm install

After machining, the specified file directory folder should be as follows:

.
├── _config.yml
├── package.json
├── scaffolds
├── source
|   ├── _drafts
|   └── _posts
└── themes

 Then  cd <folder>  to the specified folder  hexo s -debug  able to start the project

After a successful start in the browser we enter localhost: 4000 will be able to visit the our blog

3. Change the configuration, theme

In the root directory of the project, these documents

  • node_modules: dependencies
  • public: storing the generated page
  • Some templates generate articles: scaffolds
  • source: used to store your article
  • themes: Theme
  • _config.yml: blog profile

We can start with Hexo the theme of the site to download a theme you like, here I use ochuunn

In this topic github page has a more detailed installation guide, it will not install configurations students can also contact me

After installing the theme to start the project, you will be able to access a nice blog

 

The second part of the deployment to the server


 

1. cloud server installed git, Node.js, Hexo

After logging into the server, enter

sudo yum install git-core

After completion of input

-qO- ht wget tps: //raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | SH 
nvm install the Node
# nvm not run if it can restart the server
npm install -g hexo-cli

2. Create a git repository

Entry

mkdir /var/www/Blog/
#更改权限
chown -R $USER:$USER /var/www/Blog/
chmod -R 755 /var/www/Blog/
cd /home/
git init --bare Blog.git

 Now create an empty git repository

3. Create a git hook

In  /home/BLog.git  , the hooks have a folder. We need to create a file inside hook 

vim /home/Blog.git/hooks/post-receive

Add two lines of code in the file

#!/bin/bash
git --work-tree=/var/www/Blog --git-dir=/home/Blog.git checkout -f

Modify file permissions

chmod +x /home/Blog.git/hooks/post-receive

 4. Configuration Server Nginx

installation

yum install -y nginx

 

start up

service nginx start

 

Now we can address the public network from the browser to access the server, if you can see the welcome page so successful installation instructions Nginx

Then to modify the configuration of Nginx

vim /etc/nginx/nginx.conf
{Server 
    the listen 80 the default_server; 
    the listen [::]: 80 the default_server; 
    the root / var / WWW / Blog;     # modify
 
    server_name chenmingzhang.cn; #, then if the domain name, the domain name into
 
    # the Load Configuration File S The default for S erver . Block 
    I nclude /etc/nginx/default.d/* .conf; 
    LOCATION / { 
    } 
    error_page 404 /404.html; 
        LOCATION /40x.html = { 
    }

 Finally, restart Nginx

service nginx restart

5. Modify the local configuration

In _config.yml local project root directory, make the following changes

Deploy: 
  of the type: git 
  repo: [email protected]: / Home / hexoBlog   // xx.xx.xx.xx server address 
  branch: master

Then enter the git

npm install hexo-deployer-git --save

After installation is complete, as long as the git

hexo generate
hexo deploy

Wait for completion

You can access the blog it with public IP

 

Guess you like

Origin www.cnblogs.com/FortisCK/p/11614488.html