# hexo部署到私有云一鍵部署服務(wù)器
> Blog服務(wù)到期翰意,把Blog相關(guān)的都要遷移至新的服務(wù)器衔峰,然而比較尷尬的是具體的配置和部署忘了。又是一頓百度帖池,為了避免下一次遷移出現(xiàn)尷尬婚惫,還是費點筆墨梳理一下氧骤。
> 續(xù)費是不可能續(xù)費的奈泪,這輩子都不可能續(xù)費的
>? 本質(zhì)上就是把本地代碼懟到服務(wù)器上,方法有很多種,Hexo也支持一鍵部署疾棵,只需要在`_config.yml`配置一下戳稽,相對更簡單一些
## 一馆蠕、 在云服務(wù)器上創(chuàng)建git倉庫
##### 1. 安裝Git
```
yum install git
```
##### 2. 創(chuàng)建Git倉庫
> 我這里把git倉庫創(chuàng)建在了`/var/git`目錄下
```
mkdir /var/git/
```
##### 3. 創(chuàng)建hexo遠程倉庫
```
cd /var/git
```
```
git init --bare hexo.git
/* git init? --bare (你自定義倉庫名).git */
```
>
##### 4. 配置Git Hooks
> 利用git的hooks中的post-receive來實現(xiàn)代碼提交完成之后的動作。將倉庫指定一個--work-tree然后進行檢出操作checkout --force
```
cd /var/git/hexo.git/hooks/
```
```
vim post-receive
```
> 將入下代碼復(fù)制進去 惊奇,并保存退出
```
#!/bin/bash
git --work-tree=/var/www/hexo --git-dir=/var/git/hexo.git checkout -f
```
> 說明
```
git
--work-tree=/var/www/hexo? 設(shè)置工作樹的路徑/var/www/hexo
--git-dir=/var/git/hexo.git 設(shè)置存儲庫的路徑 /var/git/hexo.git
checkout -f
```
##### 5. 給鉤子文件添加執(zhí)行權(quán)限
```
chmod +x post-recevie
```
##### 6. 創(chuàng)建工作樹的路徑
```
mkdir /var/www/hexo
```
## 二互躬、配置本地Hexo? `_config.yml`
##### 1. 配置`_config.yml`
```
deploy:
? type: git
? repo: root@你的ip:/var/git/hexo.git
? branch: master
```

##### 2. 執(zhí)行
```
hexo clean && hexo deploy
```
##### 3. 檢查服務(wù)器上 `/var/www/hexo`目錄下你的代碼有沒有push過來

## Nginx
##### 1. 安裝Nginx
```
yun install
```
##### 2. 配置Nginx資源指向

##### 3. 修改域名解析

##### 4.配置域名和https
> 配置證書我放在了根目錄下ssl文件夾里面? `cd /ssl`

### [遇到的問題](https://www.superwang.cn/2020/09/28/ssh%E8%BF%9E%E6%8E%A5-Host-key-verification-failed/)