nginx+unicornでうまく生きません><

センセーにこんな指南を受けて

https://twitter.com/#!/rosylilly/status/194062009594163200

確かに、それまでstderr_pathに出ていたエラーが下記なので、ソケットがつながらなかったようであった。

E, [2012-04-22T23:47:43.012801 #2673] ERROR -- : adding listener failed addr=/tmp/unicorn.sock (in use)
E, [2012-04-22T23:47:43.013081 #2673] ERROR -- : retrying in 0.5 seconds (4 tries left)
E, [2012-04-22T23:47:43.515428 #2673] ERROR -- : adding listener failed addr=/tmp/unicorn.sock (in use)
E, [2012-04-22T23:47:43.515561 #2673] ERROR -- : retrying in 0.5 seconds (3 tries left)
E, [2012-04-22T23:47:44.017541 #2673] ERROR -- : adding listener failed addr=/tmp/unicorn.sock (in use)
E, [2012-04-22T23:47:44.017658 #2673] ERROR -- : retrying in 0.5 seconds (2 tries left)
E, [2012-04-22T23:47:44.519601 #2673] ERROR -- : adding listener failed addr=/tmp/unicorn.sock (in use)
E, [2012-04-22T23:47:44.519719 #2673] ERROR -- : retrying in 0.5 seconds (1 tries left)
E, [2012-04-22T23:47:45.021640 #2673] ERROR -- : adding listener failed addr=/tmp/unicorn.sock (in use)
E, [2012-04-22T23:47:45.021850 #2673] ERROR -- : retrying in 0.5 seconds (0 tries left)
E, [2012-04-22T23:47:45.523848 #2673] ERROR -- : adding listener failed addr=/tmp/unicorn.sock (in use)
/usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.2.1/lib/unicorn/socket_helper.rb:140:in `initialize': Address already in use - /tmp/unicorn.sock (Errno::EADDRINUSE)
from /usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.2.1/lib/unicorn/socket_helper.rb:140:in `new'
from /usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.2.1/lib/unicorn/socket_helper.rb:140:in `bind_listen'
from /usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.2.1/lib/unicorn/http_server.rb:224:in `listen'
from /usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.2.1/lib/unicorn/http_server.rb:739:in `block in inherit_listeners!'
from /usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.2.1/lib/unicorn/http_server.rb:739:in `each'
from /usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.2.1/lib/unicorn/http_server.rb:739:in `inherit_listeners!'
from /usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.2.1/lib/unicorn/http_server.rb:123:in `start'
from /usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.2.1/bin/unicorn_rails:209:in `'
from /usr/local/bin/unicorn_rails:23:in `load'
from /usr/local/bin/unicorn_rails:23:in `

'

最初に悩んだ現象は回避されたものの、
再度

# unicorn_rails -c (railsアプリルート)/config/unicorn.rb -E production -D

やると別のエラー。

I, [2012-04-23T00:53:39.085709 #17065] INFO -- : unlinking existing socket=/tmp/unicorn.sock
I, [2012-04-23T00:53:39.086146 #17065] INFO -- : listening on addr=/tmp/unicorn.sock fd=5
I, [2012-04-23T00:53:39.086969 #17065] INFO -- : Refreshing Gem list
/usr/local/lib/ruby/1.9.1/yaml.rb:56:in `':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require': cannot load such file -- openssl (LoadError)
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `block in require'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in `load_dependency'
・・・・

何だろうか。。

現在の設定とか書いてある内容まとめ。

(railsアプリルート)/config/unicorn.rb

worker_processes 4
working_directory '(railsアプリルート)/'

listen '/tmp/unicorn.sock'
pid '/tmp/unicorn.pid'

stdout_path '(railsアプリルート)/log/unicorn.stdout.log'
stderr_path '(railsアプリルート)/log/unicorn.stderr.log'

preload_app true

/etc/nginx/nginx.conf

最後に追加
include /etc/nginx/sites-enabled/*;

/etc/nginx/sites-enabled/demo

upstream (ドメイン) {
server 127.0.0.1:8080;
}
server {
listen 80;
server_name (ドメイン);
location / {
proxy_pass http://(ドメイン);
allow all;
}
}