It has been 541 days since the last update, the content of the article may be outdated.
宝塔系统依托于Centos
开发,所以我们服务器系统选择 Centos7+
安装宝塔
yum install -y wget && wget -O install.sh /install/install_6.0.sh && sh install.sh
安装完成后,登录宝塔,首次登录会提示我们安装环境,我们勾选Nginx
即可。
之后,我们在home
文件夹下新建git
,hexo
这两个文件夹
随后,我们登录我们的服务器,一次执行
cd ..cd homecd gitgit init --bare blog.git
接着,在目录/home/git/blog.git/hooks
下新建文件post-receive
,写入一下代码
git --work-tree=/home/hexo --git-dir=/home/git/blog.git checkout -f
给post-receive
权限
chmod +x /home/git/blog.git/hooks/post-receive
配置 Nginx
宝塔面板默认的nginx
配置文件在根目录 ->www->serve->nginx->conf 下,找到nginx.conf
,编辑它重启nginx
服务
service nginx restart
本地 Hexo 配置
修改_config.yml
中的配置deploy:type: gitrepo: user@ip:/home/git/blog
这个时候配置差不多就好了,hexo generate --deplay
部署后就可以访问博客了
接下来在宝塔面板里添加网站
之后在阿里云将域名解析到服务器 ip 即可