最近大家對 PIXNET 部落格發展方向似乎有不少負面聲音,對我而言倒是還好,但也抽空嘗試其他家服務,其中看到一篇文章:Hosting a WordPress Blog on Heroku with the Svbtle Theme for free ,挺有意思的,就是試了一下。試完的結果是...免費的空間不夠用 XD

根據 Heroku Postgres Basic Plan and Row Limits @ 2012/07/16

Accompanying this announcement is the implementation of a 10,000 row limit on the dev plan. This row limit was designed to correspond to the 5mb limit on the existing free shared plan.

以此 Blog 為例,進行匯入時最後只匯了約 400 篇文章,然後機器就連不到了 XDD:

$ heroku pg:info
=== HEROKU_POSTGRESQL_XXX_URL (DATABASE_URL)
Plan: Dev
Status: available
Connections: 1
PG Version: 9.2.4
Created: 2013-06-01 13:57 UTC
Data Size: 10.4 MB
Tables: 11
Rows: 1584/10000 (In compliance)
Fork/Follow: Unsupported

大概是我比較愛打字 XD 所以使用 Heroku 免費架 Blog 的方案不適合我,但 5MB size & 10000 rows 倒還可以用在其他應用囉 :D

剩下是此次操作方式:

$ git clone git://github.com/webjames/heroku-wordpress-svbtle.git
Cloning into 'heroku-wordpress-svbtle'...
remote: Counting objects: 1447, done.
remote: Compressing objects: 100% (1286/1286), done.
remote: Total 1447 (delta 130), reused 1428 (delta 120)
Receiving objects: 100% (1447/1447), 7.00 MiB | 1.16 MiB/s, done.
Resolving deltas: 100% (130/130), done.

$ cd heroku-wordpress-svbtle

$ heroku create
Creating xxxx-xxx-####... done, stack is cedar
http://xxxx-xxx-####.herokuapp.com/ | git@heroku.com:xxxx-xxx-####.git
Git remote heroku added

$ heroku addons:add heroku-postgresql:dev
Adding heroku-postgresql:dev on xxxx-xxx-####... done, v3 (free)
Attached as HEROKU_POSTGRESQL_RED_URL
Database has been created and is available
! This database is empty. If upgrading, you can transfer
! data from another database with pgbackups:restore.
Use `heroku addons:docs heroku-postgresql:dev` to view documentation.

$ heroku pg:promote HEROKU_POSTGRESQL_RED
Promoting HEROKU_POSTGRESQL_RED_URL to DATABASE_URL... done

$ git checkout -b production
Switched to a new branch 'production'

$ cp wp-config-sample.php wp-config.php
$ >.gitignore
$ git add .
$ git commit -m "Initial WordPress commit"
[production #######] Initial WordPress commit
2 files changed, 93 insertions(+)
create mode 100644 .gitignore
create mode 100755 wp-config.php

$ git push heroku production:master
Counting objects: 1450, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (1278/1278), done.
Writing objects: 100% (1450/1450), 7.00 MiB | 173 KiB/s, done.
Total 1450 (delta 132), reused 1445 (delta 130)

-----> PHP app detected
-----> Bundling Apache version 2.2.22
-----> Bundling PHP version 5.3.10
-----> Discovering process types
Procfile declares types -> (none)
Default types for PHP -> web

-----> Compiled slug size: 16.0MB
-----> Launching... done, v6
http://xxxx-xxx-####.herokuapp.com deployed to Heroku

To git@heroku.com:xxxx-xxx-####.git
* [new branch] production -> master

其他部分:

將 Wordpress 設定為必須登入才能看到文章:

$ cat wp-blog-header.php
<?php
/**
* Loads the WordPress environment and template.
*
* @package WordPress
*/
if ( !isset($wp_did_header) ) {

  $wp_did_header = true;

  require_once( dirname(__FILE__) . '/wp-load.php' );

  if ( !is_user_logged_in() ) {   // 太久沒用 wordpress ,印象中有選項可以設定:限定登入才能看到文章
    auth_redirect();
    exit;
  }

  wp();

  require_once( ABSPATH . WPINC . '/template-loader.php' );

}

啟用 MT 匯入功能:

$ wget -qO- http://downloads.wordpress.org/plugin/movabletype-importer.zip | tar -xvf - -C wp-content/plugins/
$ git add .
$ git commit -am 'add movabletype-importer plugin'
$ git push heroku production:master

由於 heroku 僅能上傳 2MB 大小的檔案,若你的 Blog 之 MT 備份檔超過 2MB 的話,可以擺在 blog site 匯入。

$ cp /path/you_blog_backup.txt wp-content/mt-export.txt
$ git add .
$ git commit -am 'add mt-export.txt'
$ git push heroku production:master

接著就可以去後台管理來匯入資料。


, , , , , , , , , ,

changyy 發表在 痞客邦 PIXNET 留言(0) 人氣()