本机配置
官网 下载Node.js,换成淘宝源:
1 2 3 4 5 6 7 8 npm install -g cnpm --registry==https://registry.npm.taobao.org cnpm -v cnpm install -g hexo-cli mkdir Hexo && cd Hexohexo init hexo s
服务器与域名配置
阿里云ECS轻量应用服务器2核2G¥108/年;买域名、ICP备案
选择CentOS系统镜像,设置密码;
创建新用户并设置ssh免密登录[原理链接] ,方便后续hexo部署:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 adduser git chmod 740 /etc/sudoersvim /etc/sudoers git ALL=(ALL) ALL chmod 400 /etc/sudoerssudo passwd git su git cd ~mkdir .sshssh-keygen ssh-copy-id user@host
服务器nginx配置
RedHat系(RedHat、CentOS、Fedora等)包管理工具为rpm,依赖管理工具为yum,Debian系(Debian、Ubuntu等)包管理工具为dpkg,依赖管理工具为apt。
安装nginx依赖环境,下载解压nginx安装包:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 yum install gcc-c++ yum install -y pcre pcre-devel yum install -y zlib zlib-devel yum install -y openssl openssl-devel wget -c https://nginx.org/download/nginx-1.10.1.tar.gz tar -xvf nginx-1.10.1.tar.gz -C /usr/local cd /usr/local/nginx-1.10.1./configure make make install vim ./objs/Makefile CFLAGS = -pipe -O -W -Wall -Wpointer-arith -Wno-unused -g vim ./src/os/unix/ngx_user.c cd.current_salt[0] = ~salt[0];
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 cd /usr/local/nginx/sbin./nginx /sbin/iptables -I INPUT -p tcp –dport 80 -j ACCEPT mkdir -p /home/www/hexocd /usr/local/nginx/confvim nginx.conf cd ~curl -sL https://rpm.nodesource.com/setup_10.x | bash - yum install -y nodejs node -v npm -v yum install git git --version
服务器Hexo配置
配置git仓库
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 cd ~git init --bare hexo.git vim ~/hexo.git/hooks/post-receive chmod +x ~/hexo.git/hooks/post-receivecd ~sudo chmod -R 777 /home/www/hexo cd ~/Documents/Hexosudo vim _config.yml deploy: type : git repo: git@ip:/home/git/hexo.git branch: master npm install hexo-deployer-git --save npm install hexo-server git config --global user.name "your-username" git config --global user.email "your-email-address" hexo clean && hexo g -d
NeXT主题配置
1 2 3 4 5 6 7 8 9 10 11 git clone --depth=1 https://github.com/theme-next/hexo-theme-next.git themes/next hexo n "name.md" hexo clean && hexo g -d ![](image.jpg)
配置教程 ,另一篇 ,另一篇
1 2 npm uninstall hexo-generator-index --save npm instal hexo-generator-index-pin-top --save
在置顶文章的Front-matter中加上top: true即可。