<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>david winter &#187; rails</title>
	<atom:link href="http://davidwinter.me.uk/articles/tag/rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://davidwinter.me.uk</link>
	<description>you were expecting someone else?</description>
	<lastBuildDate>Mon, 28 Jun 2010 20:37:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Install Rails 2.0 RC1</title>
		<link>http://davidwinter.me.uk/articles/2007/11/15/install-rails-20-rc1/</link>
		<comments>http://davidwinter.me.uk/articles/2007/11/15/install-rails-20-rc1/#comments</comments>
		<pubDate>Thu, 15 Nov 2007 17:24:21 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://davidwinter.me.uk/articles/2007/11/15/install-rails-20-rc1/</guid>
		<description><![CDATA[sudo gem install rails -v 1.99.0 -y --source http://gems.rubyonrails.com]]></description>
			<content:encoded><![CDATA[<pre><code>sudo gem install rails -v 1.99.0 -y --source http://gems.rubyonrails.com
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://davidwinter.me.uk/articles/2007/11/15/install-rails-20-rc1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Initial Rails Subversion Project Setup</title>
		<link>http://davidwinter.me.uk/articles/2007/10/29/initial-rails-subversion-project-setup/</link>
		<comments>http://davidwinter.me.uk/articles/2007/10/29/initial-rails-subversion-project-setup/#comments</comments>
		<pubDate>Mon, 29 Oct 2007 20:31:53 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://davidwinter.me.uk/articles/2007/10/29/initial-rails-subversion-project-setup/</guid>
		<description><![CDATA[rails my_project cd my_project/ svn import . http://svn cd ~/Projects svn co http://svn/my_project/trunk my_project cd my_project/ svn rm log/* svn rm tmp/* svn mv config/database.yml config/database.yml.example svn ci -m "Removed files to ignore in SVN." svn propset svn:ignore "*.log" log/ svn propset svn:ignore "*" tmp/ svn propset svn:ignore "database.yml" config/ svn ci -m "Ignoring files [...]]]></description>
			<content:encoded><![CDATA[<pre><code>rails my_project
cd my_project/
svn import . http://svn
cd ~/Projects
svn co http://svn/my_project/trunk my_project
cd my_project/
svn rm log/*
svn rm tmp/*
svn mv config/database.yml config/database.yml.example
svn ci -m "Removed files to ignore in SVN."
svn propset svn:ignore "*.log" log/
svn propset svn:ignore "*" tmp/
svn propset svn:ignore "database.yml" config/
svn ci -m "Ignoring files for SVN."
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://davidwinter.me.uk/articles/2007/10/29/initial-rails-subversion-project-setup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu Dapper Web Server How-to</title>
		<link>http://davidwinter.me.uk/articles/2006/08/09/ubuntu-dapper-web-server-how-to/</link>
		<comments>http://davidwinter.me.uk/articles/2006/08/09/ubuntu-dapper-web-server-how-to/#comments</comments>
		<pubDate>Wed, 09 Aug 2006 09:11:32 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[apache]]></category>
		<category><![CDATA[dapper]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://davidwinter.me.uk/articles/2006/10/13/ubuntu-dapper-web-server-how-to/</guid>
		<description><![CDATA[It&#8217;s finally here, my updated how-to on how to get Ubuntu Dapper up and running as a home web server. Perfect for hosting those small web sites and blogs. My original Ubuntu 5.10 web server how-to is still available. This updated version is very similar to the 5.10 how-to, however, there are a few changes [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s finally here, my updated how-to on how to get Ubuntu Dapper up and running as a home web server. Perfect for hosting those small web sites and blogs. My original <a href="http://davidwinter.me.uk/articles/2006/02/05/ubuntu-5-10-web-server-howto">Ubuntu 5.10 web server how-to</a> is still available.</p>

<p>This updated version is very similar to the 5.10 how-to, however, there are a few changes required. The following changes have been made:</p>

<ul>
<li>Setting up the Multiverse and Universe repositories</li>
<li>The packages to install Ruby</li>
<li>Setting a symbolic link for Ruby</li>
<li>Updating rubygems</li>
<li>Clearing the rubygems cache</li>
</ul>

<p>Other than those, the rest of the how-to is the same as the Breezy how-to. </p>

<p><span id="more-30"></span></p>

<p>This how-to assumes that you have a clean install of Ubuntu Dapper (I&#8217;m not currently using Ubuntu Dapper Server, just the <strong>basic desktop install</strong>).</p>

<p>The first thing to do, is get <code>ssh</code> installed so that if you like, you can connect and do all of this remotely.</p>

<pre><code>sudo apt-get install ssh
</code></pre>

<p>There are some packages that are needed that aren&#8217;t in the default repositories for <code>apt</code>, so you have to enable them manually. Universe and Multiverse are needed.</p>

<p>To enable them, open up the Synaptic Package Manager</p>

<ol>
<li>Settings</li>
<li>Repositories</li>
<li>Add</li>
<li>Ensure that &#8216;Ubuntu 6.06 LTS&#8217; is the selected &#8216;Channel&#8217;</li>
<li>Check &#8216;Community maintained (Universe)&#8217;</li>
<li>Check &#8216;Non-free (Multiverse)</li>
<li>Click OK and let it rescan the servers.</li>
</ol>

<p>You can then close Synaptic. <code>apt</code> is now all set up ready for installing the packages we need.</p>

<p>Before we start installing the packages we want, do a system update:</p>

<pre><code>sudo apt-get update
</code></pre>

<h3>Ruby</h3>

<p>All on one line:</p>

<pre><code>sudo apt-get install irb libdbm-ruby libfcgi-ruby1.8 libgdbm-ruby libmysql-ruby libopenssl-ruby libruby1.8-dbg ri ruby1.8-dev
</code></pre>

<p>In order for Ruby to work ok, do the following:</p>

<pre><code>sudo ln -s /usr/bin/ruby1.8 /usr/bin/ruby
</code></pre>

<p>This will add a symbolic link into your <code>/usr/bin</code> directory so that the command <code>ruby</code> works, as opposed to <code>ruby1.8</code>.</p>

<h3>MySQL Server</h3>

<pre><code>sudo apt-get install mysql-server
</code></pre>

<p>During this install, a Postfix config screen will appear. Select OK and then &#8220;No configuration&#8221;.</p>

<h3>Ruby Gems &amp; Rails</h3>

<p>This is the standard way of installing ruby applications.</p>

<p>Need to download it directly from its web site:</p>

<pre><code>wget http://rubyforge.org/frs/download.php/5207/rubygems-0.8.11.tgz
</code></pre>

<p>Then extract it:</p>

<pre><code>tar xvfz rubygems-0.8.11.tgz
</code></pre>

<p>Move into the extracted directory:</p>

<pre><code>cd rubygems-0.8.11
</code></pre>

<p>Run the setu-p program:</p>

<pre><code>sudo ruby1.8 setup.rb
</code></pre>

<p>Update all installed gems on the system:</p>

<pre><code>sudo gem update --system
</code></pre>

<p>Take note that there are two dashes preceding <code>system</code>.</p>

<p>Now that Ruby Gems is installed, we can install Rails. However, I encountered problems with this and had to clear my rubygems cache first. Do the following:</p>

<pre><code>gem env gemdir
</code></pre>

<p>This will output a path location which you&#8217;ll need to use for the next command. For me, it was and probably is the same for you, <code>/usr/lib/ruby/gems/1.8</code></p>

<pre><code>sudo rm ABOVE_PATH/source_cache
</code></pre>

<p>This will clear your rubygems cache. Now you shouldn&#8217;t have any problems with installing rails.</p>

<pre><code>sudo gem install rails -y
</code></pre>

<h3>Apache 2</h3>

<p>Next is the web server I&#8217;m using. Apache 2. The following command will install Apache 2, FastCGI, FCGI, PHP 5 with MySQL functionality. PHP isn&#8217;t needed for Ruby or Rails, but I&#8217;m including it so that I can run PHP apps&#8230;</p>

<pre><code>sudo apt-get install apache2 libapache2-mod-fcgid libapache2-mod-fastcgi libapache2-mod-php5 php5-mysql
</code></pre>

<p>Once that&#8217;s done, we&#8217;ll need to enable the Apache mods we&#8217;ll be using:</p>

<pre><code>sudo a2enmod fcgid
sudo a2enmod fastcgi
sudo a2enmod rewrite
</code></pre>

<p>You&#8217;ll notice I&#8217;ve installed two different types of Fast CGI. That&#8217;s because at some point I want to try them both out. However, at the moment, I&#8217;ve only had success with getting FastCGI working decently.</p>

<p>Restart Apache to make sure all is well.</p>

<pre><code>sudo /etc/init.d/apache2 restart
</code></pre>

<h3>FastCGI</h3>

<p>I thought FastCGI would have been installed after doing the libapache2-mod-fastcgi &#8211; but for some reason, you have to install it manually.</p>

<p>In order to configure and build from the source files, you need to download some basic files:</p>

<pre><code>sudo apt-get install build-essential
</code></pre>

<p>Then, grab the FastCGI files from the web site:</p>

<pre><code>wget http://fastcgi.com/dist/fcgi-2.4.0.tar.gz
</code></pre>

<p>Extract:</p>

<pre><code>tar xvfz fcgi-2.4.0.tar.gz
</code></pre>

<p>Move into the directory:</p>

<pre><code>cd fcgi-2.4.0
</code></pre>

<p>Configure the installer:</p>

<pre><code>./configure
</code></pre>

<p>Install:</p>

<pre><code>sudo make install
</code></pre>

<p>Now, that is all of the Apache and FastCGI files installed. Later, we&#8217;ll need to configure it all.</p>

<h3>Webmin</h3>

<p>Webmin is ugly, but it works, and it lets us configure Apache and the Nameserver easily.</p>

<p>Go to http://www.webmin.com/ and download the latest version of webmin in tar.gz format.</p>

<p>Once downloaded, extract it (filename may vary depending on the version you download):</p>

<pre><code>tar xvfz webmin-1.260.tar.gz
</code></pre>

<p>Move into the directory:</p>

<pre><code>cd webmin-1.260
</code></pre>

<p>Run the set-up program:</p>

<pre><code>sudo ./setup.sh /usr/local/webmin
</code></pre>

<p>You can use the default settings for this, or change them if you know what you&#8217;re doing. Be sure to set a password you can remember.</p>

<p>At the end of the set-up you&#8217;ll be given an address to use to connect to webmin. Remember this! and go to it straight away and login.</p>

<p>Do the following to configure Webmin to work with Apache:
1. At the top, click on the &#8220;Servers&#8221; link.
2. Select Apache Webserver.
3. Select Module Config.
4. Set the following values:
    * Apache Server Root &#8211; /etc/apache2
    * Path to httpd executable &#8211; /usr/sbin/apache2
    * Path to httpd.conf &#8211; /etc/apache2/httpd.conf
    * Command to start Apache &#8211; /etc/init.d/apache2 start
    * Command to stop Apache &#8211; /etc/init.d/apache2 stop</p>

<p>Save these settings.</p>

<h3>Nameserver</h3>

<p>I&#8217;m no DNS expert, so this is very vague and I suggest you go read a howto on DNS&#8230; <a href="http://rimuhosting.com/support/bindviawebmin.jsp">here&#8217;s one</a> I used to complete this part.</p>

<p>This will be different depending on your set-ups. For me, I have my domain name pointing to my web server in America that hosts http://commanderbond.net </p>

<p>On the server, there, I have the DNS pointing to my Internet IP at home, here in the UK.</p>

<p>The nameserver I&#8217;m using is Bind.</p>

<pre><code>sudo apt-get install bind9
</code></pre>

<p>Once that&#8217;s installed, we need to configure it in Webmin.
1. Click the &#8220;Servers&#8221; link.
2. Select BIND DNS Server.
3. A message will appear about a configuration file. Select the 3rd option &#8220;Setup as an internet name server, but use Webmin&#8217;s older root server information&#8221;
4. Create a Master Zone and enter the following details:
    * Domain Name &#8211; yourdomain.com
    * Email &#8211; you@anemail.com
5. Click on &#8220;Create&#8221;.
6. Click on the &#8220;Address&#8221; link.
7. Create a new Address record using the following:
    * Name &#8211; yourdomain.com. (including the trailing dot)
    * Address &#8211; your Internet IP address
8. Click on &#8220;Create&#8221;.
9. Go to the Module Index.
10. Click on &#8220;Apply Changes&#8221;.</p>

<h3>Set-up your web site</h3>

<p>You&#8217;ll need somewhere to store your web site files, so I suggest to first of all create a <code>public_html</code> directory in your user directory.</p>

<pre><code>mkdir ~/public_html
</code></pre>

<p>Now we&#8217;ll create a test HTML file to check all is working so far.</p>

<pre><code>nano ~/public_html/index.html
</code></pre>

<p>Inside it put the following:</p>

<pre><code>&lt;p&gt;Hopefully you can see this...&lt;/p&gt;
</code></pre>

<p>Save the file using Control O and then Control X to quit Nano.</p>

<p>Now, set the permissions of the file so it&#8217;s visible to the world:</p>

<pre><code>chmod 644 ~/public_html/index.html
</code></pre>

<p>In Webmin, go to the Apache configuration.</p>

<p>Create a new Virtual Server with the following:
* Document Root &#8211; home/yourusername/public_html
* Server Name &#8211; yourdomain.com</p>

<p>Save the settings. Now restart Apache:</p>

<pre><code>sudo /etc/init.d/apache2 restart
</code></pre>

<p>Now visit http://yourdomain.com/~yourusername/ and you should see:</p>

<blockquote>
  <p>Hopefully you can see this&#8230;</p>
</blockquote>

<p>If so, excellent! If not, hmmm&#8230; maybe you didn&#8217;t follow everything? or I made a mistake somewhere&#8230; leave a comment below.</p>

<p>Take a 5 minute break!</p>

<p>Refreshed? Right. Moving on&#8230;</p>

<h3>phpMyAdmin for MySQL management</h3>

<p>Go to http://www.phpmyadmin.net/home_page/index.php and download the latest stable release of phpMyAdmin in tar.gz format.</p>

<p>Extract:</p>

<pre><code>tar xvfz phpMyAdmin-2.7.0-pl2.tar.gz
</code></pre>

<p>Move the directory to some place helpful:</p>

<pre><code>mv phpMyAdmin-2.7.0-pl2 ~/phpmyadmin
</code></pre>

<p>Move into that directory:</p>

<pre><code>cd ~/phpmyadmin/
</code></pre>

<p>Create a new configuration file:</p>

<pre><code>cp config.default.php config.inc.php
</code></pre>

<p>Change the authentication mode to http</p>

<pre><code>gedit config.inc.php
</code></pre>

<p>Change this line:</p>

<pre><code>$cfg['Servers'][$i]['auth_type'] = 'config';
</code></pre>

<p>&#8230;to this line:</p>

<pre><code>$cfg['Servers'][$i]['auth_type'] = 'http';
</code></pre>

<p>Save the file.</p>

<p>Back in the command line, we need to set the root password, because by default, there isn&#8217;t one! </p>

<pre><code>mysql -u root
</code></pre>

<p>You&#8217;ll then enter the MySQL console. Enter the following:</p>

<pre><code>UPDATE mysql.user SET Password=PASSWORD('newpasswordhere') WHERE User='root';
</code></pre>

<p>This will set the root password. Now flush the privileges:</p>

<pre><code>FLUSH PRIVILEGES;
</code></pre>

<p>Now exit:</p>

<pre><code>exit
</code></pre>

<p>Now, we want phpMyAdmin accessible on the server &#8216;globally&#8217;. So that it doesn&#8217;t matter what address we&#8217;re using, we&#8217;ll still be able to access it.</p>

<p>In Webmin, under Apache Webserver:
1. Select &#8220;Default Server&#8221;
2. Aliases and Redirects
3. Under &#8220;Document directory aliases&#8221; enter <code>/phpmyadmin/</code> into the first text box, and <code>/home/davidwinter/phpmyadmin/</code> into the box to the right of that one.</p>

<p>Save, and in the Terminal restart apache:</p>

<pre><code>sudo /etc/init.d/apache2 restart
</code></pre>

<p>Go to http://yourdomain.com/phpmyadmin/</p>

<p>Login in using &#8220;root&#8221; and the password you set in the MySQL console.</p>

<p>You can do any MySQL configuration here. For me, I restored my Typo database for this blog from a backup.</p>

<h3>FastCGI configuration with a Rails application</h3>

<p>This part is what gets a Rails app running really fast.</p>

<p>You&#8217;ll need to configure the FastCGI config file:</p>

<pre><code>sudo nano /etc/apache2/mods-enabled/fastcgi.conf
</code></pre>

<p>Here is my config file:</p>

<pre><code>&lt;IfModule mod_fastcgi.c&gt;
  #FastCgiWrapper /usr/lib/apache2/suexec2
  FastCgiIpcDir /var/lib/apache2/fastcgi
  FastCgiConfig -maxClassProcesses 2 -maxProcesses 2 -minProcesses 2 -processSlack 2
  FastCgiServer /home/davidwinter/typo/public/dispatch.fcgi -idle-timeout 120 -processes 2 -initial-env RAILS_ENV=production
&lt;/IfModule&gt;
</code></pre>

<p>The following line of the above:</p>

<pre><code>FastCgiServer /home/davidwinter/typo/public/dispatch.fcgi -idle-timeout 120 -processes 2 -initial-env RAILS_ENV=production
</code></pre>

<p>Is important. You need to specifiy a line like this for each Rails app you&#8217;ll be using under FastCGI.</p>

<p>Now, in your Rails application directory check that in <code>public/.htaccess</code> has this line:</p>

<pre><code>AddHandler fastcgi-script .fcgi
</code></pre>

<p>And, that in the rewrite rules section, it has this:</p>

<pre><code>RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
</code></pre>

<p>&#8230;instead of:</p>

<pre><code>RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
</code></pre>

<p>Notice <code>.fcgi</code> instead of <code>.cgi</code></p>

<p>And that&#8217;s about it!</p>

<p>Give Apache one final restart:</p>

<pre><code>sudo /etc/init.d/apache2 restart
</code></pre>

<p>And you should now have everything working.</p>

<p>As I said, any problems, leave a comment and I&#8217;ll try and help.</p>
]]></content:encoded>
			<wfw:commentRss>http://davidwinter.me.uk/articles/2006/08/09/ubuntu-dapper-web-server-how-to/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Set-up Typo 4 on Ubuntu Dapper</title>
		<link>http://davidwinter.me.uk/articles/2006/07/26/set-up-typo-4-on-ubuntu-dapper/</link>
		<comments>http://davidwinter.me.uk/articles/2006/07/26/set-up-typo-4-on-ubuntu-dapper/#comments</comments>
		<pubDate>Wed, 26 Jul 2006 08:40:26 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[howto]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[typo]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://davidwinter.me.uk/articles/2006/07/26/set-up-typo-4-on-ubuntu-dapper/</guid>
		<description><![CDATA[It was very annoying to find out that the brand spanking new installer for Typo wasn&#8217;t going to install over rubygems. The irritating part was that it was SQLite causing the problem because it&#8217;s a dependency of the Typo gem. No idea why. But I don&#8217;t want to SQLite &#8211; I&#8217;m running MySQL on Apache. [...]]]></description>
			<content:encoded><![CDATA[<p>It was very annoying to find out that the brand spanking new installer for Typo wasn&#8217;t going to install over rubygems.  The irritating part was that it was SQLite causing the problem because it&#8217;s a dependency of the Typo gem. No idea why. But I don&#8217;t want to SQLite &#8211; I&#8217;m running MySQL on Apache.</p>

<p><span id="more-4"></span></p>

<p>So anyway, here&#8217;s how I got it working. Thanks to <code>sprewell</code> on the Typo IRC channel.</p>

<ol>
<li><p>Download Typo from Subversion.</p>

<pre><code>svn co svn://typosphere.org/svn/typo/trunk typo
</code></pre></li>
<li><p>Make sure that you&#8217;re inside that directory that was downloaded from Subversion.</p>

<pre><code>bin/typo config ~/typo web-server=external database=mysql
</code></pre></li>
<li><p>Grab the MySQL schema from <code>db/mysql.schema.sql</code> and manually run it on your MySQL database of choice.</p></li>
<li><p>Go into <code>config/</code> and make sure you get the <code>database.yml</code> file set-up to use your database settings.</p></li>
<li><p>Access your Typo install in your browser and you should get a prompt asking you for your admin details.</p></li>
<li><p>Blog away!</p></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://davidwinter.me.uk/articles/2006/07/26/set-up-typo-4-on-ubuntu-dapper/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ubuntu 5.10 web server howto</title>
		<link>http://davidwinter.me.uk/articles/2006/02/05/ubuntu-5-10-web-server-howto/</link>
		<comments>http://davidwinter.me.uk/articles/2006/02/05/ubuntu-5-10-web-server-howto/#comments</comments>
		<pubDate>Sun, 05 Feb 2006 08:58:40 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[apache]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://davidwinter.me.uk/articles/2006/10/13/ubuntu-5-10-web-server-howto/</guid>
		<description><![CDATA[I reinstalled my home server today (well, I actually started yesterday, but today I finished from scratch again) and wrote down what I did. My aim was to have a web server set up using Apache that I could use to host this blog which uses Ruby on Rails. Also, I wanted to set-up Webmin [...]]]></description>
			<content:encoded><![CDATA[<p>I reinstalled my home server today (well, I actually started yesterday, but today I finished from scratch again) and wrote down what I did. My aim was to have a web server set up using Apache that I could use to host this blog which uses Ruby on Rails. Also, I wanted to set-up Webmin and Bind so I could manage the DNS stuff from here.</p>

<p>So, here we go! If you find any errors, or have any problems, leave a comment and I&#8217;ll try and help.</p>

<p><span id="more-13"></span></p>

<h3>The headache begins</h3>

<p>I&#8217;m assuming that you&#8217;ve just completed a new default install of Ubuntu 5.10.</p>

<p>As my space PC/server is up in the loft, and it&#8217;s freezing up there, the first thing I did was to enable XDMCP on Ubuntu so I could connect to it from my Mac downstairs in my nice warm bedroom. You can read how to do that <a href="http://davidwinter.me.uk/articles/2005/12/08/xdmcp-for-mac" title="Setting up XDMCP for Mac">here</a>. </p>

<p>With XDMCP now running, before I can connect to it via my Mac, I set the IP address of the machine to 192.168.0.1 &#8211; a nice number that&#8217;s easy to remember.</p>

<p>Back in my room I&#8217;m connected to Ubuntu via XDMCP and it&#8217;s as if I&#8217;m sitting up in the loft.</p>

<p>If you&#8217;re not using XDMCP (and even if you are you should follow this step), you&#8217;ll want to connect via SSH. Install it using:</p>

<pre><code>sudo apt-get install ssh
</code></pre>

<p>There are some packages that are needed that aren&#8217;t in the default repositories for <code>apt</code>, so you have to enable them manually. Universe and Multiverse are needed.</p>

<p>To enable the Universe servers, I did</p>

<pre><code>sudo nano /etc/apt/sources.list
</code></pre>

<p>Inside that file, uncomment the two lines that look something like this:</p>

<pre><code>deb http://gb.archive.ubuntu.com/ubuntu breezy universe
deb-src http://gb.archive.ubuntu.com/ubuntu breezy universe
</code></pre>

<p>Hit Control O to save and press enter to use the same filename. Then press Control X to close Nano.</p>

<p>I could probably enable the Multiverse stuff in there too, but as I&#8217;ve not tested it like that, I&#8217;ll leave it to exactly how I did it.</p>

<p>Open up the Synaptic Package Manager
1. Settings
2. Repositories
3. Add
4. Check Multiverse
5. Click OK and let it rescan the servers.</p>

<p>You can then close Synaptic. <code>apt</code> is now all set up ready for installing the packages we need.</p>

<p>Before we start installing the packages we want, do a system update:</p>

<pre><code>sudo apt-get update
</code></pre>

<h4>Ruby</h4>

<p>All on one line:</p>

<pre><code>sudo apt-get install irb libdbm-ruby1.8 libfcgi-ruby1.8 libfcgi0 libgdbm-ruby1.8 libmysql-ruby1.8 libmysqlclient12 libopenssl-ruby1.8 libruby1.8-dbg mysql-common ri ri1.8 ruby1.8-dev ruby
</code></pre>

<h4>MySQL Server</h4>

<pre><code>sudo apt-get install mysql-server
</code></pre>

<p>During this install, a Postfix config screen will appear. Select OK and then &#8220;No configuration&#8221;.</p>

<h4>Ruby Gems &amp; Rails</h4>

<p>This is the standard way of installing ruby applications.</p>

<p>Need to download it directly from its web site:</p>

<pre><code>wget http://rubyforge.org/frs/download.php/5207/rubygems-0.8.11.tgz
</code></pre>

<p>Then extract it:</p>

<pre><code>tar xvfz rubygems-0.8.11.tgz
</code></pre>

<p>Move into the extracted directory:</p>

<pre><code>cd rubygems-0.8.11
</code></pre>

<p>Run the setu-p program:</p>

<pre><code>sudo ruby1.8 setup.rb
</code></pre>

<p>Update all installed gems on the system:</p>

<pre><code>sudo gem update --system
</code></pre>

<p>Now that Ruby Gems is installed, we can install Rails.</p>

<pre><code>sudo gem install rails -y
</code></pre>

<h4>Apache 2</h4>

<p>Next is the web server I&#8217;m using. Apache 2. The following command will install Apache 2, FastCGI, FCGI, PHP 5 with MySQL functionality. PHP isn&#8217;t needed for Ruby or Rails, but I&#8217;m including it so that I can run PHP apps&#8230;</p>

<pre><code>sudo apt-get install apache2 libapache2-mod-fcgid libapache2-mod-fastcgi libapache2-mod-php5 php5-mysql
</code></pre>

<p>Once that&#8217;s done, we&#8217;ll need to enable the Apache mods we&#8217;ll be using:</p>

<pre><code>sudo a2enmod fcgid
sudo a2enmod fastcgi
sudo a2enmod rewrite
</code></pre>

<p>You&#8217;ll notice I&#8217;ve installed two different types of Fast CGI. That&#8217;s because at some point I want to try them both out. However, at the moment, I&#8217;ve only had success with getting FastCGI working decently.</p>

<p>Restart Apache to make sure all is well.</p>

<pre><code>sudo /etc/init.d/apache2 restart
</code></pre>

<h4>FastCGI</h4>

<p>I thought FastCGI would have been installed after doing the libapache2-mod-fastcgi &#8211; but for some reason, you have to install it manually.</p>

<p>In order to configure and build from the source files, you need to download some basic files:</p>

<pre><code>sudo apt-get install build-essential
</code></pre>

<p>Then, grab the FastCGI files from the web site:</p>

<pre><code>wget http://fastcgi.com/dist/fcgi-2.4.0.tar.gz
</code></pre>

<p>Extract:</p>

<pre><code>tar xvfz fcgi-2.4.0.tar.gz
</code></pre>

<p>Move into the directory:</p>

<pre><code>cd fcgi-2.4.0
</code></pre>

<p>Configure the installer:</p>

<pre><code>./configure
</code></pre>

<p>Install:</p>

<pre><code>sudo make install
</code></pre>

<p>Now, that is all of the Apache and FastCGI files installed. Later, we&#8217;ll need to configure it all.</p>

<h4>Webmin</h4>

<p>Webmin is ugly, but it works, and it lets us configure Apache and the Nameserver easily.</p>

<p>Go to http://www.webmin.com/ and download the latest version of webmin in tar.gz format.</p>

<p>Once downloaded, extract it (filename may vary depending on the version you download):</p>

<pre><code>tar xvfz webmin-1.260.tar.gz
</code></pre>

<p>Move into the directory:</p>

<pre><code>cd webmin-1.260
</code></pre>

<p>Run the set-up program:</p>

<pre><code>sudo ./setup.sh /usr/local/webmin
</code></pre>

<p>You can use the default settings for this, or change them if you know what you&#8217;re doing. Be sure to set a password you can remember.</p>

<p>At the end of the set-up you&#8217;ll be given an address to use to connect to webmin. Remember this! and go to it straight away and login.</p>

<p>Do the following to configure Webmin to work with Apache:
1. At the top, click on the &#8220;Servers&#8221; link.
2. Select Apache Webserver.
3. Select Module Config.
4. Set the following values:
    * Apache Server Root &#8211; /etc/apache2
    * Path to httpd executable &#8211; /usr/sbin/apache2
    * Path to httpd.conf &#8211; /etc/apache2/httpd.conf
    * Command to start Apache &#8211; /etc/init.d/apache2 start
    * Command to stop Apache &#8211; /etc/init.d/apache2 stop</p>

<p>Save these settings.</p>

<h4>Nameserver</h4>

<p>I&#8217;m no DNS expert, so this is very vague and I suggest you go read a howto on DNS&#8230; <a href="http://rimuhosting.com/support/bindviawebmin.jsp">here&#8217;s one</a> I used to complete this part.</p>

<p>This will be different depending on your set-ups. For me, I have my domain name pointing to my web server in America that hosts http://commanderbond.net </p>

<p>On the server, there, I have the DNS pointing to my Internet IP at home, here in the UK.</p>

<p>The nameserver I&#8217;m using is Bind.</p>

<pre><code>sudo apt-get install bind9
</code></pre>

<p>Once that&#8217;s installed, we need to configure it in Webmin.
1. Click the &#8220;Servers&#8221; link.
2. Select BIND DNS Server.
3. A message will appear about a configuration file. Select the 3rd option &#8220;Setup as an internet name server, but use Webmin&#8217;s older root server information&#8221;
4. Create a Master Zone and enter the following details:
    * Domain Name &#8211; yourdomain.com
    * Email &#8211; you@anemail.com
5. Click on &#8220;Create&#8221;.
6. Click on the &#8220;Address&#8221; link.
7. Create a new Address record using the following:
    * Name &#8211; yourdomain.com. (including the trailing dot)
    * Address &#8211; your Internet IP address
8. Click on &#8220;Create&#8221;.
9. Go to the Module Index.
10. Click on &#8220;Apply Changes&#8221;.</p>

<h4>Set-up your web site</h4>

<p>You&#8217;ll need somewhere to store your web site files, so I suggest to first of all create a <code>public_html</code> directory in your user directory.</p>

<pre><code>mkdir ~/public_html
</code></pre>

<p>Now we&#8217;ll create a test HTML file to check all is working so far.</p>

<pre><code>nano ~/public_html/index.html
</code></pre>

<p>Inside it put the following:</p>

<pre><code>&lt;p&gt;Hopefully you can see this...&lt;/p&gt;
</code></pre>

<p>Save the file using Control O and then Control X to quit Nano.</p>

<p>Now, set the permissions of the file so it&#8217;s visible to the world:</p>

<pre><code>chmod 644 ~/public_html/index.html
</code></pre>

<p>In Webmin, go to the Apache configuration.</p>

<p>Create a new Virtual Server with the following:
* Document Root &#8211; home/yourusername/public_html
* Server Name &#8211; yourdomain.com</p>

<p>Save the settings. Now restart Apache:</p>

<pre><code>sudo /etc/init.d/apache2 restart
</code></pre>

<p>Now visit http://yourdomain.com/~yourusername/ and you should see:</p>

<blockquote>
  <p>Hopefully you can see this&#8230;</p>
</blockquote>

<p>If so, excellent! If not, hmmm&#8230; maybe you didn&#8217;t follow everything? or I made a mistake somewhere&#8230; leave a comment below.</p>

<p>Take a 5 minute break!</p>

<p>Refreshed? Right. Moving on&#8230;</p>

<h4>phpMyAdmin for MySQL management</h4>

<p>Go to http://www.phpmyadmin.net/home_page/index.php and download the latest stable release of phpMyAdmin in tar.gz format.</p>

<p>Extract:</p>

<pre><code>tar xvfz phpMyAdmin-2.7.0-pl2.tar.gz
</code></pre>

<p>Move the directory to some place helpful:</p>

<pre><code>mv phpMyAdmin-2.7.0-pl2 ~/phpmyadmin
</code></pre>

<p>Move into that directory:</p>

<pre><code>cd ~/phpmyadmin/
</code></pre>

<p>Create a new configuration file:</p>

<pre><code>cp config.default.php config.inc.php
</code></pre>

<p>Change the authentication mode to http</p>

<pre><code>gedit config.inc.php
</code></pre>

<p>Change this line:</p>

<pre><code>$cfg['Servers'][$i]['auth_type'] = 'config';
</code></pre>

<p>&#8230;to this line:</p>

<pre><code>$cfg['Servers'][$i]['auth_type'] = 'http';
</code></pre>

<p>Save the file.</p>

<p>Back in the command line, we need to set the root password, because by default, there isn&#8217;t one! </p>

<pre><code>mysql -u root
</code></pre>

<p>You&#8217;ll then enter the MySQL console. Enter the following:</p>

<pre><code>UPDATE mysql.user SET Password=PASSWORD('newpasswordhere') WHERE User='root';
</code></pre>

<p>This will set the root password. Now flush the privileges:</p>

<pre><code>FLUSH PRIVILEGES;
</code></pre>

<p>Now exit:</p>

<pre><code>exit
</code></pre>

<p>Now, we want phpMyAdmin accessible on the server &#8216;globally&#8217;. So that it doesn&#8217;t matter what address we&#8217;re using, we&#8217;ll still be able to access it.</p>

<p>In Webmin, under Apache Webserver:
1. Select &#8220;Default Server&#8221;
2. Aliases and Redirects
3. Under &#8220;Document directory aliases&#8221; enter <code>/phpmyadmin/</code> into the first text box, and <code>/home/davidwinter/phpmyadmin/</code> into the box to the right of that one.</p>

<p>Save, and in the Terminal restart apache:</p>

<pre><code>sudo /etc/init.d/apache2 restart
</code></pre>

<p>Go to http://yourdomain.com/phpmyadmin/</p>

<p>Login in using &#8220;root&#8221; and the password you set in the MySQL console.</p>

<p>You can do any MySQL configuration here. For me, I restored my Typo database for this blog from a backup.</p>

<h4>FastCGI configuration with a Rails application</h4>

<p>This part is what gets a Rails app running really fast.</p>

<p>You&#8217;ll need to configure the FastCGI config file:</p>

<pre><code>sudo nano /etc/apache2/mods-enabled/fastcgi.conf
</code></pre>

<p>Here is my config file:</p>

<pre><code>&lt;IfModule mod_fastcgi.c&gt;
  #FastCgiWrapper /usr/lib/apache2/suexec2
  FastCgiIpcDir /var/lib/apache2/fastcgi
  FastCgiConfig -maxClassProcesses 2 -maxProcesses 2 -minProcesses 2 -processSlack 2
  FastCgiServer /home/davidwinter/typo/public/dispatch.fcgi -idle-timeout 120 -processes 2 -initial-env RAILS_ENV=production
&lt;/IfModule&gt;
</code></pre>

<p>The following line of the above:</p>

<pre><code>FastCgiServer /home/davidwinter/typo/public/dispatch.fcgi -idle-timeout 120 -processes 2 -initial-env RAILS_ENV=production
</code></pre>

<p>Is important. You need to specifiy a line like this for each Rails app you&#8217;ll be using under FastCGI.</p>

<p>Now, in your Rails application directory check that in <code>public/.htaccess</code> has this line:</p>

<pre><code>AddHandler fastcgi-script .fcgi
</code></pre>

<p>And, that in the rewrite rules section, it has this:</p>

<pre><code>RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
</code></pre>

<p>&#8230;instead of:</p>

<pre><code>RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
</code></pre>

<p>Notice <code>.fcgi</code> instead of <code>.cgi</code></p>

<p>And that&#8217;s about it!</p>

<p>Give Apache one final restart:</p>

<pre><code>sudo /etc/init.d/apache2 restart
</code></pre>

<p>And you should now have everything working.</p>

<p>As I said, any problems, leave a comment and I&#8217;ll try and help.</p>
]]></content:encoded>
			<wfw:commentRss>http://davidwinter.me.uk/articles/2006/02/05/ubuntu-5-10-web-server-howto/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Upgraded to Typo trunk</title>
		<link>http://davidwinter.me.uk/articles/2005/12/26/upgraded-to-typo-trunk/</link>
		<comments>http://davidwinter.me.uk/articles/2005/12/26/upgraded-to-typo-trunk/#comments</comments>
		<pubDate>Mon, 26 Dec 2005 08:57:48 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[typo]]></category>

		<guid isPermaLink="false">http://davidwinter.me.uk/articles/2006/10/13/upgraded-to-typo-trunk/</guid>
		<description><![CDATA[I just upgraded to the latest trunk version of Typo; 762 and was glad to see an Audioscrobbler addition to the sidebar &#8211; so you can now see all the latest tracks I&#8217;ve played recently. Mainly this week that has been &#8216;The Polar Express&#8217; soundtrack by Alan Silvestri (composer of the Forest Gump soundtrack). Also, [...]]]></description>
			<content:encoded><![CDATA[<p>I just upgraded to the latest trunk version of Typo; 762 and was glad to see an Audioscrobbler addition to the sidebar &#8211; so you can now see all the latest tracks I&#8217;ve played recently. Mainly this week that has been &#8216;The Polar Express&#8217; soundtrack by Alan Silvestri (composer of the Forest Gump soundtrack).</p>

<p>Also, Typo should now been pinging blog-sites so they all know I&#8217;ve updated, which is nice and handy.</p>

<p>The next new addition that I&#8217;ll have to try out by updating some of my old posts, is syntax colouring :)</p>

<p><span id="more-12"></span></p>

<h3>Update</h3>

<p>I appear to be getting errors when either creating or editing posts :( However, the edit, or new post seems to be executed and not lost&#8230;</p>

<p>I get the following:</p>

<blockquote>
  <p>Application error (Rails)</p>
</blockquote>

<p>The error message doesn&#8217;t help much. But I think that&#8217;s probably down to my Typo instance being in the Production environment of Rails. If I go back into Development, then I should get more details I hope&#8230; Anyway, I&#8217;m too tired tonight so I&#8217;ll try and fix it tomorrow.</p>

<hr />

<p>Ok, so morning has now come and I&#8217;m now in the Development environment and I get a hell of a ton more information now. It&#8217;s to do with a MySQL error in <code>/app/views/admin/content/show.rhtml</code>. So right now I&#8217;m in the IRC channel trying to find an answer.</p>

<hr />

<p>Appears as though the <code>article_id</code> field was missing from the <code>resources</code> table. I added it in manually and everything is working now.</p>
]]></content:encoded>
			<wfw:commentRss>http://davidwinter.me.uk/articles/2005/12/26/upgraded-to-typo-trunk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
