sudo add-apt-repository ppa:nginx/stable
sudo apt-get update
sudo apt-get install nginx
Guide: http://www.modrails.com/documentation/Users%20guide%20Nginx.html
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 561F9B9CAC40B2F7
sudo apt-get install apt-transport-https ca-certificates
sudo nano /etc/apt/sources.list.d/passenger.list
# - Add
# deb https://oss-binaries.phusionpassenger.com/apt/passenger precise main
sudo chown root: /etc/apt/sources.list.d/passenger.list
sudo chmod 600 /etc/apt/sources.list.d/passenger.list
sudo apt-get update
sudo apt-get install nginx-extras passenger
sudo nano /etc/nginx/nginx.conf
# - Add/Uncomment passenger lines to:
# - passenger_root: run `passenger-config about root` and read the output
# - passenger_ruby: result of `passenger-config about ruby-command`
# - Add
# passenger_app_env production;
sudo service nginx restart
E.g. /etc/nginx/sites-available/example.conf
server {
listen 80;
server_name example.com;
charset utf-8;
root /home/app/apps/example/current/public;
try_files $uri /system/maintenance.html @passenger;
location @passenger {
passenger_enabled on;
passenger_friendly_error_pages off;
}
location ^~ /assets/ {
# Only use gzip_static if you have .gz compressed assets *precompiled*
gzip_static on;
expires max;
add_header Cache-Control public;
}
client_max_body_size 10M;
keepalive_timeout 10;
}
Enable:
ln -s /etc/nginx/sites-available/example.conf /etc/nginx/sites-enabled/
nginx -t # Test the config
nginx -s reload # Reload config