Last active
December 18, 2015 04:18
-
-
Save toretore/5724042 to your computer and use it in GitHub Desktop.
Installing ruby-build, ruby, unicorn, bundling and running a rails app on a server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#sudo as necessary | |
#First, install ruby-build to /opt/ruby-build | |
git clone git://github.com/sstephenson/ruby-build.git /opt/ruby-build | |
#it's a good idea to make sure you have these installed before compiling ruby | |
#apt-get install libssl-dev libreadline6-dev zlib1g-dev | |
#All ruby installations/versions are going to live in /opt/rubies | |
mkdir /opt/rubies | |
#Install version 1.9.3-p392 | |
/opt/ruby-build/bin/ruby-build 1.9.3-p392 /opt/rubies/1.9.3-p392 | |
#You could install another one that will have different gems | |
/opt/ruby-build/bin/ruby-build 1.9.3-p392 /opt/rubies/myotherversion | |
#Or a different version | |
/opt/ruby-build/bin/ruby-build rbx-2.0.0 /opt/rubies/rubinius-2.0.0 | |
#For the one you're going to run the rails app with, install the bundler gem | |
/opt/rubies/1.9.3-p392/bin/gem install bundler | |
cd /rails/app #Where your rails app lives | |
#Tell bundler to install the necessary gems. These will be installed only for the ruby version specified | |
/opt/rubies/1.9.3-p392/bin/ruby /opt/rubies/1.9.3-p392/bin/bundle #--without test,development | |
#Install unicorn if it's not part of the gemfile | |
/opt/rubies/1.9.3-p392/bin/gem install unicorn | |
#Run the rails app using unicorn | |
/opt/rubies/1.9.3-p392/bin/ruby /opt/rubies/1.9.3-p392/bin/unicorn -Eproduction -p3456 config.ru |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Upstart config | |
description "Rails w/Unicorn" | |
start on runlevel [2345] | |
stop on runlevel [016] | |
setuid webuser | |
setgid webuser | |
chdir /rails/app | |
respawn | |
exec /opt/rubies/1.9.3-p392/bin/ruby /opt/rubies/1.9.3-p392/bin/unicorn -Eproduction -p3456 /rails/app/config.ru |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment