安装thin:
gem install eventmachine --pre
gem install thin
启动thin服务:
配置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