Skip to content

Instantly share code, notes, and snippets.

@germs12
Forked from bradmontgomery/rvm_apache_passenger.txt
Last active December 24, 2015 07:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save germs12/6762817 to your computer and use it in GitHub Desktop.
Save germs12/6762817 to your computer and use it in GitHub Desktop.
# Create kpdev user
useradd kpdev
# 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 kpdev to rvm group
usermod -g rvm kpdev
# 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
rvm autolibs rvm_pkg
# install the latest ruby (and make it the default)
rvm install 1.9.3
rvm 1.9.3 --default
# install the passenger gem
gem install passenger
# Install the following required packages (as per passenger's instructions)
apt-get install libcurl4-openssl-dev libssl-dev zlib1g-dev apache2-mpm-prefork apache2-prefork-dev libapr1-dev libaprutil1-dev
# Try installing the apache module
passenger-install-apache2-module
## PROD VALUES
## LoadModule passenger_module /home/kpdev/.rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.21/buildout/apache2/mod_passenger.so
## PassengerRoot /home/kpdev/.rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.21
## PassengerDefaultRuby /home/kpdev/.rvm/wrappers/ruby-2.0.0-p247/ruby
##
##
# Create /etc/apache2/mods-available/passenger.load and include:
cat >> /etc/apache2/mods-available/passenger.load <<END_CONF
LoadModule passenger_module /home/kpdev/.rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.19/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 /home/kpdev/.rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.19
PassengerDefaultRuby /home/kpdev/.rvm/wrappers/ruby-2.0.0-p247/ruby
END_CONF
# Symlink passenger.conf and passenger.load to /etc/apache2/mods-enabled/
cd /etc/apache2/mods-enabled
ln -s ../mods-available/passenger.conf .
ln -s ../mods-available/passenger.load .
# 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=kpdev
export APACHE_RUN_GROUP=kpdev
# Update your app's apache config in /etc/apache2/sites-available/appname with something similar to the following:
<VirtualHost *:80>
ServerAdmin james@klickpush.com
ServerName apipage.klickpush.com
## Vhost docroot
DocumentRoot /kpapp/apipage/current/public
## Directories, there should at least be a declaration for /kpapp/apipage/current/public
<Directory /kpapp/apipage/current/public>
AllowOverride all
Order allow,deny
Allow from all
PassengerEnabled on
</Directory>
## Logging
ErrorLog /var/log/apache2/apipage.klickpush.com_error.log
LogLevel warn
ServerSignature Off
CustomLog /var/log/apache2/apipage.klickpush.com_access.log combined
</VirtualHost>
# Then symlink this file from /etc/apache2/sites-enabled and reload apache:
cd /etc/apache2/sites-enabled
ln -s ../sites-available/appname .
/etc/init.d/apache2 reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment