Skip to content

Instantly share code, notes, and snippets.

@gaspanik
Created January 5, 2014 09:00
Show Gist options
  • Select an option

  • Save gaspanik/8266041 to your computer and use it in GitHub Desktop.

Select an option

Save gaspanik/8266041 to your computer and use it in GitHub Desktop.

How To Serve Multiple Ghost Blogs on One VPS

1個のVPSで複数のGhostを立ち上げる方法。といっても、下に書いてあるとおりなんですが…w

→ How To Serve Multiple Ghost Blogs on One VPS Using Nginx Server Blocks | DigitalOcean

Digital Oceanは、Ghostの入ったドロップレットが用意されているので、セットアップでそれを選べば1分でサイトは用意できます。Ghost側のconfig.jsとかちょいちょいっと修正すればあっという間に完成です。

でも、今のバージョンのGhostは1インストールで複数のブログを設置することができないので、複数のサイトを立ち上げたい時はサブドメインとかで分けてそれぞれを起動する必要があります。Digital OceanのGhostのドロップレットは「Ubuntu+nginx」なので、最初に任意のホストを登録した後に(Ghost動かしてからでもいいけど)nginxの設定を2つ分けてあげればオッケー。

GhostとNginxを止める

まずは

service ghost stop

でGhostをストップ。

service nginx stop

でNginxをストップ。

Nginxの設定を2つ作る

Nginxの設定は「/etc/nginx/conf.d/」にある「default.conf」。これをコピーして2つの設定ファイルを作る。やることは、ホスト名(server_name)の書き換えと2台目のProxyのポート(proxy_pass)の変更。

cp default.conf firstsite.com.conf && mv default.conf second.net.conf

みたいな感じで2つにわけて。2台目のproxy_passの数字を空いてるポート(2777とか)にする。

service nginx start

書き換えが終わったら、ファイルを保存してNginxを再起動。

Ghostを複数のディレクトリにいれる

Digital Oceanの初期設定では、ルートディレクトリに「ghost」がポツンと置かれてるので、まずは作りたいホスト分のディレクトリを用意。

mkdir firstsite.com secondsite.net

で、元々あったghostディレクトリをそれぞれにコピーする。

cp -r ghost firstsite.com && mv ghost secondsite.net

とりあえず「/var/www」以下に、「firstsite.com」「secondsite.net」のディレクトリ、その中に「ghost」のディレクトリがあればよし。

それぞれのconfig.jsを変更

あとは、それぞれのghostディレクトリにある「config.js」を変更する。

「development」のとこは無視して、「production」のとこの「URL」と「port」のところ。

起動用のスクリプトを作って起動

最後に起動用のスクリプトを作っておしまい。すべてはココに書いてある。

→ How To Serve Multiple Ghost Blogs on One VPS Using Nginx Server Blocks | DigitalOcean

ドメインさえ割り当てていれば、ほんの10分ほどで終わるはず。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment