yxxs123 发表于 2016-12-26 08:58:22

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_processes1;
error_logC:/StandAlone/nginx/logs/error.log;
events {
worker_connections1024;
}
http {
include       mime.types;
default_typeapplication/octet-stream;
log_formatmain'$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
sendfile      on;
#keepalive_timeout0;
keepalive_timeout65;
#gzipon;
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_namelocalhost;
#charset koi8-r;
access_log C:/StandAlone/www/mystandaloneapp.com/log/access.log;
error_logC:/StandAlone/www/mystandaloneapp.com/log/error.log;
root       C:/StandAlone/www/mystandaloneapp.com;
index      index.html;
location / {
proxy_set_headerX-Real-IP$remote_addr;
proxy_set_headerX-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_headerHost $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
页: [1]
查看完整版本: Ruby On Rails, Thin and Nginx on Windows