Capistrano エラーが出てデプロイ出来ない
- bundle exec cap production deployすると以下のエラーが出る
実行bundle exec cap production deploy 01 $HOME/.rbenv/bin/rbenv exec bundle install --path /var/www/zen/shared/bundle --without development test --deployment --quiet 01 rbenv: bundle: command not found (Backtrace restricted to imported tasks) cap aborted! SSHKit::Runner::ExecuteError: Exception while executing as hoge@99.11.11.11: bundle exit status: 127 bundle stdout: Nothing written bundle stderr: rbenv: bundle: command not found SSHKit::Command::Failed: bundle exit status: 127 bundle stdout: Nothing written bundle stderr: rbenv: bundle: command not found Tasks: TOP => deploy:updated => bundler:install (See full trace by running task with --trace) The deploy has failed with an error: Exception while executing as hoge@99.11.11.11: bundle exit status: 127 bundle stdout: Nothing written bundle stderr: rbenv: bundle: command not found ** DEPLOY FAILED ** Refer to log/capistrano.log for details. Here are the last 20 lines:
- サーバ側でbundlerをインストール
rbenv exec gem install bundler
- 次はmigrateでエラー
01:58 deploy:migrate [deploy:migrate] Run `rake db:migrate` 01:58 deploy:migrating 01 $HOME/.rbenv/bin/rbenv exec bundle exec rake db:migrate 01 rake aborted! 01 PG::ConnectionBad: FATAL: Peer authentication failed for user "zen"
- ユーザ作成してロール付与、データベース作ってみる
[hoge@ip-10-0-0-62 20161013121524]$ su - postgres パスワード: -bash-4.2$ psql postgres psql (9.2.18) Type "help" for help. postgres=# create user zen; CREATE ROLE postgres=# alter role zen createdb; ALTER ROLE postgres=# \du List of roles Role name | Attributes | Member of -----------+------------------------------------------------+----------- postgres | Superuser, Create role, Create DB, Replication | {} zen | Create DB postgres=# CREATE DATABASE hoge_production; CREATE DATABASE
まだエラーが出る
sudo find / -name "pg_hba.conf" /var/lib/pgsql9/data/pg_hba.conf sudo vim /var/lib/pgsql9/data/pg_hba.conf local を peerからmd5に変更 sudo /sbin/service postgresql restart 00:13 deploy:migrating 01 $HOME/.rbenv/bin/rbenv exec bundle exec rake db:migrate 01 rake aborted! 01 PG::ConnectionBad: fe_sendauth: no password supplied
sudo su postgres -c 'psql --username=postgres' ALTER USER postgres with encrypted password 'paasss'
local を peerからtrustに変更したら動いた、多分セキュリティ的にダメなんかなぁ