msn email google-talk twitter tumblr flickr

passenger+nginx on MAC OS X

我对apache不是太感冒 就装个passenger+Nginx来赶时髦

http://blog.phusion.nl/2009/04/16/phusions-one-year-anniversary-gift-phusion-passenger-220/

使用gem安装passenger过程比预想的简单 不过还是遇到些问题 记录下过程方便同遇到问题的童鞋~

    sudo gem install passenger
    sudo passenger-install-nginx-module

gem会自动先去下载PCRE (required by Nginx) 然后去下载nginx

curl http://sysoev.ru/nginx/nginx-0.7.64.tar.gz -o /tmp/nginx-0.7.64.tar.gz

我在这里出了个问题

Unable to download or extract Nginx source tarball

断在下载nginx的过程

思前想后 虽然默认下载的nginx版本低了 但是按理说应该还是能下载到 也许我的网路问题吧 直接去down了最新的nginx-0.8.27

重跑sudo passenger-install-nginx-module

选择2. No: I want to customize my Nginx installation. (for advanced users)

过程提示你的nginx源码地址 给个绝对地址(我试了下"~/“之类的它是不认的) 之后就是配置的事儿了 结束后提示如下:

    Nginx with Passenger support was successfully installed.

    The Nginx configuration file (/opt/nginx/conf/nginx.conf)
    must contain the correct configuration options in order for Phusion Passenger
    to function correctly.

    This installer has already modified the configuration file for you! The
    following configuration snippet was inserted:

      http {
          ...
          passenger_root /Library/Ruby/Gems/1.8/gems/passenger-2.2.7;
          passenger_ruby /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby;
          ...
      }

    After you start Nginx, you are ready to deploy any number of Ruby on Rails
    applications on Nginx.
    --------------------------------------------
    Deploying a Ruby on Rails application: an example

    Suppose you have a Ruby on Rails application in /somewhere. Add a server block
    to your Nginx configuration file, set its root to /somewhere/public, and set
    'passenger_enabled on', like this:

       server {
          listen 80;
          server_name www.yourhost.com;
          root /somewhere/public;   # <--- be sure to point to 'public'!
          passenger_enabled on;
       }

    And that's it! You may also want to check the Users Guide for security and
    optimization tips and other useful information:

      /Library/Ruby/Gems/1.8/gems/passenger-2.2.7/doc/Users guide Nginx.html

上面这行就是传说中的文档之所在咯 啥也不说了 自己啃吧…

附上几条童鞋们有可能用到的语句

    mate /opt/nginx/conf/nginx.conf
    mate /etc/hosts
    ps -aux|grep nginx
    sudo /opt/nginx/sbin/nginx 
    sudo killall -m 'nginx'