在nginx rails ruby thin 等软件都安装好的情况下 ubuntu server下的配置

首先配置nginx
upstream blog.hhailuo.com {
#用端口方式去启动网站 用rails s -p3000
# server 127.0.0.1:3000;
# 用sock方式去启动网站 用thin服务器(个人推荐)
server   unix:/var/www/app/tmp/sockets/appname .0.sock;
server   unix:/var/www/app/tmp/sockets/appname .1.sock;
server   unix:/var/www/app /tmp/sockets/appname .2.sock;
}
server {
    listen   80;
    server_name blog.hhailuo.com;
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;
    root   /var/www/app;
    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;
        if (-f $request_filename/index.html) {
            rewrite (.*) $1/index.html break;
        }
        if (-f $request_filename.html) {
            rewrite (.*) $1.html break;
        }
        if (!-f $request_filename) {
            proxy_pass http://blog.hhailuo.com  ;
            break;
        }
    }
}
再用开三个 thin
thin start –server 3 –socket tmp/sockets/appname.sock -e production
创建软连接 ln -s /etc/nginx/sites-available/file /etc/nginx/sites-enabled/file
重启nginx
# service nginx restart
03-23 01:19