<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Rails Forum - Ruby on Rails Help and Discussion Forum - How to install Thin Web Server in Linux in 2 Minutes & 10 Easy Steps]]></title>
		<link>http://railsforum.com/viewtopic.php?id=17284</link>
		<description><![CDATA[The most recent posts in How to install Thin Web Server in Linux in 2 Minutes & 10 Easy Steps.]]></description>
		<lastBuildDate>Sun, 01 Jul 2012 19:46:34 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: How to install Thin Web Server in Linux in 2 Minutes & 10 Easy Steps]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=153683#p153683</link>
			<description><![CDATA[<p>Please help, I am trying to set up a rails app on Ubuntu 12.04, ruby, gems, rails, apache, thin, are all installed. If I start a thin cluster I can go to the website and the welcome page shows <br /></p><div class="codebox"><pre><code>domain.com:3000
domain.com:3001
domain.com:3002</code></pre></div><p>all work so I know that thin is doing its thing, and I can get apache without proxy to load the index.htm (though without the assets working correctly as expected). </p><p>However I can&#039;t seem to get apache to actually pass the request off to the thin servers! I get a soft 404 (page can&#039;t be found) error or the It works page, and I don&#039;t know why. </p><p>here is the sites-available file<br /></p><div class="codebox"><pre><code>&lt;VirtualHost *:80&gt;

    ServerName myapp.mydomain.com
    DocumentRoot /home/sim/public_html/railsapp

    &lt;Proxy balancer://thinservers&gt;
        BalancerMember http://127.0.0.1:3000
        BalancerMember http://127.0.0.1:3001
        BalancerMember http://127.0.0.1:3002
    &lt;/Proxy&gt;

    ProxyPreserveHost On
    ProxyPass /assets !
    ProxyPass / balancer://thinservers/
    ProxyPassReverse / balancer://thinservers/

    &lt;Proxy *&gt;
     Order deny,allow
     Allow from all
    &lt;/Proxy&gt;
&lt;/VirtualHost&gt;</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (acooper86)]]></author>
			<pubDate>Sun, 01 Jul 2012 19:46:34 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=153683#p153683</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to install Thin Web Server in Linux in 2 Minutes & 10 Easy Steps]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=150264#p150264</link>
			<description><![CDATA[<p>Hi ,</p><p>I see you posted great instruction to install webserver</p><p>But I recommend that you should highlight the command for subscriber to easily use</p><p>Below is also one post for quickly virtual web server installation on linux :</p><p><a href="http://vnluck.com/2012/01/how-to-setup-a-virtual-web-server-in-10-minutes/">http://vnluck.com/2012/01/how-to-setup- &#133; 0-minutes/</a></p>]]></description>
			<author><![CDATA[dummy@example.com (tiger_girl_25)]]></author>
			<pubDate>Sun, 26 Feb 2012 13:56:23 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=150264#p150264</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to install Thin Web Server in Linux in 2 Minutes & 10 Easy Steps]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=139511#p139511</link>
			<description><![CDATA[<p>Awesome ! thanks !</p>]]></description>
			<author><![CDATA[dummy@example.com (Saidbek)]]></author>
			<pubDate>Mon, 11 Apr 2011 16:39:58 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=139511#p139511</guid>
		</item>
		<item>
			<title><![CDATA[How to install Thin Web Server in Linux in 2 Minutes & 10 Easy Steps]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=59179#p59179</link>
			<description><![CDATA[<p>How to install Thin Web Server in a Fedora/RedHat Linux Server in 2 Minutes !!!</p><p>This tutorial/tip will show you how to install Thin web server in Fedora/RedHat Linux in 2 Minutes </p><p>First lets see if we have Thin installed.<br />[me@fedora me]$ gem list | grep thin</p><p>1.- Lets Install Thin web server.<br />As root:<br />[root@fedora ~]# gem install thin</p><p>or with sudo:<br />[me@fedora phonebook]$ sudo gem install thin</p><p>To verify if Thin is installed:<br />[me@fedora me]$ gem list |grep thin<br />thin (0.8.0, 0.7.1, 0.7.0)</p><p>To show the version of Thin:<br />[root@fedora ~]# thin -v<br />thin 0.8.0 codename Dodgy Dentist</p><p>2.- Lets create a Rails Application</p><p>[me@fedora me]$ rails phonebook -d mysql<br /># Note in Rails 2.0.2 the default database is sqlite.... but I love MySQL make sure to setup properly.</p><p>3.- [me@fedora me]$ cd phonebook</p><br /><p>4.- For the Quick &amp; Dirty:<br />thin start -e development -p 3000 -s 5 -d</p><p>Where:<br />-e == Environment in this case development<br />-p == TCP/IP Port in this case 3000<br />-s == Instances of the webserver in this case 5<br />-d == Daemonize to run in background</p><p>[me@fedora phonebook]$ thin start -e development -p 3000 -s 5 -d<br />Starting server on 0.0.0.0:3000 ... <br />Starting server on 0.0.0.0:3001 ... <br />Starting server on 0.0.0.0:3002 ... <br />Starting server on 0.0.0.0:3003 ... <br />Starting server on 0.0.0.0:3004 ... <br />[me@fedora phonebook]$ </p><p>We just start 5 instances of the Thin Web Server on ports [3000..3004]<br />Open your browser on:<br /><a href="http://127.0.0.1:3000">http://127.0.0.1:3000</a><br /><a href="http://127.0.0.1:3001">http://127.0.0.1:3001</a><br /><a href="http://127.0.0.1:3002">http://127.0.0.1:3002</a><br /><a href="http://127.0.0.1:3003">http://127.0.0.1:3003</a><br /><a href="http://127.0.0.1:3004">http://127.0.0.1:3004</a></p><p>All the PID&#039;s are located in: phonebook/tmp/pids/<br />[me@fedora phonebook]$ ls -l tmp/pids/<br />-rw-r--r-- 1 me me&nbsp; &nbsp; 5 Apr&nbsp; 7 21:48 thin.3000.pid<br />-rw-r--r-- 1 me me&nbsp; &nbsp; 5 Apr&nbsp; 7 21:48 thin.3001.pid<br />-rw-r--r-- 1 me me&nbsp; &nbsp; 5 Apr&nbsp; 7 21:48 thin.3002.pid<br />-rw-r--r-- 1 me me&nbsp; &nbsp; 5 Apr&nbsp; 7 21:48 thin.3003.pid<br />-rw-r--r-- 1 me me&nbsp; &nbsp; 5 Apr&nbsp; 7 21:48 thin.3004.pid</p><p>4a.- I&#039;m lazy and create a very simple shell script to stop this running processes.<br />my_stop.sh</p><p>[me@fedora phonebook]$ vi my_stop.sh</p><p>####################<br />#!/bin/bash</p><p>this_path=`pwd`<br />pids_path=&quot;$this_path/tmp/pids/*.pid&quot;</p><p>for thin_pid in $pids_path<br />do<br />&nbsp; &nbsp; echo &quot;Stoping Thin Instance $thin_pid&quot;<br />&nbsp; &nbsp; thin stop -P $thin_pid<br />done <br />####################</p><p>4b.- Lets allow my_stop.sh to run:<br />[me@fedora phonebook]$ chmod 755 my_stop.sh</p><p>Lets stop the daemonize Thin web server.<br />[me@fedora phonebook]$ ./my_stop.sh <br />Stoping Thin Instance /mywww/rails/phonebook/tmp/pids/thin.3000.pid<br />Sending QUIT signal to process 24610 ... <br />Stoping Thin Instance /mywww/rails/phonebook/tmp/pids/thin.3001.pid<br />Sending QUIT signal to process 24614 ... <br />Stoping Thin Instance /mywww/rails/phonebook/tmp/pids/thin.3002.pid<br />Sending QUIT signal to process 24618 ... <br />Stoping Thin Instance /mywww/rails/phonebook/tmp/pids/thin.3003.pid<br />Sending QUIT signal to process 24622 ... <br />Stoping Thin Instance /mywww/rails/phonebook/tmp/pids/thin.3004.pid<br />Sending QUIT signal to process 24626 ... <br />[me@fedora phonebook]$ </p><p>[Note the PID&#039;s surely will be different in your computer, but you get the idea ;-) ]</p><p>4c.- Just to verify there is no more Thin PID files in tmp/pids:<br />[me@fedora phonebook]$ ls -l tmp/pids/<br />total 0</p><p>This is a quick &amp; dirty Tip on how to get going with Thin, but is not a scalable solution.<br />In order to make Thin webserver start/stop automatically just like any other Fedora/RedHat service follow the <br />following steps:</p><p>5.- Once Thin gem is installed lets install it into the FileSystem.</p><p>As root execute:<br />[root@fedora phonebook]# thin install<br />or with sudo:<br />[me@fedora phonebook]$ sudo thin install</p><p>&gt;&gt; Installing thin service at /etc/init.d/thin ...<br />mkdir -p /etc/init.d<br />writing /etc/init.d/thin<br />chmod +x /etc/init.d/thin<br />mkdir -p /etc/thin</p><p>To configure thin to start at system boot:<br />on RedHat like systems:<br />&nbsp; sudo /sbin/chkconfig --level 345 thin on<br />on Debian-like systems (Ubuntu):<br />&nbsp; sudo /usr/sbin/update-rc.d -f thin defaults<br />on Gentoo:<br />&nbsp; sudo rc-update add thin default</p><p>Then put your config files in /etc/thin<br />[root@fedora phonebook]#</p><p>The folks at Thin did a great job here, few things will happen:</p><p>Should install /etc/init.d/thin for you. It works a lot like mongrel_cluster. It looks in /etc/thin for your thin config yaml files. </p><p>All the configuration yaml configuration files will be located at:<br />/etc/thin/rails_app1.yml<br />/etc/thin/rails_app2.yml<br />...<br />/etc/thin/rails_app3.yml</p><p>As many application as you want and your RAM can allow ;-)&nbsp; [ Be careful here each instance will take about 20MB Ram and for VPS with 64Bit will take around 40M. So if you create about 10 instances at 20MB/instance will be 200MB very easy, lets said you configure 5 rails applications you will eat 1GB of RAM in no time. so use the instances wisely and conservative, its not about quantity is about quality <img src="http://railsforum.com/img/smilies/smile.png" width="15" height="15" alt="smile" />.</p><p>6.- I recommend to use it similar to how mongrel cluster configuration is handled.</p><p>Create a thin.yml in your config folder of your rails app and then make a symlink to your /etc/thin folder such as /etc/thin/rails_appN.yml. This yaml file will look similar to mongrel_cluster with a few differences. Here&#039;s a sample configuration:<br />File: [ phonebook/config/thin_cluster.yml ]<br />---<br />user: me<br />group: me<br />chdir: /home/me/phonebook<br />log: log/thin.log<br />port: 3000<br />environment: development<br />pid: tmp/pid/thin.pid<br />servers: 5</p><p>Note: Jack Chu reports to be using a unix socket instead of a port and it works very nicely with nginx. &quot;chdir&quot; is the path of your rails app (similar to &quot;cwd&quot; in mongrel) and there&#039;s also some subtle differences like log vs log_file and pid vs pid_file. If you want to use a port instead of a socket, just use port: &quot;3000&quot; and so on.</p><p>Jack Chu - Sample configuration.<br />File: [ phonebook/config/thin_cluster.yml ]<br />---<br />user: www-data<br />group: www-data<br />chdir: /var/www/test.com/apps/redmine<br />log: log/thin.log<br />socket: /var/run/thin/redmine.sock<br />environment: production<br />address: 127.0.0.1<br />pid: /var/run/thin/redmine.pid<br />servers: 1 </p><p>7.- Ok so we have our thin_cluster.yml file lets create the Symbolic Link to the /etc/thin directory:</p><p>As root <br />[root@fedora phonebook]# ln -s /home/me/phonebook/config/thin_cluster.yml /etc/thin/phonebook.yml<br />Or as a regular user using sudo:<br />[me@fedora phonebook]$ sudo&nbsp; ln -s /home/me/phonebook/config/thin_cluster.yml /etc/thin/phonebook.yml</p><p>Note: Replace this path: [ /home/me/phonebook ] with the absolute path &amp; name of your rails application.</p><p>8.- Once we have Thin installed, the properly configuration files thin_cluster.yml with their symbolic links to the /etc/thin directory lets activate Thin on start for Fedora:</p><p>As root:<br />[root@fedora phonebook]# /sbin/chkconfig --level 345 thin on</p><p>Just to verify that everything looks good:<br />[root@fedora phonebook]# /sbin/chkconfig --list |grep thin<br />thin&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0:off&nbsp; &nbsp;1:off&nbsp; &nbsp;2:on&nbsp; &nbsp; 3:on&nbsp; &nbsp; 4:on&nbsp; &nbsp; 5:on&nbsp; &nbsp; 6:off</p><p>9.- Great now we can start Thin on boot or just like any other Fedora/RedHat service:</p><p>[root@fedora phonebook]# /etc/init.d/thin start</p><p>[root@fedora phonebook]# /etc/init.d/thin start<br />[start] /etc/thin/phonebook.yml ...<br />Starting server on 0.0.0.0:3000 ... <br />Starting server on 0.0.0.0:3001 ... <br />Starting server on 0.0.0.0:3002 ... <br />Starting server on 0.0.0.0:3003 ... <br />Starting server on 0.0.0.0:3004 ... </p><p>Great go a head and open your browser in any of the following URL&#039;s:<br /><a href="http://127.0.0.1:3000">http://127.0.0.1:3000</a><br /><a href="http://127.0.0.1:3001">http://127.0.0.1:3001</a><br /><a href="http://127.0.0.1:3002">http://127.0.0.1:3002</a><br /><a href="http://127.0.0.1:3003">http://127.0.0.1:3003</a><br /><a href="http://127.0.0.1:3004">http://127.0.0.1:3004</a></p><p>Pretty Cool !!!.&nbsp; You just create a Thin_Cluster in about 2 Minutes !!!.</p><p>[root@fedora phonebook]# /etc/init.d/thin stop<br />[stop] /etc/thin/phonebook.yml ...<br />Stopping server on 0.0.0.0:3000 ... <br />Sending QUIT signal to process 24833 ... <br />&gt;&gt; Exiting!<br />Stopping server on 0.0.0.0:3001 ... <br />Sending QUIT signal to process 24837 ... <br />&gt;&gt; Exiting!<br />Stopping server on 0.0.0.0:3002 ... <br />Sending QUIT signal to process 24841 ... <br />&gt;&gt; Exiting!<br />Stopping server on 0.0.0.0:3003 ... <br />Sending QUIT signal to process 24845 ... <br />&gt;&gt; Exiting!<br />Stopping server on 0.0.0.0:3004 ... <br />Sending QUIT signal to process 24849 ... <br />&gt;&gt; Exiting!</p><p>Note you can have as many symbolic links in /etc/thin pointing to different cluster configuration files thin_cluster.yml. thin start or stop will apply to all the applications.</p><p>10.- The only thing left to do is to setup a Virtual Host Directive in Apache and use te load_balancer option to distribute the pages on the cluster. Use the following configuration as a reference:</p><p>Assuming we try to setup the domain railsapplicationtip.com with the IP [123.123.123.123] using Apache Cluster Balancer we called: my_railsapp1.<br />URL: <a href="http://www.railsapplicationtip.com">www.railsapplicationtip.com</a><br />IP: 123.123.123.123<br />Cluster Balancer: my_railsapp1</p><p>Edit the httpd.conf file and insert the following configuration:<br />########################################<br />&lt;Proxy balancer://my_railsapp1&gt;<br />BalancerMember <a href="http://127.0.0.1:3000">http://127.0.0.1:3000</a><br />BalancerMember <a href="http://127.0.0.1:3001">http://127.0.0.1:3001</a><br />BalancerMember <a href="http://127.0.0.1:3002">http://127.0.0.1:3002</a><br />BalancerMember <a href="http://127.0.0.1:3003">http://127.0.0.1:3003</a><br />BalancerMember <a href="http://127.0.0.1:3004">http://127.0.0.1:3004</a><br />&lt;/Proxy&gt;</p><p>&lt;VirtualHost 123.123.123.123:80&gt;<br />ServerAdmin webmaster@railsapplicationtip.com<br />ServerName railsapplicationtip.com<br />ServerAlias <a href="http://www.railsapplicationtip.com">www.railsapplicationtip.com</a><br />RewriteEngine on<br />ProxyPass / balancer://my_railsapp1/<br />ProxyPassReverse / balancer://my_railsapp1/<br />ErrorLog logs/railsapplicationtip-error_log<br />CustomLog logs/railsapplicationtip-access_log common<br />&lt;/VirtualHost&gt;<br />########################################</p><p>Start apache:<br />[root@fedora /]# /etc/init.d/thin start<br />[root@fedora /]# /etc/init.d/apache start</p><p>If you have the properly DNS configuration you should be able to open your browser at:</p><p><a href="http://railsapplicationtip.com">http://railsapplicationtip.com</a></p><p>Your Rails applications is working with a Thin Cluster and being allocated with the Apache Load_Balancer Module !!!.</p><p>Dinooz.<br />Brains R Like books only work when they R Open.</p>]]></description>
			<author><![CDATA[dummy@example.com (dinooz)]]></author>
			<pubDate>Tue, 08 Apr 2008 18:43:32 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=59179#p59179</guid>
		</item>
	</channel>
</rss>
