mattak's blog

人生を1ミリ進める

nginxインストール

おおー

nginxでwebsocketサポートとか

http://qiita.com/items/484aa9bfb7bc4206ffed

ためそー

インストール

$ aptitude show nginx
Package: nginx                           
State: not installed
Version: 1.1.19-1ubuntu0.1
Priority: optional
Section: universe/web
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: all
Uncompressed Size: 86.0 k
Depends: nginx-full | nginx-light
Provided by: nginx-extras, nginx-full, nginx-light, nginx-naxsi
Description: small, but very powerful and efficient web server and mail proxy
 Nginx (engine x) is a web server created by Igor Sysoev and kindly provided to the open-source community. This
 server can be used as standalone HTTP server and as a reverse proxy server before some Apache or another big
 server to reduce load to backend servers by many concurrent HTTP-sessions. 

 This is a dummy package that selects nginx-full by default, but also can be installed with nginx-light for
 upgrading to nginx-light directly.
Homepage: http://nginx.net

くっ、1.1.19か。

websocketをサポートしたのは1.3.13からで間違いなさそう。 https://github.com/nginx/nginx/blob/master/CHANGES

ソースからビルド。

$ curl -O http://nginx.org/download/nginx-1.3.14.tar.gz
$ tar xzvf nginx-1.3.14.tar.gz

nginxって、ロシアの人がつくってるのか。。

$ cd nginx-1.3.14
$ ./configure

perl正規表現が使えるライブラリがはいってなかった。

$ sudo aptitude install libpcre3-dev
$ ./configure
$ make 
$ make install

あ、passengerもいれよ。

$ gem i passenger
(1: auto build 1.2.6, 2: custom install)
> 2 
(where soure?)
> /home/user/src/nginx-1.3.14
(install location)
> /usr/local/nginx
Extra arguments to pass to configure script:
The Nginx configure script will be run as follows:
Is this what you want? (yes/no) [default=yes]:
permission failed.

途中にでてきたconfigureをつかう。

$ ./configure --prefix='/usr/local/nginx' --with-http_ssl_module --with-http_gzip_static_module --with-cc-opt='-Wno-error' --add-module='/home/maruyama/.rbenv/versions/1.9.3-p385/lib/ruby/gems/1.9.1/gems/passenger-3.0.19/ext/nginx'
$ make 
$ make install

起動

$ /usr/local/nginx/sbin/nginx

nginx.conf

http {
...

    include /usr/local/nginx/conf/sites-enabled/*;
}

シンボリックリンクをホームにはった。

$ ln -s /home/user/etc/nginx/sites-enabled /usr/local/nginx/conf/site-enabled

sites-enabled以下に試しに各種設定書いた。

$ cat ~/etc/nginx/site-enabled/shurl
passenger_root /home/user/.rbenv/versions/1.9.3-p385/lib/ruby/gems/1.9.1/gems/passenger-3.0.19;
passenger_ruby /home/user/.rbenv/shims/ruby;

server {
    listen  80;
    server_name shurl.localhost;

    root /home/user/path/to/ruby/project/public;
    passenger_enabled on;
    passenger_base_uri /;

    access_log /home/user/var/log/nginx/access.log;
}

できた!

websocket使うのはまたこんどに。。