3、 选1, 然后选2, 安装本地的安装包
4、 加参数--with-ld-opt="-L /usr/local/lib"
5、 成功后sudo ln -s /usr/local/nginx/sbin/nginx /usr/sbin/
6、配置Nginx + Passenger + Rails
关于Nginx的配置,请参考Nginx的官方网站以及Passenger的官方网站
修改hosts文件,给你的项目一个本地域名, 比如awesome_project.local
$ sudo vim /etc/hosts
127.0.0.1 awesome_project.local
测试hosts
$ ping awesome_project.local
PING awesome_project.local (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.054 ms
继续配置Nginx, 这里我给出一个最小可运行的Nginx配置文件
vim /usr/local/nginx/conf/nginx.conf
nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
passenger_root /Users/Daniel/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.10;
passenger_ruby /Users/Daniel/.rvm/wrappers/ruby-1.9.2-p290/ruby;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name awesome_project.local;
root /Users/Daniel/awesome_project/public;
passenger_enabled on;
rails_env development;
}
}
测试Nginx的配置文件语法是否正确
$ sudo nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
启动Nginx
$ sudo nginx
如何在修改Nginx的配置文件后,让Nginx载入新配置
$ sudo nginx -s reload
如何停止Nginx
$ sudo nginx -s stop
如何在不停Nginx的情况下,重新启动Passenger
$ cd path/to/your/awesome/project
$ touch tmp/restart.txt
好了,这个时候你可以打开浏览器,访问你的awesome_project网站了
http://awesome_project.local