Ruby On Rails, Thin and Nginx on Windows

安装thin:

gem install eventmachine --pre
gem install thin

启动thin服务:

在rails的app目录上输入 thin start

 

配置nginx(nginx.conf):

worker_processes  1;
error_log  C:/StandAlone/nginx/logs/error.log;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
 
    sendfile        on;
    #keepalive_timeout  0;
    keepalive_timeout  65;
    #gzip  on;
    include C:/StandAlone/nginx/sites_enabled/*.txt;
}
 

其中include意思是从这个目录时加载其它外部配置,按着配置文件、在nginx目录下新建sites_enabled文件夹,接下来在里面建立 mystandalone app.com.txt文件、输入以下内容:

upstream mystandaloneapp {
     server 127.0.0.1:3000;
 }
  
 server {
     listen       80;
     server_name  localhost;
     #charset koi8-r;
  
     access_log C:/StandAlone/www/mystandaloneapp.com/log/access.log;
     error_log  C:/StandAlone/www/mystandaloneapp.com/log/error.log;
     root       C:/StandAlone/www/mystandaloneapp.com;
     index      index.html;
  
     location / {
         proxy_set_header  X-Real-IP  $remote_addr;
         proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_set_header  Host $http_host;
         proxy_redirect    off;
         try_files C:/StandAlone/www/maintenance.html $uri $uri/index.html $uri.html @ruby;
     }
  
     location @ruby {
         proxy_pass http://mystandaloneapp;
     }
 }

 

这里的配置就是把thin的3000端口转化成正常的80端口,注意目录都要填写你的实际目录,然后运行nginx命令便可以成功运行了

 

Nginx的命令

nginx -s [ stop | quit | reopen | reload ]

 

参考:http://www.beechtreetech.com/ruby-on-rails-thin-and-nginx-on-windows

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值