WordPress: Moving WordPress:修订间差异

来自站长百科
跳转至: 导航、​ 搜索
(新页面: __TOC__ There are times when you need to move WordPress around within your server, and times when you need to move WordPress from one server to another. You don't need to reinstall. WordP...)
 
无编辑摘要
 
(未显示3个用户的3个中间版本)
第1行: 第1行:
<span style="border:1px solid #000; text-align:center; float:right; padding:6px;"><strong>导航:</strong> [[WordPress:WordPress文档|上一级]] | [[WordPress]] | {{Template:WordPress导航}}</span>
<div style="clear:both;"></div>
__TOC__
__TOC__
There are times when you need to move WordPress around within your server, and times when you need to move WordPress from one server to another. You don't need to reinstall. WordPress is flexible enough to handle all of these situations.
有时你需要在你的服务器内移动WordPress,也可能需要移动WordPress到另外一个服务器上。你不用重新安装。WordPress完全可以应付这些情况。


Easy answer for most installations:  
对大多数安装的简单的回答:  
* If database and URL remains the same, you can move by just copying your files and database.  
* 如果数据库和URL保持不变, 你可以通过简单的复制你的文件和数据库来进行移动.  
* If database name or user changes, edit wp-config.php to have the correct values.
* 如果数据库名字或者用户改变了,编辑wp-config.php 文件,得到正确的内容.
* If you want to '''test before you switch''', you must temporarily change "siteurl" and "home" in the database table "wp_options" (through phpMyAdmin or similar).<br />If you had any kind of rewrites (permalinks) setup you must disable .htaccess and reconfigure permalinks when it goes live.
* 如果你想'''转换之前进行测试''', 你必须在数据库表格"wp_options"中临时的更改"siteurl" "home" (通过 phpMyAdmin 或者类似工具).<br />如果你做出了某种改写 (permalinks) 设置,你必须禁用 .htaccess 文件然后在激活时重新配置permalinks


==在站点内部移动WordPress==


==Moving WordPress Within Your Site==
从你服务器上的一个位置把移动WordPress文件移动到另外一个位置 – 改变它的URL – 有一些要特别注意的地方.
# 使用下面两个选项中的一个建立新的位置:
## 如果你打算移动你的[[WordPress:WordPress Files|WordPress 核心文件]]到一个新的目录,那么建立一个新的目录。
## 如果你想把WordPress移动到你的根目录, 确认所有的[[WordPress:WordPress Files|index.php]], [[WordPress:Glossary#.htaccess|.htaccess]], 和别的可能复制的文件已经备份并移动了,而且根目录已经为新的WordPress文件准备好了.
# 登陆你的blog.
# 进入[[WordPress:Administration Panels|管理]] > [[WordPress:Administration_Panels#Options_-_Configuration_Settings|设置]] > [[WordPress:Settings_General_SubPanel|一般]]面板.
# 在'''WordPress 地址 (URI)框中:''' 更改地址为主要WordPress核心文件所在的新位置.
# 在 '''Blog 地址 (URI)框中:''' 把地址改为新位置,要与WordPress 地址 (URI)相符合.
# 点击 '''更新选项'''.
# (现在不要尝试打开/浏览你的blog!)
# ''仅针对WordPress 2.0:'' 删除文件夹''wp-content/cache''.
# 把你的WordPress核心文件移动到新的位置。这包括原始目录中的文件,如 <tt><nowiki> http://example.com/wordpress</nowiki></tt>, 还有所有子目录。
# 如果你正在使用[[WordPress:Using Permalinks|Permalinks]], 进入 [[WordPress:Administration Panels|管理]] > [[WordPress:Administration_Panels#Options_-_Configuration_Settings|设置]] > [[WordPress:Settings_Permalinks_SubPanel|Permalinks]] 面板,更新Permalink 结构到 [[WordPress:Glossary#.htaccess|.htaccess]] 文件, 这个文件应该和主<tt>index.php</tt> 文件在同一目录下。
# 如果你有丢失已经上传过的图片的问题,你需要在SQL数据库中更改每个文章中到这个图片的路径。按照[http://www.tamba2.org.uk/wordpress/move3 Tamba2  "电脑内移动webblog"]的说明去做即可


Moving the WordPress files from one location on your server to another - changing its URL - requires some special care.
在你移动文件之前,设定URI位置是非常重要的。


Here are the step-by-step instructions:
假设你不小心在更改URI之前移动了文件。假设文件本来的路径是/path/to/old/ ,在更改URI前你把它们移动到了/path/to/new 。修正的方法是把 /path/to/old/设定为转到/path/to/new/的symlink (对于Windows 用户来说, "symlink" 等同于"快捷方式")
 
# Create the new location using one of these two options:
## If you will be moving your [[WordPress:WordPress Files|WordPress core files]] to a new directory, create the new directory.
## If you want to move WordPress to your root directory, make sure all [[WordPress:WordPress Files|index.php]], [[WordPress:Glossary#.htaccess|.htaccess]], and other files that might be copied over are backed up and/or moved, and that the root directory is ready for the new WordPress files.
# Login to your blog.
# Go to the [[WordPress:Administration Panels|Administration]] > [[WordPress:Administration_Panels#Options_-_Configuration_Settings|Settings]] > [[WordPress:Settings_General_SubPanel|General]] panel.
# In the box for '''WordPress address (URI):''' change the address to the new location of your main WordPress core files.
# In the box for '''Blog address (URI):''' change the address to the new location, which should match the WordPress address (URI).
# Click '''Update Options'''.
# (Do not try to open/view your blog now!)
# ''WordPress 2.0 only:'' Delete the folder ''wp-content/cache''.
# Move your WordPress core files to the new location.  This includes the files found within the original directory, such as <tt><nowiki> http://example.com/wordpress</nowiki></tt>, and all the sub-directories, to the new location.
# If you are using [[WordPress:Using Permalinks|Permalinks]], go to the [[WordPress:Administration Panels|Administration]] > [[WordPress:Administration_Panels#Options_-_Configuration_Settings|Settings]] > [[WordPress:Settings_Permalinks_SubPanel|Permalinks]] panel and update your Permalink structure to your [[WordPress:Glossary#.htaccess|.htaccess]] file, which should be in the same directory as the main <tt>index.php</tt> file.
# If you have problems with missing images that you've uploaded, you need to change the path to the images on every post directly on your SQL database. For this, follow the instructions on [http://www.tamba2.org.uk/wordpress/move3 Tamba2's Tutorial "Moving your weblog inside your PC"].
 
It is important that you set the URI locations BEFORE you move the files.
 
Suppose you accidentally moved the files before you changed the URIs. Suppose the files were originally in /path/to/old/ and you moved them to /path/to/new before changing the URIs. The way to fix this would be to make /path/to/old/ a symlink (for Windows users, "symlink" is equivalent to "shortcut") to /path/to/new/, i.e.
<pre>ln -s /path/to/new /path/to/old</pre>
<pre>ln -s /path/to/new /path/to/old</pre>
and then follow the steps [[WordPress:Moving WordPress#Moving WordPress Within Your Site | above]] as normal. Afterwards delete the symlink if you want.
然后象平时那样按照 [[WordPress:Moving WordPress#Moving WordPress Within Your Site | 上边的]]步骤,最后如果你想的话可以删除symlink。
 
You're done.  Test your site to make sure that it works right.  If the change involves a new address for your blog, make sure you let people know the new address, and consider adding some redirection instructions in your <tt>.htaccess</tt> file to guide visitors to the new location.
 
== Giving WordPress its Own Directory While Leaving the WordPress Index File in the Root Directory==
Please see this article, [[WordPress:Giving_WordPress_Its_Own_Directory|Giving WordPress Its Own Directory]], for detailed instructions.
 
==Moving WordPress to a New Server==
 
If you are moving WordPress from one server to another, begin by backing up your data. This includes backing up your WordPress database as well as all the core files, images, plugins, and
other files on your site. See [[WordPress:WordPress Backups]] and [[WordPress:Backing Up Your Database]] for more details.
 
*Note: If you are changing to a new server but same domain, all you need to do is edit wp-config.php and upload everything as it is to your new server.
 
'''If You Don't Care If Your Old Blog Works'''
 
#Download a copy of the main wordpress files from your OLD blog to your hard drive and edit wp-config.php to suit the new server.
#Go back to your OLD blog and go to options and change the url (both of them) to that of your new site.
#Again, download your database (but keep the old one just in case), upload this new database and the copy of the wordpress core files with the edited wp-config.php to your new server. Thats it!
 
'''If You Want Your Old Blog To Still Work'''


Caution: Make sure you have a backup of your old blog's WordPress database before proceeding!
完成了。测试一下你的站点,确认它工作正常。如果这些更改涉及到新的blog地址,确认访问者知道新的地址,考虑添加一些跳转说明到你的<tt>.htaccess</tt>文件中来引导访问者到新的地址。
== 给WordPress自己的目录,同时把索引文件保留在根目录==
请阅读[[WordPress:Giving_WordPress_Its_Own_Directory|给WordPress自己的目录]]得到详细的信息。
==把WordPress移动到新的服务器上==


''Part A - Activating Your New Blog''
如果你正打算把WordPress从一个服务器上移动到另一个服务器,首先备份你的数据。包括备份你的WordPress数据库,所有的核心文件,图片插件,和其他一些网站上的文件参见 [[WordPress:WordPress Backups| WordPress备份]] 和[[WordPress:Backing Up Your Database|备份你的数据库]]。
#Download your entire WordPress installation to your hard drive.  Name the folder appropriately to indicate that this is your OLD blog's installation.
#Go back to your OLD blog and go to options and change the url (both of them) to that of your new site.
#Again, download your entire WordPress installation to your hard drive.  Name the folder appropriately to indicate that this is your NEW blog's installation.
#Download your database once again (but keep the old one).  Upload this database to your new server.  It will be easiest if you use the same database name and you create a user with the same login credentials on your new server as on your old server.
#If you used a different database name and/or user (see previous step), edit wp-config.php in your NEW blog's installation folder appropriately.
#Upload the NEW blog's installation folder to your new site.  Presto, your NEW blog should be working!


''Part B - Restoring Your Old Blog''
*注意: 如果你更换一个新服务器,但还是在同一个域中,你只需要编辑 wp-config.php 文件并上传到新服务器就可以了。
#On the original server, delete your OLD blog's database (remember, you should have a copy on your local computer that you made at the very beginning).
#Upload your OLD blog's installation folder to your original server, overwriting the files that are currently there (you may also delete the installation folder on the server and simply re-upload the OLD blog's files).
#Upload your OLD blog's database from your local computer to the server.  That should do it!


'''如果你不在意旧的blog是否能够运行'''


Another procedure for making copies of posts, comments, pages, categories and custom field (post status, data, permalinks, ping status...) easy to follow:
#从旧的blog下载一个wordpress主要文件的副本,编辑 wp-config.php文件以适应新服务器。.
#Install a new Wordpress blog
#返回旧blog,改变url 为你的新站点链接。
#Go on old blog Admin panel. Here, in  Manage > Export select "all" in menu Restrict Author.
#再次下载你的数据库(保留旧的以防万一), 上传新的数据库和带有编辑过的wp-config.php 文件的wordpress核心文件的副本 到新的服务器。 完成!
#Click on Download Export File
'''如果你希望你的旧blog仍然可以使用'''
#In new blog go on Manage > Import, choose Wordpress item.
#In the page that will be shown, select the file just exported. Click on Upload file and Import
#It will appear a page. In Assign Authors, assign the author to users that already exist or create new ones.
#Click on Submit
#At the end, click on Have fun


Note: using this method if there are some articles in new blog (like hello world, info page...), these will not be erased. Articles are only added. Using the former procedure the article in new blog will be deleted.
注意: 开始之前确认你有旧的blog的WordPress数据库备份!


==Moving WordPress to a New Server with Fantastico==
''Part A – 激活新的 Blog''
#下载整个的WordPress安装文件到硬盘上。命名这个文件夹表明这是你的旧的blog。
#返回旧的blog然后更改url 为新的站点.
#再次下载整个WordPress安装文件到硬盘。命名文件夹表明这是新的blog。
#再次下载数据库(保留旧的)。上传这个数据库到新的服务器上。使用同样的数据库名字,并且在新服务器建立了一个和旧服务器一样的用户,这会是最容易的办法。
#如果你使用了不同的数据库名字或者用户名(见上一步), 在新的blog安装文件中编辑 wp-config.php文件。
#上传新blog安装文件夹到新的网站。你的新blog应该可以运行了!
''Part B – 恢复旧的blog''
#在原有的服务器上, 删除旧的blog数据库(记住,开始时你应该在本地电脑上做一个备份).
#上传旧的blog安装文件到原来的服务器, 覆盖现有的文件(你也可以删除文件夹然后重新上传旧的blog).
#上传旧的blog数据库,完成!


Some webhosts use a service called [http://netenberg.com/fantastico.php Fantastico], which can install a vanilla WordPress web with just a few clicks. You can transfer your blog to one of these webs, but the steps are slightly different.
另外一种制止文章,评论,页面,分类和自定义域(文章状态,数据, permalinks, ping 状态等等) 的过程,如下:
#安装一个新的Wordpress blog
#进入旧的管理面板,进入管理> 导出,在菜单Restrict Author选择"所有"。
#点击下载导出文件
#在新的blog中进入管理 > 导入, 选择Wordpress 选项。
#在接下来的页面中,选择文件导出,点击上传文件然后导入。
#接下来将显示一个页面,在分配作者中,给已经存在的使用者分配一个作者或者创建一个新的。
#点击提交
#最后点击Have fun


Begin by backing up your data. This includes backing up your WordPress database as well as all the core files, images, plugins, and
注意: 使用这个方法,如果新blog中有文章的话(如hello world, info page...), 将不会被删除。文章只能被添加. 使用前一种方法,新blog中的文章会被删除。
other files on your site. See [[WordPress:WordPress Backups]] and [[WordPress:Backing Up Your Database]] for more details.
==使用Fantastico把WordPress 移动到新的服务器==


'''Make a copy of your database. You will need to edit the <code>.sql</code> file, and in case of errors, it is important that you work on a copy.'''
一些网络主机使用一种叫做[http://netenberg.com/fantastico.php Fantastico]的服务, 可以安装一个点击几次就可以安装的vanilla WordPress 网页,你可以转移你的blog到一个这类网页上,但是步骤完全不一样.
首先备份数据. 包括备份WordPress 数据库,核心文件,图片,插件和站点上的其他文件,参见[[WordPress:WordPress Backups| WordPress备份]] 和 [[WordPress:Backing Up Your Database|备份你的数据库]].


Begin the process of working from copies of your backups.
'''制作一个数据库副本. 你需要编辑<code>.sql</code> 文件, 为了防止出现错误, 在副本上做实验是很重要的.'''


#'''If''' you have changed domain, edit the backed up database file to reflect this. A simple way to do this is:
使用你的备份开始如下步骤.
## Using a [[WordPress:Glossary#Text editor|text editor]], open a '''copy''' of the <code>.sql</code> database file.
## Using the search and replace function, find all instances of the blog's old [[WordPress:Glossary#URL|URL]] and replace it with the new URL.
## Repeat the process with your old email address. (For example, replacing <tt>someone@example.com</tt> with <tt>someone@tutorial.com</tt>)
## Save your changes.
#Upload your plugins and themes from your old site to the new one.
#Drop (delete) the database tables of the pre-installed Fantastico web.
#[[WordPress:Restoring Your Database From Backup|Restore the database]].


When you are ready to check your site, make sure to [[WordPress:I Make Changes and Nothing Happens|clear your cache]] and cookies so you will see the changes in your web browser.
#'''如果''' 你更换了域,编辑备份数据库文件来反应出这一点。一个简单的方法是:
## 使用[[WordPress:Glossary#Text editor|文本编辑器]], 打开数据库中<code>.sql</code>文件的'''副本'''
## 使用搜索和替换功能, 找到所有blog的旧的[[WordPress:Glossary#URL|URL]] 然后替换为新的URL.
## 使用旧的电子邮件地址重复这一过程。(例如,使用<tt>someone@tutorial.com</tt>替代<tt>someone@example.com</tt>)
## 保存更改.
#从旧的blog上传插件和主题到新的blog.
#删除刚才在Fantastico web上安装的数据库表格.
#[[WordPress:Restoring Your Database From Backup|恢复数据库]].


当你准备好检查你的站点时,确认[[WordPress:I Make Changes and Nothing Happens|清除缓存]] 和cookies,这样你才能在浏览器中看到所做的更改。


== Additional Information ==
== 附加信息 ==
* [http://www.tamba2.org.uk/wordpress/ Podz' WordPress Guides]
* [http://www.tamba2.org.uk/wordpress/ Podz WordPress 指南]
* [http://www.mydigitallife.info/2007/10/01/how-to-move-wordpress-blog-to-new-domain-or-location/ How to move WordPress to a new domain or location]
* [http://www.mydigitallife.info/2007/10/01/how-to-move-wordpress-blog-to-new-domain-or-location/ 如何转移WordPress到一个新的域或者位置]


* Italian version of this article - [http://www.valent-blog.eu/2007/09/14/trasferire-wordpress/ Versione italiana dell'articolo]
* 本文的意大利语版本 - [http://www.valent-blog.eu/2007/09/14/trasferire-wordpress/ Versione italiana dell'articolo]
* German version of this article - [http://blogs-optimieren.de/2008/01/13/wordpress-korrekt-umziehen/]
* 本文的德语版本 - [http://blogs-optimieren.de/2008/01/13/wordpress-korrekt-umziehen/]


{{Copyedit}}
{{Copyedit}}

2008年5月27日 (二) 10:49的最新版本

导航: 上一级 | WordPress | 首页 | WordPress中文论坛 | WordPress主机 | CMS程序 | 论坛程序 | ECShop | ShopNC | PowerEasy

有时你需要在你的服务器内移动WordPress,也可能需要移动WordPress到另外一个服务器上。你不用重新安装。WordPress完全可以应付这些情况。

对大多数安装的简单的回答:

  • 如果数据库和URL保持不变, 你可以通过简单的复制你的文件和数据库来进行移动.
  • 如果数据库名字或者用户改变了,编辑wp-config.php 文件,得到正确的内容.
  • 如果你想转换之前进行测试, 你必须在数据库表格"wp_options"中临时的更改"siteurl" 和 "home" (通过 phpMyAdmin 或者类似工具).
    如果你做出了某种改写 (permalinks) 设置,你必须禁用 .htaccess 文件然后在激活时重新配置permalinks

在站点内部移动WordPress[ ]

从你服务器上的一个位置把移动WordPress文件移动到另外一个位置 – 改变它的URL – 有一些要特别注意的地方.

  1. 使用下面两个选项中的一个建立新的位置:
    1. 如果你打算移动你的WordPress 核心文件到一个新的目录,那么建立一个新的目录。
    2. 如果你想把WordPress移动到你的根目录, 确认所有的index.php, .htaccess, 和别的可能复制的文件已经备份并移动了,而且根目录已经为新的WordPress文件准备好了.
  2. 登陆你的blog.
  3. 进入管理 > 设置 > 一般面板.
  4. WordPress 地址 (URI)框中: 更改地址为主要WordPress核心文件所在的新位置.
  5. Blog 地址 (URI)框中: 把地址改为新位置,要与WordPress 地址 (URI)相符合.
  6. 点击 更新选项.
  7. (现在不要尝试打开/浏览你的blog!)
  8. 仅针对WordPress 2.0: 删除文件夹wp-content/cache.
  9. 把你的WordPress核心文件移动到新的位置。这包括原始目录中的文件,如 http://example.com/wordpress, 还有所有子目录。
  10. 如果你正在使用Permalinks, 进入 管理 > 设置 > Permalinks 面板,更新Permalink 结构到 .htaccess 文件, 这个文件应该和主index.php 文件在同一目录下。
  11. 如果你有丢失已经上传过的图片的问题,你需要在SQL数据库中更改每个文章中到这个图片的路径。按照Tamba2 "电脑内移动webblog"的说明去做即可

在你移动文件之前,设定URI位置是非常重要的。

假设你不小心在更改URI之前移动了文件。假设文件本来的路径是/path/to/old/ ,在更改URI前你把它们移动到了/path/to/new 。修正的方法是把 /path/to/old/设定为转到/path/to/new/的symlink (对于Windows 用户来说, "symlink" 等同于"快捷方式")。

ln -s /path/to/new /path/to/old

然后象平时那样按照 上边的步骤,最后如果你想的话可以删除symlink。

完成了。测试一下你的站点,确认它工作正常。如果这些更改涉及到新的blog地址,确认访问者知道新的地址,考虑添加一些跳转说明到你的.htaccess文件中来引导访问者到新的地址。

给WordPress自己的目录,同时把索引文件保留在根目录[ ]

请阅读给WordPress自己的目录得到详细的信息。

把WordPress移动到新的服务器上[ ]

如果你正打算把WordPress从一个服务器上移动到另一个服务器,首先备份你的数据。包括备份你的WordPress数据库,所有的核心文件,图片插件,和其他一些网站上的文件参见 WordPress备份备份你的数据库

  • 注意: 如果你更换一个新服务器,但还是在同一个域中,你只需要编辑 wp-config.php 文件并上传到新服务器就可以了。

如果你不在意旧的blog是否能够运行

  1. 从旧的blog下载一个wordpress主要文件的副本,编辑 wp-config.php文件以适应新服务器。.
  2. 返回旧blog,改变url 为你的新站点链接。
  3. 再次下载你的数据库(保留旧的以防万一), 上传新的数据库和带有编辑过的wp-config.php 文件的wordpress核心文件的副本 到新的服务器。 完成!

如果你希望你的旧blog仍然可以使用

注意: 开始之前确认你有旧的blog的WordPress数据库备份!

Part A – 激活新的 Blog

  1. 下载整个的WordPress安装文件到硬盘上。命名这个文件夹表明这是你的旧的blog。
  2. 返回旧的blog然后更改url 为新的站点.
  3. 再次下载整个WordPress安装文件到硬盘。命名文件夹表明这是新的blog。
  4. 再次下载数据库(保留旧的)。上传这个数据库到新的服务器上。使用同样的数据库名字,并且在新服务器建立了一个和旧服务器一样的用户,这会是最容易的办法。
  5. 如果你使用了不同的数据库名字或者用户名(见上一步), 在新的blog安装文件中编辑 wp-config.php文件。
  6. 上传新blog安装文件夹到新的网站。你的新blog应该可以运行了!

Part B – 恢复旧的blog

  1. 在原有的服务器上, 删除旧的blog数据库(记住,开始时你应该在本地电脑上做一个备份).
  2. 上传旧的blog安装文件到原来的服务器, 覆盖现有的文件(你也可以删除文件夹然后重新上传旧的blog).
  3. 上传旧的blog数据库,完成!

另外一种制止文章,评论,页面,分类和自定义域(文章状态,数据, permalinks, ping 状态等等) 的过程,如下:

  1. 安装一个新的Wordpress blog
  2. 进入旧的管理面板,进入管理> 导出,在菜单Restrict Author选择"所有"。
  3. 点击下载导出文件
  4. 在新的blog中进入管理 > 导入, 选择Wordpress 选项。
  5. 在接下来的页面中,选择文件导出,点击上传文件然后导入。
  6. 接下来将显示一个页面,在分配作者中,给已经存在的使用者分配一个作者或者创建一个新的。
  7. 点击提交
  8. 最后点击Have fun

注意: 使用这个方法,如果新blog中有文章的话(如hello world, info page...), 将不会被删除。文章只能被添加. 使用前一种方法,新blog中的文章会被删除。

使用Fantastico把WordPress 移动到新的服务器[ ]

一些网络主机使用一种叫做Fantastico的服务, 可以安装一个点击几次就可以安装的vanilla WordPress 网页,你可以转移你的blog到一个这类网页上,但是步骤完全不一样.

首先备份数据. 包括备份WordPress 数据库,核心文件,图片,插件和站点上的其他文件,参见 WordPress备份备份你的数据库.

制作一个数据库副本. 你需要编辑.sql 文件, 为了防止出现错误, 在副本上做实验是很重要的.

使用你的备份开始如下步骤.

  1. 如果 你更换了域,编辑备份数据库文件来反应出这一点。一个简单的方法是:
    1. 使用文本编辑器, 打开数据库中.sql文件的副本
    2. 使用搜索和替换功能, 找到所有blog的旧的URL 然后替换为新的URL.
    3. 使用旧的电子邮件地址重复这一过程。(例如,使用someone@tutorial.com替代someone@example.com)
    4. 保存更改.
  2. 从旧的blog上传插件和主题到新的blog.
  3. 删除刚才在Fantastico web上安装的数据库表格.
  4. 恢复数据库.

当你准备好检查你的站点时,确认清除缓存 和cookies,这样你才能在浏览器中看到所做的更改。

附加信息[ ]

This article is [[WordPress::Category:Copyedits|marked]] as in need of editing. You can help Codex by editing it.