Last active
December 15, 2015 21:29
-
-
Save highruned/5325680 to your computer and use it in GitHub Desktop.
speedtrain.sh
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 | |
#:Title : Speedtrain on Rails | |
#:Date : | |
#:Author : Obi Akubue, Eric Muyser | |
#:Version : 1.0 | |
#:Description: This script installs Ruby on Rails on Ubuntu 12.04 with the option to install Apache and Phusion Passenger. (It creates a test rails app) | |
#Usage Option 1: To Install Rails (Ruby + Rubygems) + Sqlite. Simply run the script by typing ./speedtrain | |
#Usage Option 2: To Install Rails (Ruby + Rubygems) + Sqlite + MySQL + Apache + Passenger. Run script by typing ./speedtrain -p | |
red='\e[0;31m' | |
RED='\e[1;31m' | |
blue='\e[0;34m' | |
BLUE='\e[1;34m' #light blue | |
cyan='\e[0;36m' | |
CYAN='\e[1;36m' | |
GREEN='\e[1;32m' | |
YELLOW='\e[1;33m' | |
WHITE='\e[1;37m' | |
NC='\e[0m' # No Color | |
#begining messages | |
if [ "$1" = "-p" ]; then | |
#option to install Apache + Passenger | |
echo -e "${GREEN} Welcome to Speedtrain on Rails" | |
echo " Installing Rails (Ruby + Rubygems) + Sqlite + MySQL + Apache + Passenger ..." | |
echo " This will take a few minutes to complete.." | |
echo -e "${WHITE} Press ENTER to continue or Ctrl-C to Quit" | |
echo -e "${NC}" | |
else | |
echo -e "${GREEN} Welcome to Speedtrain on Rails" | |
echo " Installing Rails..." | |
echo " This will take a few minutes to complete.." | |
echo -e "${WHITE} Press ENTER to continue or Ctrl-C to Quit" | |
echo -e "${NC}" | |
fi | |
read key | |
echo -e "${RED} updating system..." | |
echo -e "${CYAN}" | |
sudo aptitude update | |
echo -e "${RED} Installing build essential..." | |
echo -e "${CYAN}" | |
sudo apt-get install build-essential | |
echo -e "${RED} installing ruby..." | |
echo -e "${GREEN}" | |
sudo apt-get install irb libopenssl-ruby libreadline-ruby rdoc ri ruby ruby-dev | |
echo -e "${RED} installing rubygems..." | |
echo -e "${CYAN}" | |
cd /usr/local/src | |
sudo wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.6.tgz | |
sudo tar xzvf rubygems-1.3.6.tgz | |
cd rubygems-1.3.6 | |
sudo ruby setup.rb | |
echo -e "${RED} updating rubygems..." | |
echo -e "${GREEN}" | |
sudo update-alternatives --install /usr/bin/gem gem /usr/bin/gem1.8 1 | |
sudo gem update --system | |
echo -e "${RED} installing rails..." | |
echo -e "${CYAN}" | |
sudo gem install rails | |
echo -e "${RED} installing sqlite..." | |
echo -e "${GREEN}" | |
sudo apt-get install libsqlite3-dev sqlite3 sqlite3-doc | |
sudo gem install sqlite3-ruby | |
echo -e "${RED} creating dev directory..." | |
echo -e "${CYAN}" | |
mkdir ~/rails_apps/ | |
cd ~/rails_apps/ | |
echo -e "${RED} creating dev test app..." | |
echo -e "${GREEN}" | |
rails new testapp | |
if [ "$1" = "-p" ]; then | |
#if the passenger switch is set | |
echo -e "${RED} installing Apache..." | |
echo -e "${CYAN}" | |
sudo apt-get install apache2 | |
echo -e "${RED} installing PHP5..." | |
echo -e "${CYAN}" | |
sudo apt-get install php5 libapache2-mod-php5 | |
echo -e "${RED} installing MySQL..." | |
echo -e "${CYAN}" | |
sudo apt-get install mysql-server mysql-client | |
sudo apt-get install php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl | |
echo -e "${RED} installing passenger..." | |
echo -e "${GREEN}" | |
sudo gem install passenger | |
#install apache development headers | |
#required by passenger | |
#Apache 2 development headers -- | |
sudo apt-get install apache2-prefork-dev | |
#Apache portable Runime (APR) development headers -- | |
sudo apt-get install libapr1-dev | |
#install passenger | |
sudo passenger-install-apache2-module | |
fi | |
#ending message | |
if [ "$1" = "-p" ]; then | |
#if the passenger switch is set | |
echo -e "${YELLOW}" | |
printf "Your Apache Configuration file is /etc/apache2/httpd.conf\n" | |
echo -e "${NC}" | |
fi | |
echo -e "${CYAN}" | |
echo "Rails has been successfully installed" | |
echo -e "${GREEN}" | |
echo "Your Apps directory is $HOME/rails_apps" | |
echo "We created a Test Rails App for you at $HOME/rails_apps/testapp/" | |
echo "To run the Test App type" | |
echo -e "${YELLOW} cd $HOME/rails_apps/testapp" | |
echo " rails s" | |
echo -e "${NC}" | |
if [ "$1" = "-p" ]; then | |
#if the passenger switch is set | |
echo -e "${GREEN}" | |
echo "To deploy the Test Rails app on passenger " | |
echo "Edit the Apache Configuration file and add the following virtualhost" | |
echo -e "${YELLOW}\n" | |
echo "" | |
echo " ServerName www.yourhost.com" | |
echo " DocumentRoot $HOME/rails_apps/testapp/public" | |
echo " " | |
echo " AllowOverride all" | |
echo " Options -MultiViews" | |
echo " " | |
echo "" | |
echo -e "${NC}" | |
echo -e "${GREEN}" | |
echo "then Restart Apache: sudo /etc/init.d/apache2 restart" | |
echo "and Open on your browser: http://yourdormain.com or http://your-ip.com" | |
echo -e "${NC}" | |
fi | |
sudo a2enmod rewrite proxy ssl | |
sudo ln -s /etc/apache2/mods-available/proxy_http.load /etc/apache2/mods-enabled/proxy_http.load | |
apache2ctl configtest | |
apache2ctl graceful |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment