云服务器+域名+hexo 搭建博客

1 阿里云服务器安全组规则中启用80,4000,22端口,

记得出方向也要设置,否则...

2 域名指向服务器ip

3 安装git

yum install git

4 安装node.js

下载地址为:(可以通过wget命令,或者自己的电脑上传)

https://nodejs.org/dist/v12.13.1/node-v12.13.1-linux-x64.tar.gz

解压缩

[root@VM_0_7_centos ~]# tar zxvf node-v12.13.1-linux-x64.tar.gz 

放到/usr/local下

[root@VM_0_7_centos ~]# mv node-v12.13.1-linux-x64 /usr/local/

软链接到 /bin 目录

[root@VM_0_7_centos ~]# ln -s /usr/local/node-v12.13.1-linux-x64/bin/node /bin/node
[root@VM_0_7_centos ~]# ln -s /usr/local/node-v12.13.1-linux-x64/bin/npm /bin/npm

测试环境变量

[root@VM_0_7_centos ~]# node -v
v12.13.1
[root@VM_0_7_centos ~]# npm -v
6.12.1

5 安装hexo

npm install -g hexo-cli

设置软连接

[root@VM_0_7_centos node_modules]# ln -s /usr/local/node-v12.13.1-linux-x64/lib/node_modules/hexo-cli/bin/hexo /bin/hexo

生成博客文件

[root@VM_0_7_centos ~]# hexo init hexos

[root@VM_0_7_centos ~]# cd hexos/

生成静态连接

[root@VM_0_7_centos hexos]# hexo g
[root@VM_0_7_centos hexos]# hexo s

查看网页

http://106.54.3.104:4000/

6 安装Nginx

[root@VM_0_7_centos hexos]# yum install nginx

开启服务

[root@VM_0_7_centos hexos]# systemctl start nginx

查看页面

http://IP地址

设置开机自启动

[root@VM_0_7_centos hexos]# systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.

7修改nginx配置文件

[root@VM_0_7_centos public]# vim /etc/nginx/nginx.conf

修改第4行

user root;

修改第41行

        server_name  www.sunlizhao.cn;

修改第42行

        root         /root/hexos/public;

进入博客目录(清除缓存,生成页面,上传)

[root@VM_0_7_centos hexos]# pwd
/root/hexos
[root@VM_0_7_centos hexos]# hexo clean
[root@VM_0_7_centos hexos]# hexo g
[root@VM_0_7_centos hexos]# hexo d

重启nginx服务

[root@VM_0_7_centos hexos]# nginx -s reload

通过ip或者域名都可以访问到页面了!

猜你喜欢

转载自www.cnblogs.com/inmeditation/p/12051710.html
今日推荐