RoR应用程序和带有Passenger的nginx在Ubuntu上运行

我在Ubuntu 13.10服务器上使用RVM安装Ruby。 我用rubygems和Rails做同样的事情。 当我开始我的申请

rails server

并进入

localhost:3000

在我的浏览器中有效。

现在我想让应用程序对其他用户可见。 所以我查了rubyonrails.org/deploy-Site并决定用Passenger安装nginx。

gem install passenger
rvmsudo passenger-install-nginx-module

在此之后,我下载了那些失踪和做的事情

rvmsudo passenger-install-nginx-module

再次。

在我跑之前

sudo service nginx start

我编辑/opt/nginx/conf/nginx.conf中的.conf-File

server { 
listen 80; 
server_name example.com; 
passenger_enabled on; 
root /var/www/my_awesome_rails_app/public; 
}

作为服务器名称,我把IP-Adress作为域名。 我添加了passenger_enabled行,并以root身份取/ home / ServerName / AppName / public

我的问题是 ,当我打开服务器-IP-页面时,我什么都看不到。

当我运行'顶部'时,我看到nginx正在运行。 Ruby on Rails应用程序也在运行。

并且在编辑.conf文件后重新启动nginx。

任何人都知道我的解决方案或我如何测试nginx?

谢谢

更新 - error.log,access.log

access.log:文件是空的(里面没有内容)

error.log中:

[ 2014-05-13 14:08:18.9450 2548/7fc38986d740 agents/Watchdog/Main.cpp:538 ]: Options: { 'analytics_log_user' => 'nobody', 'default_group' => 'nogroup', 'default_python' => 'python', 'default_ruby' => '/home/mustermann/.rvm/gems/ruby-2.1.1/wrappers/ruby', 'default_user' => 'nobody', 'log_level' => '0', 'max_pool_size' => '6', 'passenger_root' => '/home/mustermann/.rvm/gems/ruby-2.1.1/gems/passenger-4.0.42', 'passenger_version' => '4.0.42', 'pool_idle_time' => '300', 'temp_dir' => '/tmp', 'union_station_gateway_address' => 'gateway.unionstationapp.com', 'union_station_gateway_port' => '443', 'user_switching' => 'true', 'web_server_passenger_version' => '4.0.42', 'web_server_pid' => '2547', 'web_server_type' => 'nginx', 'web_server_worker_gid' => '65534', 'web_server_worker_uid' => '65534' }
[ 2014-05-13 14:08:18.9501 2551/7fbf96162740 agents/HelperAgent/Main.cpp:643 ]: PassengerHelperAgent online, listening at unix:/tmp/passenger.1.0.2547/generation-0/request
[ 2014-05-13 14:08:18.9590 2556/7fcd93dab780 agents/LoggingAgent/Main.cpp:321 ]: PassengerLoggingAgent online, listening at unix:/tmp/passenger.1.0.2547/generation-0/logging
[ 2014-05-13 14:08:18.9604 2548/7fc38986d740 agents/Watchdog/Main.cpp:728 ]: All Phusion Passenger agents started!
[ 2014-05-13 14:10:33.6645 2592/7f40a1fe8740 agents/Watchdog/Main.cpp:538 ]: Options: { 'analytics_log_user' => 'nobody', 'default_group' => 'nogroup', 'default_python' => 'python', 'default_ruby' => '/home/mustermann/.rvm/gems/ruby-2.1.1/wrappers/ruby', 'default_user' => 'nobody', 'log_level' => '0', 'max_pool_size' => '6', 'passenger_root' => '/home/mustermann/.rvm/gems/ruby-2.1.1/gems/passenger-4.0.42', 'passenger_version' => '4.0.42', 'pool_idle_time' => '300', 'temp_dir' => '/tmp', 'union_station_gateway_address' => 'gateway.unionstationapp.com', 'union_station_gateway_port' => '443', 'user_switching' => 'true', 'web_server_passenger_version' => '4.0.42', 'web_server_pid' => '2591', 'web_server_type' => 'nginx', 'web_server_worker_gid' => '65534', 'web_server_worker_uid' => '65534' }
[ 2014-05-13 14:10:33.6693 2595/7fc930750740 agents/HelperAgent/Main.cpp:643 ]: PassengerHelperAgent online, listening at unix:/tmp/passenger.1.0.2591/generation-0/request
[ 2014-05-13 14:10:33.6777 2600/7f645bf0f780 agents/LoggingAgent/Main.cpp:321 ]: PassengerLoggingAgent online, listening at unix:/tmp/passenger.1.0.2591/generation-0/logging
[ 2014-05-13 14:10:33.6780 2592/7f40a1fe8740 agents/Watchdog/Main.cpp:728 ]: All Phusion Passenger agents started!
[ 2014-05-13 14:18:19.9938 2638/7fae3ef32740 agents/Watchdog/Main.cpp:538 ]: Options: { 'analytics_log_user' => 'nobody', 'default_group' => 'nogroup', 'default_python' => 'python', 'default_ruby' => '/home/mustermann/.rvm/gems/ruby-2.1.1/wrappers/ruby', 'default_user' => 'nobody', 'log_level' => '0', 'max_pool_size' => '6', 'passenger_root' => '/home/mustermann/.rvm/gems/ruby-2.1.1/gems/passenger-4.0.42', 'passenger_version' => '4.0.42', 'pool_idle_time' => '300', 'temp_dir' => '/tmp', 'union_station_gateway_address' => 'gateway.unionstationapp.com', 'union_station_gateway_port' => '443', 'user_switching' => 'true', 'web_server_passenger_version' => '4.0.42', 'web_server_pid' => '2637', 'web_server_type' => 'nginx', 'web_server_worker_gid' => '65534', 'web_server_worker_uid' => '65534' }
[ 2014-05-13 14:18:19.9990 2641/7f6ed18af740 agents/HelperAgent/Main.cpp:643 ]: PassengerHelperAgent online, listening at unix:/tmp/passenger.1.0.2637/generation-0/request
[ 2014-05-13 14:18:20.0074 2646/7fbb3494b780 agents/LoggingAgent/Main.cpp:321 ]: PassengerLoggingAgent online, listening at unix:/tmp/passenger.1.0.2637/generation-0/logging
[ 2014-05-13 14:18:20.0077 2638/7fae3ef32740 agents/Watchdog/Main.cpp:728 ]: All Phusion Passenger agents started!
[ 2014-05-13 14:18:25.2711 2673/7f292be1d740 agents/Watchdog/Main.cpp:538 ]: Options: { 'analytics_log_user' => 'nobody', 'default_group' => 'nogroup', 'default_python' => 'python', 'default_ruby' => '/home/mustermann/.rvm/gems/ruby-2.1.1/wrappers/ruby', 'default_user' => 'nobody', 'log_level' => '0', 'max_pool_size' => '6', 'passenger_root' => '/home/mustermann/.rvm/gems/ruby-2.1.1/gems/passenger-4.0.42', 'passenger_version' => '4.0.42', 'pool_idle_time' => '300', 'temp_dir' => '/tmp', 'union_station_gateway_address' => 'gateway.unionstationapp.com', 'union_station_gateway_port' => '443', 'user_switching' => 'true', 'web_server_passenger_version' => '4.0.42', 'web_server_pid' => '2656', 'web_server_type' => 'nginx', 'web_server_worker_gid' => '65534', 'web_server_worker_uid' => '65534' }
[ 2014-05-13 14:18:25.2760 2676/7f26f5920740 agents/HelperAgent/Main.cpp:643 ]: PassengerHelperAgent online, listening at unix:/tmp/passenger.1.0.2656/generation-0/request
[ 2014-05-13 14:18:25.2839 2681/7f0cf6b96780 agents/LoggingAgent/Main.cpp:321 ]: PassengerLoggingAgent online, listening at unix:/tmp/passenger.1.0.2656/generation-0/logging
[ 2014-05-13 14:18:25.2847 2673/7f292be1d740 agents/Watchdog/Main.cpp:728 ]: All Phusion Passenger agents started!
[ 2014-05-13 14:18:35.0327 2709/7f19099b8740 agents/Watchdog/Main.cpp:538 ]: Options: { 'analytics_log_user' => 'nobody', 'default_group' => 'nogroup', 'default_python' => 'python', 'default_ruby' => '/home/mustermann/.rvm/gems/ruby-2.1.1/wrappers/ruby', 'default_user' => 'nobody', 'log_level' => '0', 'max_pool_size' => '6', 'passenger_root' => '/home/mustermann/.rvm/gems/ruby-2.1.1/gems/passenger-4.0.42', 'passenger_version' => '4.0.42', 'pool_idle_time' => '300', 'temp_dir' => '/tmp', 'union_station_gateway_address' => 'gateway.unionstationapp.com', 'union_station_gateway_port' => '443', 'user_switching' => 'true', 'web_server_passenger_version' => '4.0.42', 'web_server_pid' => '2708', 'web_server_type' => 'nginx', 'web_server_worker_gid' => '65534', 'web_server_worker_uid' => '65534' }
[ 2014-05-13 14:18:35.0374 2712/7f6ce241a740 agents/HelperAgent/Main.cpp:643 ]: PassengerHelperAgent online, listening at unix:/tmp/passenger.1.0.2708/generation-0/request
[ 2014-05-13 14:18:35.0457 2718/7fba54563780 agents/LoggingAgent/Main.cpp:321 ]: PassengerLoggingAgent online, listening at unix:/tmp/passenger.1.0.2708/generation-0/logging
[ 2014-05-13 14:18:35.0461 2709/7f19099b8740 agents/Watchdog/Main.cpp:728 ]: All Phusion Passenger agents started!

更新 - ps aux | egrep'(PID | nginx)'

http://s1.directupload.net/images/140513/v2lv5dpe.jpg


现在它正在运行。

80端口被我们大学的防火墙阻止。

解锁80端口后,运行服务器的IP地址时会得到nginx页面。

最后,我们只需要用下面几行更改nginx的.conf:

location / {
    proxy_pass http://localhost:3000/;
    proxy_redirect off;
    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_set_header X-NginX-Proxy true;
}

来源:链接

如果您不想使用ip-adress:3000访问您的应用程序,则此部分非常重要

旧的位置部分可以删除。

现在你可以重新启动/重新加载nginx:

sudo service nginx restart

并启动rails服务器(在端口3000上 - 默认):

rails server

如果你想要的话,你可以用另一种模式启动rails服务器:

rails server -e ....

现在您可以访问您的RoR应用程序。

祝你好运 :-)

链接地址: http://www.djcxy.com/p/32533.html

上一篇: RoR Application and nginx with Passenger on Ubuntu

下一篇: Sinatra + Passenger + RVM on DreamHost fail to start