Created
April 8, 2012 13:28
-
-
Save tbaba/2337316 to your computer and use it in GitHub Desktop.
Nginx and Unicorn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rack' | |
class Hello | |
def call(env) | |
[200, {'Content-Type' => 'text/plain'}, ['Hello, Nginx!']] | |
end | |
end | |
run Hello.new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 2012/04/08時点のStable版は1.0.14らしいです | |
$ wget http://nginx.org/download/nginx-1.0.14.tar.gz | |
$ tar zxvf nginx-1.0.14.tar.gz | |
$ cd nginx-1.0.14 | |
# モジュール的なもの(例えばgzipとかsslとか)はconfigureの段階で書いておかないと、再度コンパイルし直すことになるので注意! | |
$ ./configure --with-http_gzip_static_module --with-http_ssl_module | |
$ make | |
$ sudo make install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ gem install unicorn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# デフォルトのprefixだとnginxは /usr/local/nginx にインストールされるようです | |
$ /usr/local/nginx/sbin/nginx | |
# コンフィグを再読み込みしたいときはreloadする | |
$ /usr/local/nginx/sbin/nginx -s reload | |
# 停止させたいときはstop | |
$ /usr/local/nginx/sbin/nginx -s stop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cd /path/to/your/app | |
$ unicorn -c unicorn.conf | |
# ここで -D オプションをつけるとデーモン起動させることも可能です。ログを見たかったらそのまんま起動して、別のターミナルで作業しましょう。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
listen '/tmp/unicorn.sock' | |
worker_processes 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream unicorntest { | |
server "unix:/tmp/unicorn.sock"; | |
} | |
server { | |
listen 80; | |
server_name localhost; | |
location ~ / { | |
proxy_pass http://unicorntest; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment