Showing posts with label install a simple easy ruby on rails server. Show all posts
Showing posts with label install a simple easy ruby on rails server. Show all posts

Monday, January 25, 2010

Automatically install a Full Ruby on Rails Mongrel Server

I have created the install files for a Simple Easy to get running Linux Ruby on Rails Server. Once you have installed your server using the openssh server option (or type 'apt-get install ssh openssh-server -y' at the command line), login to the server remotely. Then all you do is copy the code below to a notepad(or it breaks some of the -- links) file then do the following:

vi railsinstall ##the name of the file, no extension
Paste all the stuff below
:wq #to close the file
chmod +x railsinstall
./railsinstall #run the file to get the process rolling

It will need some info for mysql, etc so some attendance is needed, but it does most things without attendance. Here it is:
#############File starts here#################
##things to do before you run the script:
##visit the following sites and get the download links for the latest programs by right clicking on the correct extensions and copying the link location.
## http://rubyforge.org/frs/?group_id=126&release_id=37073
## http://apache.org/dyn/closer.cgi
##Also place your linux install cd in the cdrom drive as some installs will require it
##change your git details before you run this file

echo "making system adjustments" >> install.txt
locale-gen en_US.UTF-8
/usr/sbin/update-locale LANG=en_US.UTF-8

echo "creating the sources directory" >> install.txt
mkdir ~/sources
mkdir /var/www/
cd ~/sources

echo "copying sources file and uncommenting all repositories" >> /root/sources/install.txt
cp /etc/apt/sources.list /etc/apt/sources.list.orig2
sed -i -e "s/# deb/deb/g" /etc/apt/sources.list

echo "updating your system prior to the install" >> /root/sources/install.txt
aptitude update
aptitude safe-upgrade -y
aptitude full-upgrade -y
apt-get -f install
dpkg --configure -a

echo "installing build-essentials" >> /root/sources/install.txt
apt-get install build-essential -y


echo "Installing basic system requirements" >> /root/sources/install.txt
apt-get install vim
apt-get install ssh openssh-server

echo "Installing ruby" >> /root/sources/install.txt
sudo apt-get install ruby rdoc irb libyaml-ruby libzlib-ruby ri libopenssl-ruby ruby1.8-dev -y
sudo ln -s /usr/bin/gem1.8 /usr/local/bin/gem
sudo ln -s /usr/bin/rdoc1.8 /usr/local/bin/rdoc
sudo ln -s /usr/bin/ri1.8 /usr/local/bin/ri
sudo ln -s /usr/bin/irb1.8 /usr/local/bin/irb

echo "Installing rubygems" >> /root/sources/install.txt
wget "http http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz"
tar -xvzf rubygems-1.3.5.tgz
rm rubygems-1.3.5.tgz
cd rubygems-1.3.5
sudo ruby setup.rb
cd ..
rm -r rubygems-1.3.5
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
sudo gem update --system

echo "Installing apache2" >> /root/sources/install.txt
apt-get install apache2 apache2-mpm-prefork apache2-prefork-dev
sudo a2enmod proxy
sudo a2enmod rewrite
sudo /etc/init.d/apache2 restart
#wget http://apache.is.co.za/httpd/httpd-2.2.14.tar.gz
#tar -xzf httpd-2.2.14.tar.gz
#cd httpd-2.2.14
#./configure -–enable-rewrite –-enable-proxy
#make
#make install
#/usr/local/apache2/bin/httpd -k start
#cd ..

echo "Installing mysql" >> /root/sources/install.txt
sudo gem install mysql
sudo apt-get install libopenssl-ruby -y
sudo apt-get install libmysql-ruby mysql-server -y
sudo apt-get install libmysqlclient15-dev -y

echo "Installing rails" >> /root/sources/install.txt
sudo gem install rails

echo "Installing mongrel" >> /root/sources/install.txt
sudo gem install mongrel
gem install mongrel -–remote –-version=1.2.4
gem install mongrel_cluster
mkdir /etc/mongrel_cluster
cd /etc/mongrel_cluster
cp /usr/lib/ruby/gems/1.8/gems/mongrel_cluster-1.0.5/resources/mongrel_cluster /etc/init.d
chmod +x /etc/init.d/mongrel_cluster
/usr/sbin/update-rc.d -f mongrel_cluster defaults

Echo “install hobo” >> /root/sources/install.txt
gem install hobo

echo "Updating system" >> /root/sources/install.txt
gem update --system
gem update
echo "Please add the final touches to your system. You should now be able to install your application." >> /root/sources/install.txt


#################end of file########################

You may want to comment out hobo if you dont need it or any of the other items. Also check out the new app creation file also on this blog posted here which will automate your mongrel_cluster creation.

I offer NO WARRANTY and you should check the file before you run this in case it breaks something. you use it at your own accord.

I hope it works for you. Good Luck.

Installing a complete Ruby on Rails Server on Ubuntu

I have installed a few Rails servers using Ruby, Rails, apache, mongrel, etc. I got to a point that I got tired of following a file to do and having to monitor it. I tried passenger_stack and had problems with capistrano so eventually when I couldn't find the help I needed, I created my own fresh ubuntu linux 9.04 and newer(I think 8.04. will work as well if you really have to), based install file that automated the whole process. In order to get this running you will obviously need your install cd and preferably some knowledge of ruby, etc. Also, read the file as it requests you to get some file links for the latest stuff from relevant sites.

I usually right click on the download link and copy the link location and then change it in the script where its applicable. But, check the script if you not sure.

I hope this helps someone as its made my life a little simpler and its works for me 100%. There is also an added file which I drop into rails directory (/var/www/) and then edit the few options. When I run the file using ./filename.rb(whatever I named it.rb) it asks me the relevant questions, creates the application and the mongrel required files and sets it all up for me. Once I have edited the database and create the first controller for hobo or rails, it gives me the required screens. Then you ready to create your app without all the "copy to here" links, etc to get an app running. It also create the apache file, etc as it should be.

I offer NO WARRANTY and you should check the file before you run this in case it breaks something. you use it at your own accord.

Hopefully you can make this work for yourself. The links are:

Install a Rails server with Mongrel

Create Mongrel clusters easily

Good Luck.