Ali cloud Centos build Hexo detailed tutorial

This article details how to build hexo blog in Centos 7

1. Install Git

yum install -y git

Configure the user name and mailbox

git config --global user.name "你的账号"
git config --global user.email "你的邮箱"

View configuration and version

git config -l

git version

Generate ssh keys

ssh-keygen -t rsa -C "你的 github 邮箱"

Open /root/.ssh/id_rsa.pub, which will add content to the GitHub SSH Key

Try to use ssh clone your repository

git clone [email protected]:githubid/repo.git

If successful then the clone ssh set successfully

2. Install Nodejs

As used herein, mounted compressed manner

First, cd to /tmpthe directory (tmp directory used to store temporary files, the server will restart automatically cleared)

cd /tmp

Download the latest version nodejs

wget https://nodejs.org/dist/v12.16.0/node-v12.16.0-linux-x64.tar.xz

Decompression

tar xvJf node-v12.16.0-linux-x64.tar.xz

The /tmp/node-v12.16.0-linux-x64folder to the /usr/localdirectory and renamednode

mv node-v12.16.0-linux-x64 /usr/local/node

Add soft link to / bin directory

ln -s /usr/local/node/bin/node /bin/node

ln -s /usr/local/node/bin/npm /bin/npm

Configuration environment variable

echo 'export PATH=/usr/local/node/bin:$PATH' >> /etc/profile

source /etc/profile

View nodejs and npm version

node -v

npm -v

If properly displayed, the installation was successful

3. Install Hexo

Set npm source is the Taobao source

npm config set registry https://registry.npm.taobao.org

Installation hexo

npm install -g hexo-cli

View version

hexo -v

4. Create Hexo blog

Here on the blog /data/blogdirectory

Create a folder

mkdir -p /data/blog

Initialization hexo

cd /data/blog

hexo init

Page generated hexo

hexo g

At this point in the directory will generate a publicfile, which index.htmlis the blog's main page

5. Installation Nginx

As used herein, mounted compressed manner

First you need to install depend on

yum install -y gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel

Also in the /tmpdirectory, nginx download the latest version, and unzip

wget http://nginx.org/download/nginx-1.16.1.tar.gz

tar -zxvf nginx-1.16.1.tar.gz

Compile

cd nginx-1.16.1

./configure --with-http_ssl_module

--with-http_ssl_module : Configuration ssl module

After compilation, the configuration information is displayed, the default will be to install nginx /usr/local/nginx

installation

make && make install

nginx configuration files in /usr/local/nginx/confthe directory, editing nginx.conf, press the ienter INSERTmode

vi /usr/local/nginx/conf/nginx.conf

# 保存并退出
:wq

# 退出但不保存
:q!

Need to modify the monitor in the configuration file server_namedirectory and blog for your domain name, and ssl certificate directory

server {
       listen       443 ssl;

       # 修改域名或ip
       server_name  blog.tsund.cn;
       
       # 修改ssl证书目录
       ssl_certificate      /data/ssl/blog_tsund_cn/chain.crt;
       ssl_certificate_key  /data/ssl/blog_tsund_cn/key.key;

       ssl_session_cache    shared:SSL:1m;
       ssl_session_timeout  10m;

       ssl_ciphers  ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
       ssl_prefer_server_ciphers  on;
       
       # 修改博客目录
       location / {
           root   /data/blog/public;
           index  index.html index.htm;
       }
    }

Restart nginx

cd /usr/local/nginx/sbin

./nginx -s reload

# 启动 nginx
./nginx

# 关闭 nginx
./nginx -s stop

Visit the blog address, the interface appears hexo

Then, you can move to the GitHub blog server up

Published 16 original articles · won praise 31 · views 8223

Guess you like

Origin blog.csdn.net/sculpta/article/details/104380871