nginx+unicorn+capistrano+railsをansibleも交えてやってみる...(完全ではない)

January 17, 2015

前回の[rails 1=”-” 2=“Morizotter” 3=“Blog” language=“+unicornをやってみる”]/railsに引き続き、unicornの設定を書いてcapistranoでデプロイしてみます。目的はとりあえずこの形で表示されること。綺麗さは問いません…。とりあえずは。

一つ一つていねいにはまっていったんだけど、ハマりすぎてまとめられなかった。覚えている箇所を箇条書きにして、参考記事があれば貼っておく。

主に、「Ruby - Capistrano3でUnicorn+Nginxな環境にRailsをデプロイする:初心者向け - Qiita」を参考にさせて頂いてやりました。ただ、環境設定などでうまく行かずかなりハマリました。

いちおう、Railsのページが表示された段階の記録。。。

後で参照することもあるだろうから貼っておく。

Capistrano-rbenv

DEBUG [547b3771] /usr/bin/env: bundle: そのようなファイルやディレクトリはありません cap aborted! SSHKit::Runner::ExecuteError: Exception while executing as root@178.62.117.89: bundle exit status: 127 bundle stdout: Nothing written bundle stderr: Nothing written

SSHKit::Command::Failed: bundle exit status: 127 bundle stdout: Nothing written bundle stderr: Nothing written

Tasks: TOP => deploy:updated => bundler:install (See full trace by running task with —trace) The deploy has failed with an error: #

下記のサイトを参考に、capistrano-rbenvを導入してパスできました。

502 Bad Gateway

Badgateway

unicorn.sockの置き場の問題。当初、/tmp/unicorn.sockにおいていたんだけれど、この状態だとずっと502エラーが出てダメだった。下記のStackoverflowを参考に、/var/run/unicorn.sockに置いたら、エラーが出なくなった。

Rails 4 + nginx + unicorn + ssl = 502 Bad Gateway - Stack Overflow

参考

あ、あと、Ansibleでデプロイしてもいいんじゃないかと思った。後学のために。


Profile picture

Written by morizotter who lives and works in Tokyo building useful things. You should follow them on Twitter