Created
March 7, 2011 12:13
-
-
Save ijin/858425 to your computer and use it in GitHub Desktop.
installs rvm with passenger on Ubuntu
This file contains hidden or 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
#!/bin/bash | |
# | |
# Ruby w/ Passenger Installer | |
# | |
# Michael H. Oshita (@ijin) | |
# | |
### ruby versions #### | |
RUBY_VERSION= | |
RUBY_DEFAULT=1.9.2 | |
while getopts “v:” OPTION | |
do | |
case $OPTION in | |
v) | |
RUBY_VERSION=$OPTARG | |
echo | |
echo "using ruby version $RUBY_VERSION" | |
echo | |
;; | |
esac | |
done | |
if [[ -z $RUBY_VERSION ]]; then | |
RUBY_VERSION=$RUBY_DEFAULT | |
echo | |
echo "no option given, using default ruby version $RUBY_DEFAULT" | |
echo | |
fi | |
### Prerequisite packages ### | |
PKG=acl | |
PREREQ=`dpkg -l | grep $PKG | cut -d' ' -f1` | |
if [ $PREREQ != 'ii' ]; then | |
echo "package: [$PKG] needs to be installed with fstab options...terminating" | |
exit 0 | |
fi | |
### Update repos ### | |
apt-get update | |
### Install git & svn ### | |
apt-get -y install git-core subversion subversion-tools | |
### Install RVM ### | |
apt-get -y install libreadline-dev libcurl4-openssl-dev bison autoconf | |
bash < <( curl -L http://bit.ly/rvm-install-system-wide ) | |
echo -e "\n# rvm\n[[ -s '/usr/local/lib/rvm' ]] && source '/usr/local/lib/rvm'" >> /etc/profile | |
source /etc/profile | |
chgrp -R rvm /usr/local/rvm | |
chmod -R g+w /usr/local/rvm | |
chmod -R g+s /usr/local/rvm | |
setfacl -R -d -m g:rvm:rwx /usr/local/rvm | |
### Install Ruby ### | |
rvm package install readline | |
rvm install $RUBY_VERSION | |
rvm use $RUBY_VERSION | |
RUBY_VERSION_DETAIL=`rvm list | grep ruby- | sed -e 's/.*\(ruby-.*\) \[.*/\1/g'` | |
### Install ruby-debug #### | |
gem install ruby-debug19 -- --with-ruby-include="/usr/local/rvm/src/$RUBY_VERSION_DETAIL" | |
### Install Passenger #### | |
gem install bundler | |
gem install passenger | |
apt-get -y install zlib1g-dev libssl-dev libpcre3-dev libmysqlclient-dev libcurl4-openssl-dev libgeoip-dev | |
apt-get -y install nginx wajig | |
sed -i -e 's/\(PATH=.*\)/\1:\/opt\/nginx\/sbin/' /etc/init.d/nginx | |
sed -i -e 's/\(DAEMON=\/\)usr/\1opt\/nginx/' /etc/init.d/nginx | |
rm -rf /usr/sbin/nginx | |
wajig hold nginx | |
passenger-install-nginx-module --auto --prefix=/opt/nginx --auto-download --extra-configure-flags='--error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/body --http-proxy-temp-path=/var/lib/nginx/proxy --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --with-debug --with-http_stub_status_module --with-http_flv_module --with-http_ssl_module --with-http_dav_module --with-http_gzip_static_module --with-http_realip_module --with-mail --with-mail_ssl_module --with-ipv6 --with-http_geoip_module' | |
usermod -aG rvm www-data | |
### Create rails dir ### | |
mkdir /usr/local/rails_apps | |
chown www-data: /usr/local/rails_apps | |
chmod g+w /usr/local/rails_apps | |
chmod g+s /usr/local/rails_apps | |
setfacl -d -m g:www-data:rwx /usr/local/rails_apps | |
### Create logrotate ### | |
cat > /etc/logrotate.d/rails <<EOF | |
/usr/local/rails_apps/*/log/*.log | |
/usr/local/rails_apps/*/current/log/*.log | |
{ | |
weekly | |
missingok | |
rotate 7 | |
compress | |
delaycompress | |
notifempty | |
copytruncate | |
} | |
EOF | |
### Usermod #### | |
echo | |
echo "Remember to:" | |
echo "sudo usermod -a -G www-data USER" | |
echo "sudo usermod -a -G rvm USER" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment