RimuHosting Forums  

Go Back   RimuHosting Forums > Share Knowledge

Reply
 
Thread Tools Display Modes
  #1  
Old 06-26-2006, 10:36 PM
retep retep is offline
RimuHosting Staff
 
Join Date: Jan 1970
Posts: 231
Default Rails Stack Install Script

RimuHosting provide a download and run rails install script at http://bliki.rimuhosting.com/space/k.../ruby+on+rails we recomend you use that if it suits your needs.

One customer setup a rails hosting stack (using a custom compiled apache 2.2). They provided the steps they took, so I'll post it here in case it is of any help to anyone else:

Before starting make sure you remove any existing Apache installation!

1/ Developer Tools
root@aserver:/usr/local/src# apt-get install build-essential

2/ ZLib Library
root@aserver:/usr/local/src# wget http://www.zlib.net/zlib-1.2.3.tar.gz
root@aserver:/usr/local/src# tar -xvf zlib-1.2.3.tar.gz

root@aserver:/usr/local/srcz/lib-1.2.3# ./configure
root@aserver:/usr/local/srcz/lib-1.2.3# make
root@aserver:/usr/local/srcz/lib-1.2.3# make install

3/ Apache 2.2
root@aserver:/usr/local/src# wget http://apache.rmplc.co.uk/httpd/httpd-2.2.2.tar.gz
root@aserver:/usr/local/src# tar -xvf httpd-2.2.2.tar.gz

root@aserver:/usr/local/src/httpd-2.2.2# ./configure --prefix=/usr/local/apache2 --enable-mods-shared=all --enable-deflate --enable-proxy --enable-proxy-balancer --enable-proxy-http
root@aserver:/usr/local/src/httpd-2.2.2# make
root@aserver:/usr/local/src/httpd-2.2.2# make install

4/ Setup Apache 2.2
Edit /usr/local/apache2/conf/httpd.conf and make sure it has the correct document root settings :: /var/www/

Un-comment the following options ...
-> Include conf/extra/httpd-vhosts.conf
-> Include conf/extra/httpd-default.conf

Then edit the v-hosts file and setup a couple of dummy sites just to make sure everything is working as it should

<VirtualHost *:80>
DocumentRoot /var/www/aserver.org/
ServerName aserver.org
ServerAlias www.aserver.org
ErrorLog logs/aserver.org-error_log
CustomLog logs/aserver.org-access_log common
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /var/www/aserver.com/
ServerName aserver.com
ServerAlias www.aserver.com
ErrorLog logs/aserver.com-error_log
CustomLog logs/aserver.com-access_log common
</VirtualHost>

Create the two directories in /var/www/ and place a index.html file in each, with some domain specific text in, so we can
differentiate between the two when testing.

Launch Apache

/usr/local/apache2/bin/apachectl start

Check the two sites, and if everything checks out, shut it back down

/usr/local/apache2/bin/apachectl stop

5/ Install Mongrel & Friends
root@aserver:/# gem install daemons gem_plugin mongrel mongrel_cluster sendfile --include-dependencies
Make sure when prompted you select the most recent, non mswin32 option.

6/ Create a test Rails app
root@aserver:/var/www# rails test

7/ Setting up the Mongrel cluster
Enter the test directory, and run the following command

root@aserver:/var/www/test# mongrel_rails cluster::configure -e production -p 8000 -c /var/www/test/ -a 127.0.0.1 -N 3

Which tells Mongrel to run a cluster of 3 servers (-N) for the app /var/www/test/ (-c) starting at port 8000 (-p) on
the host 127.0.0.1 (-a). We run them on the localhost so that there is no exposure to the outside world, Apache 2.2 will handle that

8/ Edit /var/www/test/config/mongrel_cluster.yml and comment out (#) the line 'address: 127.0.0.1' so that we can test the servers
are working from our remote workstation before closing them off and firing them up through Apache.

9/ To make sure the cluster comes back up after a reboot, copy the file

/usr/local/lib/ruby/gems/1.8/gems/mongrel_cluster-0.2.0/resources/mongrel_cluster -> /etc/init.d/mongrel_cluster

and make it executable with

root@aserver:/etc/init.d/# chmod +x mongrel_cluster

then make the appropriate changes to the start-up procedures to include the cluster

root@aserver:/# /usr/sbin/update-rc.d mongrel_cluster defaults

and finally create the directory /etc/mongrel_cluster/ and sym link the file /var/www/test/config/mongrel_cluster.yml to it.

root@aserver:/# ln -s /var/www/test/config/mongrel_cluster.yml /etc/mongrel_cluster/testapp.yml

10/ Fire up the cluster using

root@aserver:/# /etc/init.d/mongrel_cluster start

And then check the access by heading over to your site using the ports :8000, :8001 & :8002 and you should see the 'Welcome Aboard'
rails welcome page. If so, everything's gone okay so shut them back down

root@aserver:/# /etc/init.d/mongrel_cluster stop

And un-comment the 'address: 127.0.0.1' line in the mongrel_cluster.yml file as we are now going to setup Apache.

11/ Now setup four Apache config files to handle the site and proxy_balancer and store them with the others Apache conf files in
/usr/local/apache2/conf/extra

-> aserver.common

ServerName aserver.org
DocumentRoot /var/www/test/public

<Directory "/var/www/test/public">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

ProxyPass / balancer://mongrel_cluster/
ProxyPassReverse / balancer://mongrel_cluster/

RewriteEngine On

# Make sure people go to www.aserver.org, not aserver.org
RewriteCond %{HTTP_HOST} ^aserver.org$ [NC]
RewriteRule ^(.*)$ http://www.aserver.org$1 [R=301,L]

# Rewrite index to check for static
RewriteRule ^/$ /index.html [QSA]

# Rewrite to check for Rails cached page
RewriteRule ^([^.]+)$ $1.html [QSA]

# Redirect all non-static requests to cluster
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ balancer://mongrel_cluster%{REQUEST_URI} [P,QSA,L]

# Deflate
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript text/css
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIE !no-gzip !gzip-only-text/html

-> aserver.conf

<VirtualHost *:80>
Include /usr/local/apache2/conf/extra/aserver.common
ErrorLog logs/aserver_errors_log
CustomLog logs/aserver_log combined
</VirtualHost>

-> aserver.proxy_cluster.conf

<Proxy balancer://mongrel_cluster>
BalancerMember http://127.0.0.1:8000
BalancerMember http://127.0.0.1:8001
BalancerMember http://127.0.0.1:8002
</Proxy>

-> aserver.proxy_frontend.conf

Listen 8080
<VirtualHost *:8080>
<Location />
SetHandler balancer-manager
Deny from all
Allow from all
</Location>
</VirtualHost>

Once those have been created, add them to the bottom of the /usr/local/apache2/conf/httpd.conf file and comment out the existing
VirtualHost file we set up earlier.

Once that is done, start up the cluster again

root@aserver:/# /etc/init.d/mongrel_cluster start

And then Apache

/usr/local/apache2/bin/apachectl start

Fingers crossed everything should be up and running and ready to go !!

You can view the load balancer interface by going to :8080 on the domain you setup. To remove public access to this, change
the following line in aserver.proxy_frontend.conf

from 'Allow from all' to 'Allow from localhost'

Sources & Help
http://blog.codahale.com/2006/06/19/...trano-and-you/
http://mongrel.rubyforge.org/docs/mongrel_cluster.html
Reply With Quote
  #2  
Old 10-05-2006, 08:47 PM
addywaddy addywaddy is offline
Junior Member
 
Join Date: Oct 2006
Posts: 1
Default Installing Apache 2.2

I'm wanting to follow coda hale's tutorial cited in the above post but have alread run the rails stack install script. I understand that I need to remove Apache (version 2.0.52) but, ah, don't know how to. Help appreciated.
Reply With Quote
  #3  
Old 11-03-2006, 05:15 AM
toddvault toddvault is offline
Junior Member
 
Join Date: Nov 2006
Posts: 2
Default Detailed install instructions

Quote:
Originally Posted by addywaddy
I'm wanting to follow coda hale's tutorial cited in the above post but have alread run the rails stack install script. I understand that I need to remove Apache (version 2.0.52) but, ah, don't know how to. Help appreciated.
I think you can just do
Code:
sudo apt-get remove httpd
to remove the old apache. I ended up choosing fedora core 5 as my os since httpd 2.2 is in the package tree.

I have created full documentation of my setup

Last edited by toddvault; 11-03-2006 at 05:23 AM.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:01 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.