Alibaba Cloud host builds hexo blog

Purchase ECS server

Cloud host purchase address: click here. It is recommended to buy at the event is more cost-effective.

Note: I bought the centos system host here

Configure instance security policy

Note: You need to find the security group of the cloud host to configure it. It is not enabled by default, otherwise you cannot access port 80.

Purchase a domain name

Later, we need to record the domain name (recording time 14-20), and then bind the IP address of the cloud host we have bought

Here we buy domain name can go to Wanwang to buy

node.js installation

Official website address: http://nodejs.cn/download/

## Download node
 mkdir / soft / hexo- p
 wget https: // npm.taobao.org/mirrors/node/v12.16.1/node-v12.16.1-linux-x64.tar.xz 
## unzip
 tar xf node- . V12 16.1 . -linux-x64- the tar .xz -C / Soft / HEXO /
 Music Videos . / Soft / HEXO / Node-V12 16.1 -linux- x64-Node.js 
after decompression test ## is installed successfully: 
CD Node.js 
. / bin / the Node - v 
V12. 16.1   - version 
## set flexible connection 
LN -s /soft/hexo/node.js/bin/node / usr / local / bin / the Node
 LN -s / soft / HEXO / the Node .js / bin / npm / usr / local / bin / npm

Note: already installed here git, install hexo installation command directly belowyum install git -y

Install hexo

Note: Otherwise, you need to download from a foreign website, which is very slow! ! !

npm config set registry https://registry.npm.taobao.org
npm install -g hexo-cli

Build a blog foundation

#hexo command added to the global variable
 ln -s /soft/hexo/node.js/lib/node_modules/hexo-cli/bin/hexo / usr / local / bin / hexo

Deploy hexo blog environment: this can be placed outside nodejs for easy opening

mkdir / hexo 
cd hexo     
hexo init myblog // Automatically download resource files to myblog #Automatically 

generate website static files and deploy to the set warehouse. 
cd   / hexo / myblog /  
hexo g 
ls public /
 2020   archives css fancybox index.html js

Start test environment

## Test the front desk to open 
hexo s 
INFO Start processing 
INFO Hexo is running at http: // localhost: 4000. Press Ctrl + C to stop. 

## View port 4000 
netstat -lntup | grep  4000 
tcp6        0       0 ::: 4000                  :: : * LISTEN       10694 / hexo

log in page:

Install nginx

Function: We then bind the domain name to directly access the 80 port of the cloud host for access, write the blog directory in the extended configuration file, so that you can directly blog, here we use the yum installation method directly

Note: When the command is executed , the static file of the website will be generated to the default setting folder, which is homepage file of index.html, which can be directly accessed by nginxhexo g public

Official source:

vim  /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true    

Install nginx:

yum  install nginx- y 
systemctl start nginx 
systemctl enable 
nginx #default 
configuration file location 
rpm - ql nginx
 /etc/nginx/nginx.conf <-main configuration file
 /etc/nginx/cond.d/ <-extended configuration file position

Add a configuration file:

vim /etc/nginx/conf.d/ hexo.conf 
server { 
        listen        80 ; 
        server_name   127.0 . 0.1 ; #Binding domain name location, you can fill in the ip address 
        location / { 
            root html / public; #blog directory location 
            index index.html ; 
        } 

#Restart 
nginx 
nginx - t systemctl restart nginx

Log in directly to access by ip address.

 

Guess you like

Origin www.cnblogs.com/Mercury-linux/p/12728860.html