Reputation: 1203
I'm a newby to rails and love the language and the development environment. However, I've been overly frustrated trying to push a new app to the production environment when not using PostgreSQL and/or Heroku.
For work related reasons we are using a rackspace cloud server with MySQL as the database.
My frustration has come with setting up passenger and Nginx. I've followed Ryan's Railscasts on deploying to vps and this tutorial.
I can get through installing ruby, mysql, passenger, Nginx, dependencies, and rails on the server. But when I try to start Nginx nothing happens. When I say nothing happens I mean I don't have any indication that it's running. I point my browser to the ip address and I get the standard error "this webpage is not available" error in the browser. I've looked at the error log and it's blank. I haven't deployed my app yet...just trying to see the default screen of Nginx.
Any ideas? I'm guessing there is a key step I'm missing in configuring Nginx I just don't know what it is.
My Access Log
.0.0.1 - - [14/Oct/2012:10:40:03 -0500] "GET / HTTP/1.1" 200 151 "-" "Wget/1.13.4 (linux-gnu)"
127.0.0.1 - - [14/Oct/2012:10:45:03 -0500] "GET / HTTP/1.1" 200 151 "-" "Wget/1.13.4 (linux-gnu)"
127.0.0.1 - - [14/Oct/2012:10:50:03 -0500] "GET / HTTP/1.1" 200 151 "-" "Wget/1.13.4 (linux-gnu)"
127.0.0.1 - - [14/Oct/2012:10:55:03 -0500] "GET / HTTP/1.1" 200 151 "-" "Wget/1.13.4 (linux-gnu)"
127.0.0.1 - - [14/Oct/2012:11:00:03 -0500] "GET / HTTP/1.1" 200 151 "-" "Wget/1.13.4 (linux-gnu)"
My Nginx.conf file
user deployer staff;
#user nobody;
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/lib/ruby/gems/1.9.1/gems/passenger-3.0.17;
passenger_ruby /usr/local/bin/ruby;
include mime.types;
default_type application/octet-stream;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#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;
}
}
}
Upvotes: 3
Views: 4789
Reputation: 789
From my blog post which was pretty much on this exact setup http://blog.nikoroberts.com/post/45834702235/setting-up-a-rails-32-server-in-the-rackspace
You are at least missing
passenger_enabled on;
My nginx.conf
worker_processes 4;
events {
worker_connections 1024;
}
http {
passenger_root /home/deployer/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.17;
passenger_ruby /home/deployer/.rvm/wrappers/ruby-1.9.3-p194/ruby;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
client_max_body_size 5M;
gzip on;
gzip_http_version 1.1;
gzip_comp_level 1;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_proxied any;
gzip_vary on;
gzip_min_length 500;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
passenger_default_user deployer;
#fast passenger respawn
passenger_pool_idle_time 1000;
server {
listen 80;
charset utf-8;
server_name localhost;
root /var/www/contactguru/current/public;
passenger_enabled on;
rails_env production;
# fast passenger and rails respawn
# from http://stackoverflow.com/a/2329221
rails_spawn_method smart;
rails_app_spawner_idle_time 0;
rails_framework_spawner_idle_time 0;
location ~ ^/(assets)/ {
root /var/www/contactguru/current/public;
gzip_static on;
expires max;
add_header Cache-Control public;
# access_log /dev/null;
}
}
}
Upvotes: 5