服务器上使用 git 更新 wordpress 内核方案

本文介绍了一种WordPress网站的部署及更新方法,包括不同场景下的目录结构配置、如何使用Git进行版本管理和内核升级等。

目录结构、场景设想

推荐目录架构结构:

/opts/mysite/
—/wordpress/
—/wp-config.php
—/index.php

*wordpress 要加入到 .gitignore 中,/mysite/index.php 需要修改加载 wordpress 的路径

-场景 I 如果网站目录 mysite 是一个 repo(比如有 mysite/.git 目录)
-场景 II 网站目录不是 repo ,而是部署为 detached worktree,即不存在 mysite/.git

方案 I(适用场景 I)

把 wordpress 当成 git submodule 加入到 repo 中。
http://blog.g-design.net/post/60019471157/managing-and-deploying-wordpress-with-git

方案 II(适用场景 II)

此时可以把 wordpress 子目录设置成 git repo(即存在 mysite/wordpress/.git 目录)
git clone git://github.com/wordpress/wordpress.git /opts/mysite/wordpress

*注意在 apache 中屏蔽 .git 目录

然后通过以下命令升级 wordpress 内核即可

git fetch --tags
sudo git checkout tags/4.1.1 -f

方案 III(适用场景 I 和 场景 II)

wordpress 子目录也配置成 detached worktree

直接下载最新 wordpress
git clone git://github.com/wordpress/wordpress.git /tmp/wordpress

使用 git checkout 命令更新

git fetch --tags
sudo git —git-dir=/tmp/wordpress/.git —work-tree=/opts/mysite/wordpress checkout tags/4.1.1 -f
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值