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或者域名都可以訪問到頁面了!