如何把wordpress博客搬到Google App Engine

字体大小:


Google App Engine(GAE)是google的互联网应用程序引擎服务。用户可以使用提供的API开发自己的网站或互联网应用,而服务器、带宽等全部有Google的服务器集群来实现。GAE被开发者视为高速、免费的虚拟主机

目前的预览版本支持:
1、每个用户10个应用(application)。
2、每个应用500M存储空间和每月 500 万综合浏览量。

这些用来搭建一个小型的网站绰绰有余了。如果你的博客是,想搬到Google App Engine上,有有些困难,由于GAE目前支持python,而wordpress 是php程序。把wordpress的数据导入到一个可以在GAE运行的blog程序里,是迁移最实用的办法。

我把守望轩的博客就在GAE上做了一个镜像:http://watch-life.appspot.com/

下面我提供我尝试的方法:
http://www.watch-life.net/wordpress/wordpress-2-gae.html

1、注册GAE
链接:http://appengine.google.com/

注册必须是Gmail用户。

2、登录GAE,新建一个应用(application)
比如我新建的应用名为:watch-life

3、下载、安装App Engine SDK
链接:http://code.google.com/intl/zh-CN/appengine/downloads.html

比如我的安装目录为:D:\Program Files\Google\google_appengine

4、下载、安装python 2.5
链接:http://www.python.org/ftp/python/2.5.4/python-2.5.4.msi

为什么是2.5呢?因为目前GAE只支持2.5。

5、下载micolog 博客程序http://code.google.com/p/micolog/

目前的版本是0.5 。我只所以选择这个blog程序,是因为micolog 可以用导入wordpress的导出xml数据,兼容性不错,文章、分类都可以导入,而且支持永久链接。

6、安装micolog 博客程序。

1)把micolog 复制到GAE的安装目录(你可以对micolog目录名改名,比如我就改名为“watch-life”),修改app.yaml文件中的第一行,把“application:”后面的“mlog”,改成你在GAE上新建的应用名。比如,我就改成:application:watch-life

2)开始-运行-cmd,进入D:\Program Files\Google\google_appengine,输入命令:appcfg.py update watch-life/,然后根据提示输入gmail地址和密码,通过后会上传micolog 博客程序。这时你就可以访问你在GAE上的博客了,访问的地址为:http://应用名.appspot.com, 比如我的就是:http://watch-life.appspot.com

7、导出wordpress的xml数据。
登录到你的wordpress博客后台,在左侧导航栏选择:工具+导出,单击“下载导出文件”按钮即可。

8、在micolog 博客导入wordpress的xml数据。
1)、登录你刚刚在GAE上建好的博客程序,登录的用户名和密码和你Gmail的一样,因为应用的是google api 中用户服务,集成了Google 用户帐户。

2)在导航栏选择“设置+导入/导出”,选择导入xml文件(即从wordpress导出的xml数据文件),单击“导入”按钮即可。

在导入前要注意几点:

1、如果导入的xml文件如果很大的,是会超时导入失败的。我最开始导出的xml有1.8m,导入的时候就失败了,最开始以为是导入的程序有问题,把xml分成n多部分后分开导入,才成功了。

如何分割导出xml文件呢。xml文件里的结构是这样的:

<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" ...>
<channel>
.....
<wp:category>
</wp:category>
...
<wp:tag>
</wp:tag>
<item>
</item>
..
</channel>
</rss>

wp:category 节点表示分类
wp:tag 节点表示tag
item节点表示文章
其中的wp:tag节点可以全部删除,因为在导入的时候是被忽略的。

制作第一个xml,导入分类(在micolog 里叫目录)只保留wp:category 节点
,类似如下代码:

<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" ...>
<channel>.....

<wp:category>
</wp:category>
...

</channel>
</rss>

然后制作第二个xml,只保留一部分item节点(最好在50个item内,多了会导入失败),类似如下代码:

<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" ...>
<channel>.....

<item>
</item>
..
</channel>
</rss>

接下来制作第三个,方法类似,以此类推。

2、在wordpress的导出xml文件中有些item节点有些问题(估计是wordpress的bug),这些有问题的item节点居然用图片文件做节点,例如

<item>
  <title>gohome.jpg</title>
  ..
  </item>

如果存在这样的item节点,会导致导入中止,因此在导入中止的时候,需要检查是否存在这样的item节点。

3、永久链接(Permalink)不支持category参数,因此不能把永久链接设置为:%(category)s/%(postname)s.html,只用“%(year)s , %(month)s , %(day)s , %(postname)s , %(post_id)s”这几个参数。同时设置方式也和wordpress有些差别。

等把所有的xml都导入完后,整个迁移的工作就算完成了。

update 20090327:
配置Windows live writer 支持micolog博客
配置Windows live writer,Windows live writer中新增一个日志账户,其中提供者和接入地址,类型选择wordpress2.2+,接口为网址后面加/rpc,比如我的就是:http://watch-life.appspot.com/rpc

你有没有兴趣试试。:-)

有关链接:

1、Google App Engine:http://appengine.google.com/
2、micolog博客程序:http://code.google.com/p/micolog/downloads/list
3、python :http://www.python.org

你可能也会喜欢以下文章:

永久链接(Permalink):http://www.watch-life.net/wordpress/wordpress-2-gae.html

Tags: , , ,



  1. 网友评论( 16 )

嗯!真不錯。。。我也試著做了一個,成功了!!

非常感謝!!

不客气

目前的预览版本支持:
1、每个用户10个应用(application)。
2、每个应用500M存储空间和每月 500 万综合浏览量。
这是天文数字嘛 这么苛刻

to thatguy :为什么说苛刻呢?

昨天晚上尝试了弄了,结果一直不成功
Google App EngineMicrosoft Windows XP [版本 5.1.2600]
(C) 版权所有 1985-2001 Microsoft Corp.

C:\Documents and Settings\Administrator>cd C:\Program Files\Google\google_appeng
ine

C:\Program Files\Google\google_appengine>appcfg.py update yyssblog/
Loaded authentication cookies from C:\Documents and Settings\Administrator/.appc
fg_cookies
Scanning files on local disk.
Initiating update.
2009-06-12 07:20:45,233 ERROR appcfg.py:1334 An unexpected error occurred. Abort
ing.
Error 403: — begin server output —
You do not have permission to modify this app (app_id=u’yyssblog’).
— end server output —

C:\Program Files\Google\google_appengine>appcfg.py update 5245ssss/
Loaded authentication cookies from C:\Documents and Settings\Administrator/.appc
fg_cookies
Scanning files on local disk.
Initiating update.
Could not guess mimetype for static/images/favicon.ico. Using application/octet
-stream.
Cloning 20 static files.
Cloning 91 application files.
Uploading 3 files.
Closing update.
Uploading index definitions.
Error 400: — begin server output —
Creating a composite index failed: This index:
entity_type: “Archive”
ancestor: false
Property {
name: “date”
direction: 2
}

is not necessary, since single-property indices are built in. Please remove it f
rom your index file and upgrade to the latest version of the SDK, if you haven’t
already.
— end server output —

C:\Program Files\Google\google_appengine>appcfg.py update sxxaliuwei/
Usage: appcfg.py [options] update

appcfg.py: error: Not a directory: sxxaliuwei/

C:\Program Files\Google\google_appengine>appcfg.py update sxxaliuwei\
Usage: appcfg.py [options] update

appcfg.py: error: Not a directory: sxxaliuwei\

C:\Program Files\Google\google_appengine>appcfg.py update sxxaliuwei\
Loaded authentication cookies from C:\Documents and Settings\Administrator/.appc
fg_cookies
Scanning files on local disk.
Initiating update.
Could not guess mimetype for static/images/favicon.ico. Using application/octet
-stream.
Cloning 20 static files.
Cloning 91 application files.
Uploading 3 files.
Closing update.
Uploading index definitions.
Error 400: — begin server output —
Creating a composite index failed: This index:
entity_type: “Archive”
ancestor: false
Property {
name: “date”
direction: 2
}

is not necessary, since single-property indices are built in. Please remove it f
rom your index file and upgrade to the latest version of the SDK, if you haven’t
already.
— end server output —

C:\Program Files\Google\google_appengine>

to 小伟 : 我 对python 不是很了解,不知道你说的问题出在哪里

应该是python的版本太高了,我开始用的是2.6,后来换回2.5.4版本就ok了

不好意思,弄错了,可以看这篇文章

http://keeng2008.appspot.com/2009/05/12/gaeUploadError.html

删掉只有单个属性的索引就可以了

to don :你的链接很有用

谢谢博主,我成功建站了。

8楼说的修改版本可以到这里下载http://www.diqiu.org.ru/set-up-micolog.html

您好,我按照您的方法成功建立了博客,非常谢谢哈
我现在遇到一个问题,我不知道怎样绑定自己的域名,我试着按照网上查到的方法试着绑定了一下,好像不行,希望能够得到你的帮助,谢谢哈,呵呵

to 叙:有关域名绑定参见:http://donauya.spaces.live.com/blog/cns!F53B4DB2F7D1A8A1!131.entry

成功了,谢谢博主

你好:)

有个问题,如何保证GAE上的博客及时更新呢?

也就是说,每次你往http://www.watch-life.net写的文章,如何才可以不用再写手动设置一遍到GAE上的那个博客:http://watch-life.appspot.com/呢?

还是你每次用Windows live writer发一篇新文章的时候,直接往两个博客同时输出?

to WaterSky :我是用Windows live writer 一稿多投。;-)

  1. 3 条Trackback(s)


  2. 2009-04-9 18:18: 如何把wordpress博客搬到Google App Engine

发表评论