繁体   English   中英

Rails 3-无法加载页面(nginx无法启动)

[英]Rails 3 - doesn't load pages (nginx doesn't start)

很抱歉我的菜鸟问题,但我真的不明白怎么了!

我想在vds上运行我的应用程序。 因此,为此,我使用下一个:

Ubuntu 10.04
PostgreSQL 9.1
Rails 3.1.3
Ruby 1.9.3p27
Nginx 1.0.11 (installed/compiled by passenger)
Phusion passenger 3.0.11
Capistrano

因此,我尝试使用Scaffold创建的小型简单Rails应用程序进行配置。 因此,此应用可以正常运行(它使用SQlite并显示所有页面)。

然后,我尝试启动使用PostgreSQL的应用程序。 所以,我通过capistrano上传了它,然后打印了

$ cap deploy:start
* executing `deploy:start'

而且在我的服务器上我打印

service nginx restart

因此,当我访问ip时,我只会获得旧应用程序的主rails索引页面(如果我之前启动过非常简单的应用程序),或者它表明无法连接到服务器(否则),仅此而已。

我也尝试过:

rails c production
> app.get("/")

然后我得到:

User Load (4.0ms)  SELECT "users".* FROM "users" WHERE "users"."id" IS NULL LIMIT 1
  CACHE (0.0ms)  SELECT "users".* FROM "users" WHERE "users"."id" IS NULL LIMIT 1
  User Load (0.0ms)  SELECT "users".* FROM "users" 
 => 500 

另外,当我尝试为我的应用启动或重新启动Nginx时,它并不想工作:

$ initctl list | grep nginx
nginx stop/waiting
$ service nginx start
nginx start/running, process 30746
$ initctl list | grep nginx
nginx stop/waiting

怎么了?

我的配置文件:

Nginx.conf:

user  root;

worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    passenger_root /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-3.0.11;
    passenger_ruby /usr/local/rvm/wrappers/ruby-1.9.3-head/ruby;

    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"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  localhost;

        # root and passenger i added.
        root /vol/www/apps/ror_tutorial/current/public                      #/current because of Capistrano
        passenger_enabled on;        

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        # location / {
        #                       root   html;
        #                       index  index.html index.htm;
        #                    }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443;
    #    server_name  localhost;

    #    ssl                  on;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_timeout  5m;

    #    ssl_protocols  SSLv2 SSLv3 TLSv1;
    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers   on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

config / deploy.rb

set :user, "root"                                                             
set :rails_env, "production"

default_run_options[:pty] = true                                              # Must be set for the password prompt from git to work
set :repository,  "git://github.com/Loremaster/sample_app.git"

set :application, "ror_tutorial"
set :deploy_to, "/vol/www/apps/#{application}"

set :scm, :git
set :branch, "master"

server "188.127.224.136", :app,
                          :web,
                          :db, :primary => true

# if you're still using the script/reaper helper you will need
# these http://github.com/rails/irs_process_scripts

# If you are using Passenger mod_rails uncomment this:
namespace :deploy do
   task :start do ; end
   task :stop do ; end
   task :restart, :roles => :app, :except => { :no_release => true } do
     run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
   end
end

确保在路由文件中设置了根路由,然后从公用文件夹中删除index.html,否则它将始终在目标页面上呈现。

我对nginx一无所知,只是一个提示:

您是否已正确设置PostgresSQL服务器?

我发现出了什么问题-我忘了';' 在此字符串中:

Nginx.conf:

root /vol/www/apps/ror_tutorial/current/public

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM