Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Steps to setup and install passenger nginx and rails on digital ocean
# Login as root
ssh root@domain
# Create deploy user
adduser <username> #Adds User with username given. Enter Password when Prompted. Other Details are Optional
# Add user to sudo group
usermod -g <groupname> <username>
# Add .ssh/authorized_keys for deploy user
#update and upgrade packages
sudo apt-get update
sudo apt-get upgrade
# Install curl
sudo apt-get install curl
# Install RVM
curl -L get.rvm.io | bash -s stable
# Source RVM
source ~/.rvm/scripts/rvm
# Relogin to shell
# RVM requirements
rvm requirements
# Enable RVM autolibs to autoinstall requirements
rvm autolibs enable
# RVM requirements
rvm requirements
# Install ruby
rvm install 2.0.0
# Set default
rvm --default use 2.0.0
# Install current ruby gems
rvm rubygems current
# Before installing set gem config to NOT do rdoc and ri installation
echo "gem: --no-rdoc --no-ri" >> .gemrc
# Install rails
gem install rails # to install specific version use like - gem install rails -v 3.0.1
# Install passenger
gem install passenger --version 4.0.0.rc6
# Install Nginx
rvmsudo passenger-install-nginx-module
# Make nginx service as per http://askubuntu.com/questions/257108/trying-to-start-nginx-on-vps-i-get-nginx-unrecognized-service
# Download nginx startup script
wget -O init-deb.sh https://www.linode.com/docs/assets/660-init-deb.sh
# Move the script to the init.d directory & make executable
sudo mv init-deb.sh /etc/init.d/nginx
sudo chmod +x /etc/init.d/nginx
# Add nginx to the system startup
sudo /usr/sbin/update-rc.d -f nginx defaults
# Start nginx
sudo service nginx start
# Connect Nginx to rails project
sudo vim /opt/nginx/conf/nginx.conf
# Make following settings in nginx conf
server {
listen 80;
server_name example.com;
passenger_enabled on;
root /var/www/my_awesome_rails_app/public;
}
# Install nodejs if not previously installed
# Install mysql server and other related components
sudo apt-get install mysql-server libmysqld-dev
# Now use capistrano to deploy rails app
@fbonetti

This comment has been minimized.

Show comment Hide comment
@fbonetti

fbonetti Jul 17, 2014

This is exactly what I was looking for! Thanks for posting it.

This is exactly what I was looking for! Thanks for posting it.

@awkdev

This comment has been minimized.

Show comment Hide comment
@awkdev

awkdev Sep 1, 2014

Worked like a charm on Ubuntu 12.10. Thanks!

awkdev commented Sep 1, 2014

Worked like a charm on Ubuntu 12.10. Thanks!

@a17levine

This comment has been minimized.

Show comment Hide comment
@a17levine

a17levine Jan 26, 2015

anyone else getting /etc/init.d/nginx: 2: /etc/init.d/nginx: Syntax error: newline unexpected when first trying to sudo service nginx start?

anyone else getting /etc/init.d/nginx: 2: /etc/init.d/nginx: Syntax error: newline unexpected when first trying to sudo service nginx start?

@imkarthikk

This comment has been minimized.

Show comment Hide comment
@imkarthikk

imkarthikk Jan 29, 2015

@a17levine Same here :/ Even I;m getting the same error message :/

@a17levine Same here :/ Even I;m getting the same error message :/

@nitj2021

This comment has been minimized.

Show comment Hide comment
@februaryInk

This comment has been minimized.

Show comment Hide comment
@februaryInk

februaryInk Feb 7, 2015

@nitj2021 Thank you. I was getting the same error message as the others (apparently the tutorial's link now points to a small HTML file), but by using your link in line 58, I was able to get it working. I appreciate the time saved.

@nitj2021 Thank you. I was getting the same error message as the others (apparently the tutorial's link now points to a small HTML file), but by using your link in line 58, I was able to get it working. I appreciate the time saved.

@bahadirdogru

This comment has been minimized.

Show comment Hide comment
@bahadirdogru

bahadirdogru Mar 3, 2015

thanks. it's work for me on Debian Wheezy

thanks. it's work for me on Debian Wheezy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment