LoginSignup
20
21

More than 5 years have passed since last update.

Ghostで作ったブログをherokuに公開する

Posted at

基本的な手順は以下の通りで良いのです。
http://www.howtoinstallghost.com/how-to-install-ghost-on-heroku/

ですがいくつかはまったポイントがありました。
まず、Procfileの作成の際。

web: node index.js --production

このように書くようにとありますが、これでherokuにpushすると、
heroku logs -t でログを見ると "Ghost is running in development..."と表示されてました。
試しにローカルのGhostのディレクトリで node index.js --production で起動してみると、やはりdevelopmentでした。

そこで次の通り修正しました。

web:  NODE_ENV=production node index.js

これでproductionで動かす事ができました。
ところがログを見ると今度は "Module pg not found" でまたしてもエラー。。
Ghostをnpm installするとnpmのライブラリは「node_modules」以下に格納されるのですが、その中に"pg"がないと。
pgはpostgresqlを利用するためのライブラリです。
ではインストール。

npm install pg --production

--productionオプションは、testファイルなどの開発用のコードをインストールしないためにつけておくと良いと思います。
Ghostのインストール時にもつけるオプションです。
すると今度は、"pg_config: command not found"で失敗。
CentOS環境なのでyumでインストールします。

yum install postgresql_devel

その後pgを再インストールして、herokuにpushすると、無事Ghostのトップ画面が表示されました。

20
21
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20
21