Skip to content

Instantly share code, notes, and snippets.

@ChunAllen
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChunAllen/065a2bd706a277c929b6 to your computer and use it in GitHub Desktop.
Save ChunAllen/065a2bd706a277c929b6 to your computer and use it in GitHub Desktop.
Deploying Rails application with Phusion Passenger (Nginx)
Please refer Ruby on Rails installation in this link
https://gorails.com/setup/ubuntu/14.10
Please refer phusion passenger installation in this link:
https://www.digitalocean.com/community/tutorials/how-to-install-rails-and-nginx-with-passenger-on-ubuntu
TLDR; Install phusion passenger to ubuntu server using:
- gem install passenger
- rvmsudo passenger-install-nginx-module
- sudo service nginx stop | start | restart
- passenger start # run it on your ruby on rails project path
# /opt/nginx/conf/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 /home/willtex/.rvm/gems/ruby-2.1.1@willtex/gems/passenger-5.0.6;
passenger_ruby /home/willtex/.rvm/gems/ruby-2.1.1@willtex/wrappers/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; # accessible with domain's IP Address
server_name localhost; # yourdomain.com
passenger_enabled on;
rails_env development; # Set the Rails Environment, Default is production
root /home/willtex/apps/willtex/public; # root to your Ruby on Rails app public folder
#charset koi8-r;
#access_log logs/host.access.log main;
#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 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
# /etc/rc.local
# In development environment if you want to start the nginx passenger upon start up
cd /webapps/foo # Path of your Ruby on Rails Project
passenger start --daemonize --port 4000 --user someusername1 # specify if you want a port
# or
sudo service nginx start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment