GhostをさくらVPSに入れてつまづいた | とあるプログラマーのブログ

とあるプログラマーのブログ

Unityやblender、Live2Dについて書いていきます!

Ghost とはnode.js製のブログプラットフォームです。

そろそろ自前のブログにしようと思ってたのでレンタルサーバに入れてみました
WordPressか悩んでましたが、こちらの方が小規模で読込スピードが早いみたいです。


[ 参考記事 ] 
ブログプラットフォーム「Ghost」はいま使うべきか?待つべきか?


Ghostの日本語ページを見て、以下の手順通りに実践してみました。

LinuxにGhostをインストールする方法 


# Ghostの最新版をダウンロードします
$ curl -L https://ghost.org/zip/ghost-latest.zip -o ghost.zip

# 解凍
$ unzip -uo ghost.zip -d ghost

# Ghostをインストールします
$ cd ghost
$ npm install --production

npm WARN package.json connect-slashes@0.0.9 No repository field.
npm http GET https://registry.npmjs.org/sqlite3/2.1.16
 ・
 ・
Build failed
[sqlite3]: 1
npm ERR! sqlite3@2.1.16 install: `node build.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the sqlite3@2.1.16 install script.
npm ERR! This is most likely a problem with the sqlite3 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node build.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls sqlite3
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 2.6.32-358.6.1.el6.x86_64
npm ERR! command "node" "/usr/bin/npm" "install" "--production"
npm ERR! cwd /home/naotaro/ghost
npm ERR! node -v v0.11.9
npm ERR! npm -v 1.3.21
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/naotaro/ghost/npm-debug.log
npm ERR! not ok code 0


なんかエラーでまくった
ghotst配下のpackage.jsonのsqlite3バージョンを2.1.16→2.1.18に修正したら直った
 → 参考ページ



# 再度、Ghostのインストール実行
$ npm install --production

gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:101:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:827:12)
gyp ERR! System Linux 2.6.32-358.6.1.el6.x86_64
gyp ERR! command "node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--production"
gyp ERR! cwd /home/naotaro/ghost/node_modules/sqlite3
gyp ERR! node -v v0.11.9
gyp ERR! node-gyp -v v0.12.1
gyp ERR! not ok 
[sqlite3]: Error: Failed to execute 'node-gyp rebuild --production' (1)
npm ERR! sqlite3@2.1.18 install: `node build.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the sqlite3@2.1.18 install script.
npm ERR! This is most likely a problem with the sqlite3 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node build.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls sqlite3
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 2.6.32-358.6.1.el6.x86_64
npm ERR! command "node" "/usr/bin/npm" "install" "--production"
npm ERR! cwd /home/naotaro/ghost
npm ERR! node -v v0.11.9
npm ERR! npm -v 1.3.21
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/naotaro/ghost/npm-debug.log
npm ERR! not ok code 0


またエラーでまくった
node v.0.10.xを使えよとおっしゃる → 参考ページ
僕は最新のv.0.11.9なのでダウングレードしました。


# インストールできるnode.jsバージョン確認
$ nodebrew ls-remote

# v0.10.x系で最新のを入れる(5分ぐらいかかった...)
$ nodebrew install v0.10.24

# 使用するnodeを選択
$ nodebrew use v0.10.24
$ node -v

3度目のGhostインストール実行
$ npm install --production


ここまでくればひと安心

# 設定ファイルのURLとポート、IPを修正します
$ vim config.js

config = {   
 development:{
  url:'自分のサイトURL',
  server:{
   host:'自分のサーバIPアドレス',
   port:'任意のポート番号'
  }
 }
}

# 開発用モードで起動
$ npm start 

# サイトにアクセス
http://自分のサイトURL:ポート番号



もちろん、対象のポート番号のファイアウォール設定も忘れずに