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 is exactly what I was looking for! Thanks for posting it.

@awkdev
awkdev commented Sep 1, 2014

Worked like a charm on Ubuntu 12.10. Thanks!

@a17levine

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

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

@februaryInk

@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

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