Skip to content

Instantly share code, notes, and snippets.

@ranaharis-tkxel
Forked from germs12/rvm_apache_passenger.txt
Last active December 31, 2015 11:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ranaharis-tkxel/7982933 to your computer and use it in GitHub Desktop.
Save ranaharis-tkxel/7982933 to your computer and use it in GitHub Desktop.
# Create deploy user
useradd deploy
# Install rvm for system
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
# First you need to add all users that will be using rvm to 'rvm' group,
# and logout - login again, anyone using rvm will be operating with `umask u=rwx,g=rwx,o=rx`.
# Add deploy to rvm group
usermod -g rvm deploy
#add deploy to sudoers
# Add the following line to you /etc/sudoers below root
# deploy ALL=(ALL:ALL) ALL
# Update the packages
apt-get update
apt-get upgrade
apt-get install build-essential
# get the packages required by ruby
rvm pkg install zlib
rvm pkg install openssl
#install mysql
apt-get install mysql-server mysql-client
# install the latest ruby (and make it the default)
rvm install 2.0.0
rvm 2.0.0 --default
# install the passenger gem
gem install passenger
# Try installing the apache module
passenger-install-apache2-module
# Install the following required packages (as per passenger's instructions)
apt-get install libcurl4-openssl-dev apache2-mpm-worker apache2-threaded-dev libapr1-dev libaprutil1-dev
# Try installing the apache module again
passenger-install-apache2-module
# Install node.js
apt-get install nodejs
## PROD VALUES
## LoadModule passenger_module /usr/local/rvm/gems/ruby-2.0.0-p353/gems/passenger-4.0.29/buildout/apache2/mod_passenger.so
## PassengerRoot /usr/local/rvm/gems/ruby-2.0.0-p353/gems/passenger-4.0.29
## PassengerDefaultRuby /usr/local/rvm/wrappers/ruby-2.0.0-p353/ruby
##
##
# Create /etc/apache2/mods-available/passenger.load and include:
cat >> /etc/apache2/mods-available/passenger.load <<END_CONF
LoadModule passenger_module /usr/local/rvm/gems/ruby-2.0.0-p353/gems/passenger-4.0.29/buildout/apache2/mod_passenger.so
END_CONF
# Then create /etc/apache2/mods-available/passenger.conf
cat >> /etc/apache2/mods-available/passenger.conf <<END_CONF
PassengerRoot /usr/local/rvm/gems/ruby-2.0.0-p353/gems/passenger-4.0.29
PassengerDefaultRuby /usr/local/rvm/wrappers/ruby-2.0.0-p353/ruby
END_CONF
# Enable Passenger mod
sudo a2enmod passenger
# Remove RailsAutoDetect On if present
nano /etc/apache2/mods-available/passenger.conf
# Set the correct User/Group
nano /etc/apache2/envvars
# set...
export APACHE_RUN_USER=deploy
export APACHE_RUN_GROUP=deploy
# Update your app's apache config in /etc/apache2/sites-available/appname with something similar to the following, this is for sub URI deployment:
<VirtualHost *:80>
ServerName 10.0.0.73
# for sub URI
Alias /todos /home/deploy/projects/todos/current/public
<Location /todos>
PassengerBaseURI /todos
PassengerAppRoot /home/deploy/projects/todos/current
PassengerRuby /usr/local/rvm/wrappers/ruby-2.0.0-p353@todos/ruby
</Location>
<Directory /home/deploy/projects/todos/current/public>
Allow from all
Options -MultiViews
</Directory>
</VirtualHost>
# Then enable your site and reload apache:
sudo a2ensite appname
service apache2 reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment