October 28, 2007
WordPress 自动升级脚本
update: 大可不必怀疑下面代码的安全性,它只是 Shell 命令的批处理。
update 2: 这是我使用脚本自动升级 WordPress 的截图(从 2.4-bleeding 到 2.3.1,其实是“降级”),整个过程一分钟不到:

这是一段 Bash 脚本。如果你的 blog 所在服务器开放了 Shell 帐户,你就可以利用它来体验一条命令搞定 WordPress 升级的快捷。Bash 脚本看上去有点类似 Microsoft 系统的批处理脚本,但相比之下功能要强大得多。感谢 Ozh 提供下面的代码:
#!/bin/bash
CURDIR=$(pwd)
SITE="http://yoursite.com/blog"
echo Updating Wordpress in $CURDIR
echo 1. downloading latest build
wget -q http://wordpress.org/latest.tar.gz
echo 2. unpacking latest build
tar zxf latest.tar.gz
cd wordpress/
echo 3. replacing old files with fresh ones
tar cf - . | (cd $CURDIR; tar xf -)
echo 4. updating your blog
wget -q -O - ${SITE}/wp-admin/upgrade.php?step=1> /dev/null
echo 5. removing unneeded files and directory
rm -f ../latest.tar.gz
echo 6. all done !
CURDIR=$(pwd)
SITE="http://yoursite.com/blog"
echo Updating Wordpress in $CURDIR
echo 1. downloading latest build
wget -q http://wordpress.org/latest.tar.gz
echo 2. unpacking latest build
tar zxf latest.tar.gz
cd wordpress/
echo 3. replacing old files with fresh ones
tar cf - . | (cd $CURDIR; tar xf -)
echo 4. updating your blog
wget -q -O - ${SITE}/wp-admin/upgrade.php?step=1> /dev/null
echo 5. removing unneeded files and directory
rm -f ../latest.tar.gz
echo 6. all done !
- 使用前记得修改第三行为你的 blog 地址(如:http://hellobmw.com/)
- 然后将此代码保存在 WordPress 的根目录下,那里会有一个名为“wp-config.php”的配置文件,跟它放一块儿就行了,取名为“updatewp”或任意与其他文件不冲突的名字
- 为其添加可执行权限:chmod +x updatewp
- 需要升级 WP 时,只需输入 ./updatewp

漫步 at 14:04 Oct 28, 2007 ₪
有个插件可以实现自动升级的了。
Andor at 15:09 Oct 28, 2007 ₪
对自动的东西总有点不放心,不过 svn 也是很方便的
北极冰仔 at 16:32 Oct 28, 2007 ₪
漫步 > 这个只是 BASH 命令,比插件升级要安全。
Andor > 相比之下,这个比 SVN 也要安全些,毕竟得到的是正式版。
漫步 at 17:58 Oct 28, 2007 ₪
偶空间好像不支持shell,
另我已经重发了邮件给你..
李晨 at 21:31 Aug 25, 2008 ₪
updatewp带不带后缀内呢?
北极冰仔 at 08:33 Aug 26, 2008 ₪
不带