2020/2/11日
我的第一篇log
不知道写点儿啥,不如写写怎么用Hexo搭建的吧
使用阿里云服务器CentOS 7搭建Hexo
首先安装自动补全和vim
yum install bash-completion vim -y
安装Git
yum install git-core -y
安装Node.js
curl -sL https://rpm.nodesource.com/setup_13.x | bash - 此命令会提示缺少依赖的安装包
安装缺少依赖的安装包:
sudo yum install -y nodejssudo yum install gcc-c++ make -y
node -v 查看Node.js版本
npm -v 查看npm版本
安装Hexo
npm install -g hexo-cli 安装Hexo(WARN级别的提示可不用理会)
openssl version 查看版本
yum update openssl -y 更新版本
配置Hexo
cd /移动至根目录hexo init cooper初始化生成博客文件夹(此处cooper为自定义文件夹名,可任意更改)cd cooper进入生成的文件夹内进行下一步配置npm install在文件夹内安装hexo扩展插件hexo generate (hexo g)生成静态页面hexo server (hexo s)开启本地服务器(此处等待10秒左右后使用Ctrl+C,再进行下边的配置)扩展知识:
hexo new “my new postCreate a new post(新建帖子)hexo deployDeploy to remote sites(部署到远程站点)
配置Nginx服务
yum install nginx -y安装nginxsystemctl start nginx.service启动nginx服务vi /etc/nginx/nginx.conf修改nginx配置;1
2
3
4
5
6user root; //修改为当前账户
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name localhost;
root /cooper/public;} 修改为生成hexo所在文件夹的public目录(此处需要注意,如果nginx找不到默认的3个主页面就会返回403,所以此处应该为public下的index.html才能成功)systemctl restart nginx.service重启nginx服务
错误及解决办法
安装主题后发布新文章提示Error: Cannot find module 'cheerio'(仅Jerryc的主题)
解决办法:在博客根目录npm install [email protected] -save 安装cheerio
主题页面
Page Front-matter
1 | --- |
Post Front-matter
1 | --- |
友情链接
本博客所应用的Butterfly主题教程(作者Jerryc): https://demo.jerryc.me/
NEXT主题教程: http://theme-next.iissnan.com/
Hexo官网上的更多网站主题模板: https://hexo.io/themes/
七牛云对象存储(免费10G存储): https://sso.qiniu.com/
Valine评论系统: https://leancloud.cn/


