RoR Application and nginx with Passenger on Ubuntu

i installed Ruby using RVM on a Ubuntu 13.10 Server. The same thing i do with rubygems and Rails. When i start my application with

rails server

and enter

localhost:3000

in my Browser it works.

Now i want to make the application visible for other users. So i checked rubyonrails.org/deploy-Site and decided to install nginx with Passenger.

gem install passenger
rvmsudo passenger-install-nginx-module

After this i downloaded stuff who was missing and do

rvmsudo passenger-install-nginx-module

again.

Before i runned

sudo service nginx start

i edit my .conf-File in /opt/nginx/conf/nginx.conf

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

As server name i take the ip-Adress for the domain. The passenger_enabled Line i added and as root i take /home/ServerName/AppName/public

My Problem is that i doesn't see anything when i open the server-ip-page.

When i run 'top' i see that nginx is running. The Ruby on Rails Application is also running.

AND i restartet nginx after editing the .conf-File.

Anybody know i solution OR how i can test nginx?

Thanks

Update - error.log, access.log

access.log: file is empty (no content inside)

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!

Update - ps aux | egrep '(PID|nginx)'

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


Now its running.

Port 80 was blocked by the firewall of our university.

After unlocking Port 80 we get the nginx page when running the ip-adress of the server.

Finally we just needed to change the .conf of nginx with the following lines:

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;
}

Source: Link

This part is important if you don't want access your Application with ip-adress:3000

The old location-part can be deleted.

Now you can restart/reload the nginx:

sudo service nginx restart

and start the rails server (on Port 3000 - default):

rails server

If you want you can start the rails server i another mode with:

rails server -e ....

Now you can access your RoR-Application.

Good Luck :-)

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

上一篇: Modular Sinatra应用程序在Passenger下返回404

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