Created
May 7, 2013 05:07
-
-
Save tyrotinal/5530381 to your computer and use it in GitHub Desktop.
railsHowTo: intalling Rails 3.2
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
#Installing RVM. | |
-------------------------------- | |
RVM is used for managing GEM sets and ruby versions. There is a lot that you can do with it. For more information visit: [RVM website](https://rvm.io/) | |
##Installing RVM Prereq: | |
echo ######Installing pre pre reqs######### | |
sudo apt-get update | |
sudo apt-get upgrade -y | |
sudo apt-get install build-essential zlib1g-dev libssl-dev libreadline-dev \ | |
git-core curl libyaml-dev libcurl4-dev libsqlite3-dev apache2-dev -y | |
##Installing RVM more prereq | |
sudo apt-get --no-install-recommends install bash curl git patch bzip2 | |
sudo apt-get --no-install-recommends install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev libgdbm-dev ncurses-dev automake libtool bison subversion pkg-config libffi-dev | |
sudo apt-get --no-install-recommends install curl g++ openjdk-6-jre-headless | |
##install RVM | |
\curl -#L https://get.rvm.io | bash -s stable --autolibs=3 --ruby | |
##Add source | |
echo "source ~/.rvm/scripts/rvm">> ~/.bash_profile | |
-------------------------------- | |
#Install Ruby 1.9.3 | |
rvm install ruby-1.9.3-p392 | |
##Use as default | |
rvm --default use 1.9.3 | |
-------------------------------- | |
#Install Rails | |
##Dependecies | |
sudo apt-get install libqt4-dev libqtwebkit-dev | |
sudo apt-get install ruby1.9.1-dev | |
sudo apt-get install build-essential libopenssl-ruby1.9.1 libssl-dev zlib1g-dev | |
##Add RVM rails and profile config | |
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && \ | |
. "$HOME/.rvm/scripts/rvm"' >> ~/.bash_profile | |
##Install it. | |
gem install rails | |
If you get error for i18 do the following: | |
rvm use 2.0.0 | |
gem install i18n | |
rvm use 1.9.3 | |
###Install mysql rails dependecies | |
sudo apt-get install libmysql-ruby libmysqlclient-dev | |
gem install mysql | |
gem install mysql2 | |
###Installing Passenger | |
sudo apt-get install apache2-prefork-dev | |
sudo apt-get install libcurl4-openssl-dev | |
####Install LAMP | |
echo "######INSTALLING PHP and apache and all the requriemtns########" | |
sudo apt-get install apache2 libapache2-mod-php5 -y | |
sudo apt-get install php5 mysql-server php-pear php5-mysql php5-suhosin -y | |
echo "######GOING TO ASK FOR PASSWORD HERE#########" | |
sudo apt-get install mysql-client mysql-server mysql-navigator php5-mysql php5-gd -y | |
echo "######checking if everything is installed#########" | |
sudo apt-get install apache2 libapache2-mod-php5 php5 mysql-server php-pear php5-mysql php5-suhosin mysql-client mysql-server mysql-navigator php5-mysql php5-gd -y | |
####INSTALL PASSENGER | |
rvm use 1.9.3 | |
gem install passenger | |
passenger-install-apache2-module | |
####record informatino given | |
LoadModule passenger_module /home/vagrant/.rvm/gems/ruby-1.9.3-p392/gems/passenger-3.0.19/ext/apache2/mod_passenger.so | |
PassengerRoot /home/vagrant/.rvm/gems/ruby-1.9.3-p392/gems/passenger-3.0.19 | |
PassengerRuby /home/vagrant/.rvm/wrappers/ruby-1.9.3-p392/ruby | |
####Example of vhost file | |
<VirtualHost *:80> | |
ServerAdmin [email protected] | |
ServerName flitti.com | |
ServerAlias www.flitti.com | |
DocumentRoot /srv/www/flitti.com/flitti/public | |
RailsEnv production | |
<Directory /srv/www/flitti.com/flitti/public> | |
Allow from all | |
AllowOverride all | |
Options -MultiViews | |
</Directory> | |
</VirtualHost> | |
or | |
If you want to use the default configuration: | |
<VirtualHost *:80> | |
DocumentRoot /srv/www/flitti.com/flitti/public | |
RailsEnv development | |
<Directory /srv/www/flitti.com/flitti/public> | |
Allow from all | |
AllowOverride all | |
Options -MultiViews | |
</Directory> | |
</VirtualHost> | |
###instlal node | |
####install the dependcies | |
sudo apt-get install python-software-properties python g++ make | |
####clone node and install | |
mkdir -p ~/local/src | |
cd ~/local/src | |
git clone git://github.com/joyent/node.git | |
cd node | |
git checkout v0.11.1-release | |
./configure --prefix=~/local | |
make | |
make install | |
echo 'PATH=$PATH:$HOME/local/bin' >> $HOME/.bash_profile | |
source ~/.bash_profile | |
##Setting up the rails installation app | |
sudo chown -R vagrant /srv/ | |
mkdir -p /srv/www/flitti.com | |
cd /srv/www/flitti.com | |
rails new flitti -d mysql | |
##RAKE DB: | |
rake db:create | |
##Setting up the apache server for rails | |
Add the loader to the apache config file: | |
sudo vi /etc/apache2/apache2.conf | |
And add the config line that you got from passenger installation: | |
LoadModule passenger_module /home/vagrant/.rvm/gems/ruby-1.9.3-p392/gems/passenger-3.0.19/ext/apache2/mod_passenger.so | |
PassengerRoot /var/lib/gems/1.9.1/gems/passenger-3.0.19 | |
PassengerRuby /usr/bin/ruby1.9.1 | |
Then we need to change the virtual host file. Here is an example: | |
<VirtualHost *:80> | |
ServerAdmin [email protected] | |
ServerName flitti.com | |
ServerAlias www.flitti.com | |
DocumentRoot /srv/www/flitti.com/flitti/public | |
RailsEnv production | |
<Directory /srv/www/flitti.com/flitti/public> | |
Allow from all | |
AllowOverride all | |
Options -MultiViews | |
</Directory> | |
</VirtualHost> | |
If you want get something done quickly if you are using a virtual machine and vagrant and don't want to bother with setting up virtual hosts and just want to use port forwarding, it is not recommended, but you can edit the default virtual host file of apache to point to your current rails app. Here is an example. Do: | |
sudo vi /etc/apache2/sites-available/default | |
and then copy paste theis: | |
<VirtualHost *:80> | |
PassengerRoot /home/vagrant/.rvm/gems/ruby-1.9.3-p392/gems/passenger-3.0.19 | |
PassengerRuby /home/vagrant/.rvm/wrappers/ruby-1.9.3-p392/ruby | |
DocumentRoot /srv/www/flitti.com/flitti/public | |
RailsEnv development | |
<Directory /srv/www/flitti.com/flitti/public> | |
Allow from all | |
AllowOverride all | |
Options -MultiViews | |
</Directory> | |
</VirtualHost> | |
It is important to load the current passenger fconfiguration. And you got that when you installed passenger. | |
Finally do: | |
sudo /etc/init.d/apache2 reload | |
sudo /etc/init.d/apache2 restart | |
If you did everything right, you won't see apache complain, otherwise, you have to fix things up. | |
###add Javascript runtime: | |
Add 'therubyracer' gem to your gem file inside your rails application and run bundle. | |
gem 'therubyracer' | |
bundle | |
And now you are good to go ! | |
------------------------------------------------------- | |
------------------------------------------------------- | |
###MORE Additional stuff that happened during the installation. | |
###install ref gem | |
gem install ref | |
###Install the therubyracer gme | |
gem install therubyracer --version "~> 0.10.2" | |
cd /srv/www/flitti.com/flitti | |
And then do: | |
bundle install | |
Then you need to go to the site and open it in the browser and see what kind of error you get from passenger. then instlal the gem that is missing. In my case: | |
gem install coffee-script-source | |
touch tmp/restart.txt | |
also add the gem in your gem file of rails: | |
gem 'coffee-script-source' | |
Then refresh. Then it might not still fix the problem. | |
But the issue might be that the gems are installed for 2.0.0 version of ruby and not for 1.9.3. If that is the case do: | |
rvm use 1.9.3 | |
bundle install | |
The other reason might be that passenger needs configuration to work with ruby 2.0.0 gem sets and only works now with 1.9.3. Last step do: | |
touch tmp/restart.txt | |
then add therubyracer gem to your gem file and run bundle: | |
gem 'therubyracer' | |
bundle | |
Last step is to restart the server: | |
touch tmp/restart.txt | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment