WordPress:Installing/Updating WordPress with Subversion

来自站长百科
Fludlen讨论 | 贡献2008年6月24日 (二) 17:27的版本
跳转至: 导航、​ 搜索

If you have command-line access to your web server, and if your server has a Subversion (svn) client installed, you can use Subversion to install and update WordPress. Although SubVersion is mostly a software developers' tool, non-developers can also use it to install and upgrade WordPress. Some people consider this to be much easier than following the standard WordPress installation and upgrade methods (downloading and unzipping archives, then using FTP to put them on your web host), and this article explains how to do it.

如果你能够用命令行反问网络服务器,而且你的服务器安装了一个子版本 (svn) client,你可以使用子版本,安装和更新WordPress。虽然子版本通常是软件开发者的工具,非开发人员也可以使用子版本,安装和升级WordPress。有的人认为使用子版本,比遵循标准的 WordPress安装和升级方法(下载并且解压归档文件,然后使用FTP将这些文件放到你的网络主机上)更容易,这篇文章介绍了怎样使用子版本。

Introduction and Decisions

Introduction and Decisions

介绍和决定

First, a little background. Subversion is one of many existing source-code version-control systems; specifically, the version-control system that is used by WordPress. Version-control systems are used by software developers to keep track of their source code and its revisions behind the scenes, and periodically release versions of the software for public use. You can read more about Subversion, Subversion commands, and the use of Subversion in WordPress development in the WordPress:Using Subversion article.

首先,介绍一点背景知识。子版本是许多现存的源代码版本控制系统之一;明确是WordPress使用的版本控制系统。软件开发人员使用版本控制系统,在后台了解源代码,和源代码的修订本并且定期地发行软件版本,供公众使用。你可以在使用子版本这篇文章中阅读更多的关于子版本,子版本命令,在WordPress发展中使用子版本的内容。

As detailed in the WordPress:Using Subversion article, the WordPress Subversion repository has several branches or sections. When you install or upgrade WordPress, you have to choose a branch to use. Your main choices are:

使用子版本文章中所详细描述的,WordPress子版本库存拥有几个分支或者部分。当你安装或者升级WordPress的时候,你可以选择使用一个子版本分支。你主要可以选择:

  • trunk: Trunk is the "bleeding edge" version of WordPress that is being developed. This branch is likely to be broken and buggy, but can be useful for testing plugins and themes to see if they will work with the next release of WordPress. If you want to use this branch, read the "Tracking Trunk" section below.
  • 枝干:枝干是WordPress正在发展的"bleeding edge"版本。这个分支很可能会毁坏或者出现程序错误,但是测试插件和主题,看看这些插件和主题是否适用于下一个版本的WordPress,很有用。如果你想使用这个分支,请阅读下面的"追踪分支"部分。
  • A specific WordPress released version: This is recommended if you want a stable, working version of the software. If you want to use a stable version, read the "Tracking Stable Versions" section below.
  • 一个独特的WordPress发行的版本:如果你想要一个稳定的,运转的软件,那么推荐你使用这个版本。如果你想使用一个稳定的版本,请阅读下面的"追踪稳定版本部分"。

The other decision you need to make is to decide which directory to install your blog in. All examples here assume your blog is installed in a directory called "blog". If your blog is installed in a different directory, you will need to alter the commands shown accordingly.

你还需要决定将博客安装到哪个目录中。这里列出的所有例子,假定你的博客安装在一个称为"博客"的目录上。如果你的博客安装在一个不同的目录上,你需要相应地更改显示的命令。

Note: These instructions do not follow the official WordPress upgrade recommendations of deactivating all plugins and backing up your database before an upgrade. You may still want to do those things. Caveat blogger.

注:这些指示没有遵循官方WordPress升级的建议,如在升级之前取消运行插件并且备份你的数据库。但是你可能还是想执行这些操作。警告写博客的人

Tracking Trunk

追踪 Trunk

This section of the article assumes you have decided you want to have your blog run the latest "bleeding edge" development version of WordPress, and are willing to put up with bugs. If you would rather run a stable, released version of WordPress, skip down to the "Tracking Stable Versions" section below. If your blog had already been installed by the standard method, read the "Converting" section at the end of the article.

文章的这个部分,假定你已经决定了想让博客运行最新的"bleeding edge"的WordPress发展版本,而且假定你愿意容忍程序缺陷。如果你更想运行一个稳定的,已经发行的WordPress版本,跳读到下面的"追踪稳定版本"部分。如果你的博客已经用标准的方法安装好了,请在文章的结尾部分,阅读"转换"部分。

New Install

新的安装

To install a fresh copy of WordPress, type the following at your command prompt, starting from the directory above where you want to install WordPress. These commands will create a directory "blog" for your blog, and then check out (Subversion command "co"), or extract from the repository, the latest "trunk" version of WordPress. Do not type the "$" characters -- they are just indications of the command prompt. Here are the commands:

要安装一个新的WordPress拷贝,在你的命令提示符中输入以下的内容,从以上的目录,你想要安装WordPress的目录开始。这些命令会为你的博客创建一个目录"博客",然后检查(子版本命令"co"),或者从库存中提取,最新的WordPress的"枝干"版本:

$ mkdir blog
$ cd blog
$ svn co http://svn.automattic.com/wordpress/trunk/ .


$ mkdir blog
$ cd blog
$ svn co http://svn.automattic.com/wordpress/trunk/ .


The trailing slash on the URL, and that period at the end of the command, are both important - they make sure that downloaded files from the repository end up in the current directory; leave off that dot and you'll end up creating a new installation directory (which would be called "trunk"), which is not what you want if the current directory is the intended installation directory.

URL上拖尾的斜线,以及命令尾部的句点,都很重要-这两个符号确定从库存中下载的文件,在当前的目录中结束;留下那个点号,你就会不再创建一个新的安装目录(称作"枝干"),如果当前的目录是你想要安装的目录,那么新的安装目录就不是你所想要的。

When download is complete, copy wp-config-sample.php to wp-config.php and edit wp-config.php, then access your blog URL to complete installation, as in the standard WordPress installation instructions.

下载完成之后,将wp-config-sample.php复制到wp-config.php并且编辑wp-config.php,然后访问你的博客URL,完成安装,就如标准 WordPress 安装指示说明上面所叙述的。

Updating to a New Trunk Version

更新到一个新的 Trunk 版本

Some time later, you may decide that you want to update so that you are running the latest trunk version of the WordPress software. To do that, log in and use the Subversion "update" (up) command:

一段时间后,你可能想要更新,这样你就会运行WordPress软件的最新的trunk版本。要更新,请登录并且使用子版本"更新"命令:

$ cd blog
$ svn up


$ cd blog
$ svn up

Doing so will overwrite any changed WordPress-provided files, while leaving any custom or privately owned files, plugins, and themes alone. In other words, it should be safe (but make a backup, just in case). 这样做,会覆盖任何更改过的WordPress提供的文件,留下任何自定义或者私有的文件,插件。换句话说,这样做应该是安全的(但是以防万一,做了一个文件备份)。

Run the usual wp-admin/upgrade.php and you're done.

运行通常的wp-admin/upgrade.php,你就完成了。

Tracking Stable Versions

追踪稳定的版本

This section of the article assumes you have decided you want to have your blog run a stable version of WordPress. If you would rather run an unstable version in development, go back to the "Tracking Trunk" section above. If your blog had already been installed by the standard method, read the "Converting" section at the end of the article.

文章的这个部分,假定你决定让博客运行稳定版本的WordPress。如果在发展过程中,你更想运行一个不稳定的版本,返回到上面的"追踪 Trunk"部分。如果你的博客已经用标准的方法安装好了,请阅读文章尾部的"转换"部分。

The next thing you will need to do is decide which exact version of WordPress you would like to install. The examples in this section assume you want to install particular version numbers; if you want to install a different version, substitute that version number.

然后你需要做的事是决定安装哪个WordPress版本。这个部分的例子假定你想要安装某个特别的版本;如果你想要安装一个不同的版本,那么请你替换版本数字。

New Install

新的安装

To install a fresh copy of WordPress, type the following at your command prompt, starting from the directory above where you want to install WordPress. These commands will create a directory "blog" for your blog, and then check out (Subversion command "co"), or extract from the repository, the stable version of WordPress you have chosen. Do not type the "$" characters -- they are just indications of the command prompt. Here are the commands (assuming the version you want is 模板:CurrentVersion):

要安装WordPress的一个新的副本,在你的命令提示符中输入一下的内容,从你想要安装WordPress的目录开始。这些命令会为你的博客创建一个目录"博客",然后检查 (子版本命令 "co"),或者从库存中,提取你选择的稳定版本的WordPress。不要输入"$" 字符 –这只是命令指示符的迹象。下面是命令(假定你想要的版本是1.39.3):

$ mkdir blog
$ cd blog
$ svn co http://svn.automattic.com/wordpress/tags/模板:CurrentVersion .


$ mkdir blog
$ cd blog
$ svn co http://svn.automattic.com/wordpress/tags/模板:CurrentVersion .

The period at the end of the command is very important - it makes sure that downloaded files from the repository end up in the current directory; leave off that dot and you'll end up creating a new installation directory (which would be called "tags/模板:CurrentVersion"), which is not what you want if the current directory is the intended installation directory.

命令尾部的点号非常重要-这个点号确定了从库存中下载的文件在当前的目录中结束了;留下那个点,你就停止创建新安装目录(称作"tags/1.39.3"),如果当前目录就是想要安装的目录,你就不想要再安装目录了。

When download is complete, edit wp-config.php, then access your blog URL to complete installation, as in the standard WordPress installation instructions.

完成下载之后,编辑wp-config.php,然后访问你的博客URL来完成安装,就如standard WordPress 安装指示说明所介绍的那样安装。

Updating to a New Stable Version

更新到一个新的稳定的版本

The next time WordPress releases a new version, you will probably want to upgrade to that version. To do that, log in and use the Subversion "switch" command (sw) to switch to a new version (assuming the new version is 模板:CurrentVersion):

下一次WordPress发行一个新的版本的时候,你可能想要升级到那个新的版本。要升级到新版本,请登录并且使用子版本"切换" 命令 (sw)来切换到新的版本(假定新的版本是1.39.3):

$ cd blog
$ svn sw http://svn.automattic.com/wordpress/tags/模板:CurrentVersion/


$ cd blog
$ svn sw http://svn.automattic.com/wordpress/tags/模板:CurrentVersion/


Doing so will overwrite any changed WordPress-provided files, while leaving any custom or privately owned files, plugins, and themes alone. In other words, it should be safe (but make a backup, just in case).

这样做会覆盖任何更改了的WordPress提供的文件,但是会留下任何自定义的或者私有的文件,插件和主题。换句话说,这样做是安全的(但是以防万一,做一个文件备份)。

Run the usual wp-admin/upgrade.php and you're done.

运行通常的wp-admin/upgrade.php你就完成了。

Finding Released Versions

找到发行的版本

You can visit http://svn.automattic.com/wordpress/tags, the "tags" section of the Subversion repository, to find the list of tagged versions of WordPress.

你可以访问http://svn.automattic.com/wordpress/tags,子版本库存的"标签"部分,找到WordPress加上标签的版本的列表。

Converting a "Traditional" WordPress Blog to a Subversion Checkout

将WordPress一个"传统的l" WordPress切换到子版本Checkout

If you originally installed your blog without subversion, but now want to convert it to installing/upgrading with Subversion, this section explains how. The basic steps are:

如果你原先安装你的博客的时候,没有子版本,但是你现在向升级/安装博客时,带有子版本,这个部分介绍了可以怎么做。基本的步骤是:

  1. Create a new temporary blog directory.
  2. 创建一个新的临时博客目录。
  1. Use the Subversion commands from above to check out WordPress (trunk or stable version) into it.
  2. 使用上述的子版本命令,将WordPress(trunk或者稳定的版本)放进来。
  1. Copy all your custom files from the old blog location to the temporary directory.
  1. 从旧的博客位置中将所有的自定义文件复制到临时目录中。
  1. Rename the temporary directory to match the old directory name.
  1. 重新命名临时目录名,使其匹配旧的目录名。
  1. Run the WordPress update script (by going to your admin page - /wp-admin/) and test everything.
  1. 运行WordPress更新的脚本(通过进入你的管理网页- /wp-admin/)并且测试所有的内容。

Of course, backing up the old directory, backing up the database, and disabling all plugins before you start would be advisable.

当然,建议你开始之前,备份旧的目录,备份数据库,并且取消运行插件。

Here are the details of what commands to type, assuming that your old directory was called "blog", your temporary directory is called "blognew", and the version of WordPress you want to use is the stable 模板:CurrentVersion version. As above, do not type the "$" characters -- they are an indication of the command prompt.

下面是一些详细信息,关于输入哪个命令,假定你的旧目录称为"博客",你的临时目录称为"新博客",你想要使用的WordPress版本是稳定的1.39.3版本。如上所述,不要输入"$"字符—这是命令提示符的暗示。

First, create the temporary directory and check out WordPress there:

首先,创建临时目录同时查看WordPress位于其中:

$ mkdir blognew
$ cd blognew
$ svn co http://svn.automattic.com/wordpress/tags/模板:CurrentVersion .


$ mkdir blognew
$ cd blognew
$ svn co http://svn.automattic.com/wordpress/tags/模板:CurrentVersion .

Next, copy the old wp-config and .htaccess files to the new site:

然后,将旧的wp-config 和 .htaccess文件复制到新的站点:

$ cd ../blog
$ cp -p wp-config.php .htaccess ../blognew


$ cd ../blog
$ cp -p wp-config.php .htaccess ../blognew

Next, copy custom files/directories you may have on the old installation into the new one (this may not apply to you). For example, if you have an images directory and a wp-digest file:

其次,将旧的安装中可能有的文件/目录复制到新的安装中(可能对你并不适用)。例如,如果你有一个图像 目录和一个wp-digest文件:

$ cp -rp images wp-digest ../blognew

$ cp -rp images wp-digest ../blognew

Next, copy plugins, themes, and any uploaded images/media from the old site to the new (all three are stored in the wp-content directory):

再次,将旧的站点中的插件,主题,和任何上传的图像/媒体复制到新的站点中(这三项都储存在wp-content 目录中):

$ cp -rpf wp-content/* ../blognew/wp-content

$ cp -rpf wp-content/* ../blognew/wp-content

You may have spotted the flaw in that last step - it will overwrite any new WordPress-provided plugins with your old ones. This is probably not an issue, but running svn up (update) after the copy will fix any potential problems.

你可能在最后一步中发现了缺陷-你的旧的插件可能会覆盖任何新的WordPress提供的插件。这也许不是什么严重的问题,但是在复制后,运行svn up (更新)可能会解决一些潜在的问题。

Now, rename the directories to make the new blog dir into the current site:

现在,重新命名目录,使得新的博客dir进入当前的站点:

$ cd ..
$ mv blog blog-old
$ mv blognew blog


$ cd ..
$ mv blog blog-old
$ mv blognew blog


Now that all the files are installed, the last step is to visit the usual wp-admin/upgrade.php URL to allow WP to perform any needed database upgrades. Then you are ready to test all the links and features. If anything isn't working, check to make sure you actually copied all your custom files over from the old site. You shouldn't encounter any problems, but if you do, just move the old directory back into place, and if absolutely necessary, restore your database from backup. Here's how to move the directory names back:

既然所有的文件都已经安装好了,最后的一步就是访问通常的wp-admin/upgrade.php URL允许WP执行任何需要的数据库更新。然后你准备好测试所有的链接和功能。如果有某个内容不能够运行,检查,确定你真的从旧的站点上复制了所有的自定义文件。你不应该再遇到什么困难了,但是如果你遇到了,只要旧的目录返回到原位置,如果完全有必要的话,从文件备份中重建数据库。下面是关于怎样返回目录名:

$ mv blog blognew
$ mv blog-old blog

$ mv blog blognew
$ mv blog-old blog

Resources

WordPress:Using Subversion

Scripts for automating and managing WP blogs under svn control

资源

使用子版本

在svn控制下,自动操作和管理WP博客的脚本