雲主機購買地址:點擊這里 建議在活動時購買比較划算。
注:這里我購買的是centos系統主機


后期我們需要把域名進行備案(備案時間14天-20天),然后在去綁定我們已經買好的雲主機的ip地址
這里我們購買域名可以去萬網購買

## 下載node mkdir /soft/hexo -p wget https://npm.taobao.org/mirrors/node/v12.16.1/node-v12.16.1-linux-x64.tar.xz ## 解壓 tar xf node-v12.16.1-linux-x64.tar.xz -C /soft/hexo/ mv /soft/hexo/node-v12.16.1-linux-x64 node.js ## 解壓以后測試是否安裝成功: cd node.js ./bin/node -v v12.16.1 --版本號 ##設置軟連接 ln -s /soft/hexo/node.js/bin/node /usr/local/bin/node ln -s /soft/hexo/node.js/bin/npm /usr/local/bin/npm
npm config set registry https://registry.npm.taobao.org npm install -g hexo-cli
#hexo命令添加到全局變量 ln -s /soft/hexo/node.js/lib/node_modules/hexo-cli/bin/hexo /usr/local/bin/hexo
部署hexo博客環境:這個可以放在nodejs外面,方便打開
mkdir /hexo cd hexo hexo init myblog //會自動把資源文件下載到myblog #自動生成網站靜態文件,並部署到設定的倉庫。 cd /hexo/myblog/ hexo g ls public/ 2020 archives css fancybox index.html js
## 測試前台開啟 hexo s INFO Start processing INFO Hexo is running at http://localhost:4000 . Press Ctrl+C to stop. ## 查看4000端口 netstat -lntup | grep 4000 tcp6 0 0 :::4000 :::* LISTEN 10694/hexo
登錄頁面:

作用:我們之后綁定域名直接訪問雲主機的80端口進行訪問,在擴展配置文件內寫入博客目錄,這樣就可以直接網絡博客,這里我們直接使用yum的安裝方式
注:當執行hexo g 命令時會生成網站靜態文件到默認設置的public文件夾,里面由index.html的首頁文件,nginx可以直接訪問
官方源:
vim /etc/yum.repos.d/nginx.repo [nginx-stable] name=nginx stable repo baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=1 enabled=1 gpgkey=https://nginx.org/keys/nginx_signing.key module_hotfixes=true
安裝nginx:
yum install nginx -y systemctl start nginx systemctl enable nginx #默認的配置文件位置 rpm -ql nginx /etc/nginx/nginx.conf <--主配置文件 /etc/nginx/cond.d/ <--擴展配置文件位置
添加配置文件:
vim /etc/nginx/conf.d/hexo.conf server { listen 80; server_name 127.0.0.1; #綁定域名位置,前期可以填寫ip地址 location / { root html/public; #博客目錄位置 index index.html; }
} #重啟nginx nginx -t systemctl restart nginx
登錄直接ip地址訪問。
