希望可以帮助到你 ~~

★☆ CentOS搭建nginx环境get上传hexo网页

正文

github提供的静态博客功能很强大

但是总有些py交易不能放在github上

那就在第三方服务器搭建nginx,get环境

最后hexo本地编辑网页

最后上传

完工

代码1-CentOS

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
28
29
30
//由于centos的yum仓库没有nginx 咱们先安装EPEL
sudo yum install epel-release
yum update

//安装nginx
yum -y install nginx

//启动nginx
/bin/systemctl start nginx.service

//配置防火墙
firewall-cmd --zone=public --add-port=80/tcp --permanent
systemctl stop firewalld.service
systemctl start firewalld.service

//安装git
yum install git
adduser git

cd /data/git
mkdir hexo.git
git init --bare hexo.git //这一步是建立裸仓库


//给权限
chown -R git:git hexo.git
chown -R git:git git
chown 755 hexo.git
chown 755 /data/git
chown -R 755 /data/git

代码2-本地

//本地安装 git hode.js
//git中安装hexo
$npm install -g hexo
$npm install

#设置博客根目录
$hexo init


/*
//这些可以不用配
//配置ssh
ssh-keygen -t rsa -C "***@qq.com"
//找到公钥
#C:\Users\Administrator\.ssh
*************
//服务器添加
cd /data/git
mkdir .ssh
nano /data/git/.ssh/authorized_keys
*/

//这个总知道吧
deploy:
  type: git
  repo: root@*.*.*.*:/data/git/hexo.git
  branch: master

//如果 hexo d 报错的话 可以安装这个
npm install --save hexo-deployer-git

代码3-CentOS

/*
//这一段新手就不要改了直接用nginx的默认目录
//配置nginx
vi /etc/nginx/nginx.conf
#更改 root 为/data/git/www  更改location/为 index index.html index.htm;
/bin/systemctl restart nginx.service
*/

//建立钩子
mv post-update.sample post-update
//写入post-update
git --work-tree=/data/git/www --git-dir=/data/git/hexo.git checkout -f

//建立钩子(使用默认nginx路径的话)
mv post-update.sample post-update
//写入post-update
git --work-tree=/usr/share/nginx/html --git-dir=/data/git/hexo.git checkout -f

chmod +x post-update
★☆ Y国内9*1自拍社区作品水平鉴赏

  1. 1. 正文
  2. 2. 代码1-CentOS
  3. 3. 代码2-本地
  4. 4. 代码3-CentOS