<?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>Ruby, Rails, OSX and Linux fun &#187; admin</title>
	<atom:link href="http://www.frederico-araujo.com/author/admin/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.frederico-araujo.com</link>
	<description>Howto&#039;s, Tutorials and personal experience</description>
	<lastBuildDate>Tue, 27 Dec 2011 10:46:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Why EC2 still sux on disk IO</title>
		<link>http://www.frederico-araujo.com/2011/12/27/why-ec2-still-sux-on-disk-io/</link>
		<comments>http://www.frederico-araujo.com/2011/12/27/why-ec2-still-sux-on-disk-io/#comments</comments>
		<pubDate>Tue, 27 Dec 2011 10:46:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[vps]]></category>

		<guid isPermaLink="false">http://www.frederico-araujo.com/?p=283</guid>
		<description><![CDATA[I won't say anything, just see the numbers:

all tests run 3-4 times:

Small EC2 EBS added 16GB volume $50-80/month
# dd bs=1M count=256 if=/dev/zero of=test oflag=dsync
256+0 records in
256+0 records out
268435456 bytes (268 MB) copied, 11.5874 s, 23.2 MB/s

Small EC2 Root FS EBS 
# dd bs=1M count=256 if=/dev/zero of=test oflag=dsync
256+0 records in
256+0 records out
268435456 bytes (268 MB) ...]]></description>
			<content:encoded><![CDATA[<p>I won&#8217;t say anything, just see the numbers:</p>
<p>all tests run 3-4 times:</p>
<p>Small EC2 EBS added 16GB volume $50-80/month<br />
# dd bs=1M count=256 if=/dev/zero of=test oflag=dsync<br />
256+0 records in<br />
256+0 records out<br />
268435456 bytes (268 MB) copied, 11.5874 s, 23.2 MB/s</p>
<p>Small EC2 Root FS EBS<br />
# dd bs=1M count=256 if=/dev/zero of=test oflag=dsync<br />
256+0 records in<br />
256+0 records out<br />
268435456 bytes (268 MB) copied, 32.8698 s, 8.2 MB/s</p>
<p>Linode 1.5GB $54-60/month<br />
# dd bs=1M count=256 if=/dev/zero of=test oflag=dsync<br />
256+0 records in<br />
256+0 records out<br />
268435456 bytes (268 MB) copied, 2.25564 s, 119 MB/s</p>
<p>Tilaa.nl 1GB $30/month<br />
# dd bs=1M count=256 if=/dev/zero of=swapfile oflag=dsync<br />
256+0 records in<br />
256+0 records out<br />
268435456 bytes (268 MB) copied, 4.66885 s, 57.5 MB/s</p>
<p><a href="http://romanrm.ru/en/dd-benchmark" title="dd benchmark information" target="_blank">see dd benchmark information</a><br />
<div id="attachment_286" class="wp-caption alignleft" style="width: 810px"><a href="http://www.frederico-araujo.com/wp-content/uploads/2011/12/chartgo-1.png"><img src="http://www.frederico-araujo.com/wp-content/uploads/2011/12/chartgo-1.png" alt="Ec2 vs Linode vs Tilaa" title="Ec2 vs Linode vs Tilaa" width="800" height="400" class="size-full wp-image-286" /></a><p class="wp-caption-text">Ec2 vs Linode vs Tilaa</p></div></p>
<p class="wp-flattr-button"></p> <p><a href="http://www.frederico-araujo.com/?flattrss_redirect&amp;id=283&amp;md5=fd84b882ae6d23dcbe3097a90488d407" title="Flattr" target="_blank"><img src="http://www.frederico-araujo.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.frederico-araujo.com/2011/12/27/why-ec2-still-sux-on-disk-io/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>download rails 3.1.1 rdoc api</title>
		<link>http://www.frederico-araujo.com/2011/11/15/download-rails-3-1-1-rdoc-api/</link>
		<comments>http://www.frederico-araujo.com/2011/11/15/download-rails-3-1-1-rdoc-api/#comments</comments>
		<pubDate>Tue, 15 Nov 2011 08:11:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.frederico-araujo.com/?p=276</guid>
		<description><![CDATA[If you need to use the Rails API offline, you can download it here: 

rails311.tar.bz2 1.4M Nov 15 08:04

The package contants multiple gems rdoc: railties-3.1.1 rails-3.1.1 actionmailer-3.1.1  activemodel-3.1.1  activeresource-3.1.1 actionpack-3.1.1  activerecord-3.1.1 activesupport-3.1.1 sass-3.1.10 coffee-rails-3.1.1 coffee-script-2.2.0

You can browse online if you wish so : /rails311/index.html


Generated by sdoc 
]]></description>
			<content:encoded><![CDATA[<p>If you need to use the Rails API offline, you can download it here: </p>
<p><strong><a href="http://www.frederico-araujo.com/wp-content/rails311.tar.bz2" title="rails api rdoc">rails311.tar.bz2</a> 1.4M Nov 15 08:04</strong></p>
<p>The package contants multiple gems rdoc: railties-3.1.1 rails-3.1.1 actionmailer-3.1.1  activemodel-3.1.1  activeresource-3.1.1 actionpack-3.1.1  activerecord-3.1.1 activesupport-3.1.1 sass-3.1.10 coffee-rails-3.1.1 coffee-script-2.2.0</p>
<p>You can browse online if you wish so : <a href="http://www.frederico-araujo.com/wp-content/rails311/index.html" title="rails 3.1.1 rdoc api" target="_blank">/rails311/index.html</a></p>
<p><em>Generated by <a href="https://github.com/voloko/sdoc" target="_blank">sdoc</a> </em></p>
<p class="wp-flattr-button"></p> <p><a href="http://www.frederico-araujo.com/?flattrss_redirect&amp;id=276&amp;md5=fc9c17381ed52affed47409d6dad76e9" title="Flattr" target="_blank"><img src="http://www.frederico-araujo.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.frederico-araujo.com/2011/11/15/download-rails-3-1-1-rdoc-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>google places and address autocomplete demo</title>
		<link>http://www.frederico-araujo.com/2011/10/12/google-places-and-address-autocomplete-demo/</link>
		<comments>http://www.frederico-araujo.com/2011/10/12/google-places-and-address-autocomplete-demo/#comments</comments>
		<pubDate>Tue, 11 Oct 2011 19:32:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[maps]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.frederico-araujo.com/?p=268</guid>
		<description><![CDATA[This is a ruby on Rails demo app using Address autocomplete with google places API. 

I was experimenting with google places and I found it to be quite awesome. 

In this app you can search for a geocode address or establishments, move the marker and get the the GPS coordinates, and also get the ...]]></description>
			<content:encoded><![CDATA[<p>This is a ruby on Rails demo app using Address autocomplete with google places API. </p>
<p>I was experimenting with google places and I found it to be quite awesome. </p>
<p>In this app you can search for a geocode address or establishments, move the marker and get the the GPS coordinates, and also get the gps coordinates out the search results. </p>
<p>it&#8217;s also possible to restrain the autocomplete results by limiting it to bounds: </p>
<p>  autocomplete.setBounds(defaultBounds);</p>
<p>here is the demo app: <a href="http://electric-sunrise-8410.heroku.com/" title="demo app" target="_blank">http://electric-sunrise-8410.heroku.com/</a><br />
source: <a href="https://github.com/fred/google_places_autocomplete" title="github source" target="_blank">https://github.com/fred/google_places_autocomplete</a></p>
<p class="wp-flattr-button"></p> <p><a href="http://www.frederico-araujo.com/?flattrss_redirect&amp;id=268&amp;md5=4881ef839611943f4316eeb5fca094bf" title="Flattr" target="_blank"><img src="http://www.frederico-araujo.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.frederico-araujo.com/2011/10/12/google-places-and-address-autocomplete-demo/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Installing MWForum on debian lenny and squeeze</title>
		<link>http://www.frederico-araujo.com/2011/08/23/installing-mwforum-on-debian-lenny-and-squeeze/</link>
		<comments>http://www.frederico-araujo.com/2011/08/23/installing-mwforum-on-debian-lenny-and-squeeze/#comments</comments>
		<pubDate>Tue, 23 Aug 2011 04:25:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.frederico-araujo.com/?p=240</guid>
		<description><![CDATA[Installing mwforum on Debian Lenny 5.0 and 6.0 

There are many perl packages required by MWForum, Im not totally sure if all of them are required, but here is the list of packages that will get MWForum fully working with Image Uploading, Image resizing, attaching image, Avatar, text quote and email support. 

Install required ...]]></description>
			<content:encoded><![CDATA[<p>Installing mwforum on Debian Lenny 5.0 and 6.0 </p>
<p>There are many perl packages required by MWForum, Im not totally sure if all of them are required, but here is the list of packages that will get MWForum fully working with Image Uploading, Image resizing, attaching image, Avatar, text quote and email support. </p>
<p><strong>Install required debian packages with aptitude:</strong></p>
<pre>
# aptitude install libgd-gd2-perl libgd2-xpm imagemagick libimage-base-bundle-perl libimage-magick-perl libimage-info-perl libimage-exif-perl libimage-base-perl libimage-imlib2-perl libimage-size-perl libgeo-ip-perl libgeo-ipfree-perl libemail-mime-perl libmail-sendmail-perl libmail-rfc822-address-perl libmail-sender-perl libmail-perl libnet-cidr-lite-perl libtext-reform-perl libtext-quoted-perl mysql-server libdbd-mysql-perl libdbi-perl libcompress-zlib-perl libwww-perl liburi-perl libxml-perl libxml-regexp-perl libxml-sax-expat-perl libxml-sax-perl libxml-xslt-perl perl-modules perlmagick libtext-iconv-perl libsocket6-perl  libtimedate-perl libnet-daemon-perl libmailtools-perl libhtml-clean-perl libhtml-format-perl libhtml-parser-perl libhtml-tree-perl libcflow-perl libdata-flow-perl apache2-mpm-prefork libapache2-mod-perl2 libapache2-mod-apreq2 libapreq2 libapache2-request-perl -V
</pre>
<p>Now check latest version for download from http://www.mwforum.org/forum/topic_show.pl?tid=4222<br />
In this setup I will put mwforum in /var/www/mwforum/htdocs/ (gentoo style folder) </p>
<p><strong>Download MWforum and extract</strong></p>
<pre>
# mkdir -p /var/www/mwforum/
# cd /var/www/mwforum/
# wget http://www.mwforum.org/dl/stable/mwforum-2.24.1.tar.gz
# tar xpf mwforum-2.24.1.tar.gz
# mkdir htdocs
# cp -a mwforum-2.24.1/script/* htdocs/
# cp -a mwforum-2.24.1/data/* htdocs/
</pre>
<p><strong> Setup Configuration files</strong></p>
<pre>
# cd ./htdocs
# mv MwfConfigGlobalDefault.pm MwfConfigGlobal.pm
# mv MwfConfigDefault.pm MwfConfig.pm
</pre>
<p>Edit config file with your mysql username/password, site name and url.</p>
<pre>
# vi MwfConfig.pm
</pre>
<p><strong>Inside Mysql shell create database and username/password for mwforum:</strong></p>
<pre>
mysql> CREATE DATABASE mwforum CHARSET=utf8;
Query OK, 1 row affected (0.30 sec)

mysql> GRANT ALL ON mwforum.* TO mwforum@localhost IDENTIFIED BY 'sk8hg4I2mxW';
Query OK, 0 rows affected (0.60 sec)

mysql> flush privileges;
</pre>
<p><strong>Install MWForum database:</strong></p>
<pre>
# perl install.pl
</pre>
<p><strong>Activate Apache modules: </strong></p>
<pre>
# a2enmod perl
# a2enmod apreq
# a2enmod headers
</pre>
<p><strong>Add the apache Virtualhost config file:</strong></p>
<pre>
# vi /etc/apache2/sites-availables/mwforum
</pre>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="apache" style="font-family:monospace;">&lt;<span style="color: #000000; font-weight:bold;">VirtualHost</span> *:<span style="color: #ff0000;">80</span>&gt;
    <span style="color: #00007f;">ServerName</span> myforum.com
    <span style="color: #00007f;">ServerAlias</span> www.myforum.com
    <span style="color: #00007f;">ServerAdmin</span> webmaster@myforum.com
    <span style="color: #00007f;">DocumentRoot</span> /var/www/mwforum/htdocs
    <span style="color: #00007f;">DirectoryIndex</span> forum_show.pl
    <span style="color: #adadad; font-style: italic;">#XSendFile on</span>
    <span style="color: #adadad; font-style: italic;">#XSendFileAllowAbove on</span>
    <span style="color: #00007f;">ScriptAlias</span> /cgi-bin/ <span style="color: #7f007f;">&quot;/var/www/mwforum/htdocs/&quot;</span>
    &lt;<span style="color: #000000; font-weight:bold;">Directory</span> <span style="color: #7f007f;">&quot;/var/www/mwforum/htdocs&quot;</span>&gt;
        <span style="color: #00007f;">Options</span> +ExecCGI <span style="color: #0000ff;">FollowSymLinks</span> -<span style="color: #0000ff;">Indexes</span>
        <span style="color: #00007f;">AllowOverride</span> <span style="color: #0000ff;">All</span>
        <span style="color: #00007f;">Order</span> <span style="color: #00007f;">allow</span>,<span style="color: #00007f;">deny</span>
        <span style="color: #00007f;">Allow</span> from <span style="color: #0000ff;">all</span>
    &lt;/<span style="color: #000000; font-weight:bold;">Directory</span>&gt;
    <span style="color: #00007f;">RewriteEngine</span> <span style="color: #0000ff;">On</span>
    <span style="color: #adadad; font-style: italic;"># Uncomment to force redirect to https, but you need to create https vhost</span>
    <span style="color: #adadad; font-style: italic;"># RewriteCond %{HTTPS} off</span>
    <span style="color: #adadad; font-style: italic;"># RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}</span>
&lt;/<span style="color: #000000; font-weight:bold;">VirtualHost</span>&gt;</pre></td></tr></table></div>

<p><strong>Add PerlSwitches:</strong></p>
<pre>
# vi /etc/apache2/conf.d/mwforum
</pre>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="apache" style="font-family:monospace;">PerlSwitches -I/var/www/mwforum/htdocs
&lt;<span style="color: #000000; font-weight:bold;">Directory</span> /var/www/mwforum/htdocs/&gt;
    <span style="color: #00007f;">DirectoryIndex</span> forum.pl
    <span style="color: #00007f;">Options</span> -<span style="color: #0000ff;">Indexes</span>
    &lt;<span style="color: #000000; font-weight:bold;">Files</span> <span style="color: #7f007f;">&quot;*.pl&quot;</span>&gt;
        <span style="color: #00007f;">Options</span> +ExecCGI
        <span style="color: #00007f;">SetHandler</span> perl-<span style="color: #00007f;">script</span>
        PerlResponseHandler ModPerl::Registry
        PerlOptions -SetupEnv -ParseHeaders
    &lt;/<span style="color: #000000; font-weight:bold;">Files</span>&gt;
    &lt;<span style="color: #000000; font-weight:bold;">Files</span> <span style="color: #7f007f;">&quot;*.pm&quot;</span>&gt;
        <span style="color: #00007f;">Deny</span> from <span style="color: #0000ff;">all</span>
    &lt;/<span style="color: #000000; font-weight:bold;">Files</span>&gt;
&lt;/<span style="color: #000000; font-weight:bold;">Directory</span>&gt;</pre></td></tr></table></div>

<p>Now activate mwforum and check for configurations</p>
<pre>
# a2ensite mwforum
# apache2ctl configtest
Syntax OK
</pre>
<p>If syntax OK, then restart</p>
<pre>
# /etc/init.d/apache2 restart
</pre>
<p><strong>Security and Cleanup:</strong></p>
<pre>
# rm install.pl upgrade.pl
# cat ./mwforum-2.24.1/example/script.htaccess >> htdocs/.htacess
# cat ./mwforum-2.24.1/example/attach.htaccess >> htdocs/.htacess
</pre>
<p class="wp-flattr-button"></p> <p><a href="http://www.frederico-araujo.com/?flattrss_redirect&amp;id=240&amp;md5=229615f1a14529ac7189198bab3905f2" title="Flattr" target="_blank"><img src="http://www.frederico-araujo.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.frederico-araujo.com/2011/08/23/installing-mwforum-on-debian-lenny-and-squeeze/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Rails on OS X Lion with HomeBrew, RVM and Mysql</title>
		<link>http://www.frederico-araujo.com/2011/07/30/installing-rails-on-os-x-lion-with-homebrew-rvm-and-mysql/</link>
		<comments>http://www.frederico-araujo.com/2011/07/30/installing-rails-on-os-x-lion-with-homebrew-rvm-and-mysql/#comments</comments>
		<pubDate>Fri, 29 Jul 2011 19:06:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.frederico-araujo.com/?p=229</guid>
		<description><![CDATA[Bye Bye Macports, Welcome Homebrew

Definition
Homebrew: The missing package manager for OS X

Why? well, the reality is, macports is not that good anymore. 
Once you have many packages installed and start updating, everything start to break apart, lot's of failing packages.

Homebrew is very easy to install, it's fast and simple. That means you can make ...]]></description>
			<content:encoded><![CDATA[<h3>Bye Bye Macports, Welcome Homebrew</h3>
<p><strong>Definition</strong><br />
<em><strong>Homebrew: The missing package manager for OS X</strong></em></p>
<p>Why? well, the reality is, macports is not that good anymore.<br />
Once you have many packages installed and start updating, everything start to break apart, lot&#8217;s of failing packages.</p>
<p>Homebrew is very easy to install, it&#8217;s fast and simple. That means you can make your own homebrew formula for your package so easily. oh, and homebrew is in ruby! :)</p>
<p>Back to topic, this is you how you get rails with mysql up and running with homebrew and rvm.</p>
<p><strong>Clean up</strong></p>
<p>To make sure to have a clean install, I recommend removing any previous .rvm installation and previous Xcode.</p>
<pre>
# rm -rf ~/.rvm/
# sudo rm -rf /Developer
</pre>
<p><strong>1. Xcode</strong></p>
<p>Install Xcode from AppStore. it&#8217;s 3 GB download so it may take a while.<br />
after it&#8217;s downloaded it will not install automatically, you need to open Applications and install again from there. the name will be &#8220;Install Xcode&#8221;</p>
<p><strong>Update:</strong> If you don&#8217;t want to download and install huge XCODE (3.0GB) :<br />
<a href="https://github.com/kennethreitz/osx-gcc-installer">https://github.com/kennethreitz/osx-gcc-installer</a><br />
It allows you to install the essential compilers, GCC, LLVM, etc.<br />
PS: I have not tested it<br />
Thanks <a href="http://vidarara.com/">JP</a> for the tip.</p>
<p><strong>2. Install HomeBrew</strong></p>
<p>UPDATE: in the comments some people recommended to do create the folder &#8220;/usr/local/Cellar&#8221; before hand, due to some bug on homebrew. </p>
<pre>
mkdir -p /usr/local/Cellar
</pre>
<pre>
#  /usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"
</pre>
<p>Installation instructions: https://github.com/mxcl/homebrew/wiki/installation</p>
<p><strong>3. install RVM</strong></p>
<pre>
#  bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
</pre>
<p>then after RVM is installed run this 'one-line' command.</p>
<pre>
# echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] &#038;&#038; . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
</pre>
<p>Details instructions: http://beginrescueend.com/rvm/install/</p>
<p><strong>4. Install ruby 1.9.2 </strong></p>
<p>OS X Lion comes with Ruby-1.8.7-p249, but we all want ruby 1.9.2 right? </p>
<pre>
# rvm install 1.9.2
# rvm use ruby-1.9.2
# gem install rails thin bundler
....
</pre>
<p>I tested both ruby-1.9.2-head and ruby-1.9.3, latest sources from git, and it works well with all my apps.<br />
With Ruby-1.9.3-head, <a href="http://www.rubyinside.com/ruby-1-9-3-faster-loading-times-require-4927.html">Rails booted a lot faster</a>.<br />
If you wish to try 1.9.3:</p>
<pre>
# rvm install 1.9.3-head
</pre>
<p><strong>Optionally</strong> you might want to install GIT, wget,<br />
<a href="http://betterthangrep.com/" title="akc">ack</a>, imagemagick<br />
and other mighty software tools for daily use.</p>
<pre>
# brew install git ack wget curl redis memcached libmemcached colordiff imagemagick
</pre>
<p></p>
<p><strong>5. Install Mysql </strong></p>
<pre>
# brew install mysql
</pre>
<p>one-line command:</p>
<pre>
# mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
</pre>
<p>Once mysql is installed you might want it to load automatically each time you start your mac.</p>
<pre>
# mkdir -p ~/Library/LaunchAgents
# cp /usr/local/Cellar/mysql/5.5.14/com.mysql.mysqld.plist ~/Library/LaunchAgents/
# launchctl load -w ~/Library/LaunchAgents/com.mysql.mysqld.plist
</pre>
<p>*check that the version I use here is 5.5.14</p>
<p><strong>6. Troubleshooting:</strong></p>
<p>if you have problems with mysql "cannot connect to /tmp/mysql.sock"<br />
then create a file /usr/local/etc/my.cnf and add this:</p>
<pre>
[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
bind-address = 127.0.0.1
port = 3306
socket = /tmp/mysql.sock
</pre>
<p>if encounter errors with homebrew run this command and follow recommendations:</p>
<pre>
# brew doctor
</pre>
<p>update: If you end up with Segmentation fault or cannot install Ruby-1.8.7, you might want to try <a href="http://stackoverflow.com/questions/6170813/why-cant-i-install-rails-on-lion-using-rvm">this solution</a>:</p>
<pre>
# export CC=/usr/bin/gcc-4.2
# rvm install ruby-1.8.7
</pre>
<p>by the way this is my /usr/local/etc/my.cnf optimized file, when using this file you may have to recreate your db </p>
<pre>
# mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
</pre>
<pre>
[client]
port = 3306
socket = /tmp/mysql.sock 

[mysqld]
event_scheduler = ON
skip-character-set-client-handshake
collation_server = utf8_unicode_ci
character_set_server = utf8 

bind-address = 127.0.0.1
port = 3306
socket = /tmp/mysql.sock
max_connections = 20

table_open_cache = 256
max_allowed_packet = 32M
binlog_cache_size = 1M
max_heap_table_size = 64M 

read_buffer_size = 2M
read_rnd_buffer_size = 4M
sort_buffer_size = 8M
join_buffer_size = 512k

thread_cache_size = 2
thread_concurrency = 2
query_cache_size = 16M
query_cache_limit = 2M 

default-storage-engine = INNODB
thread_stack = 192K
transaction_isolation = REPEATABLE-READ
tmp_table_size = 64M 

# MyISAM Options 

key_buffer_size = 64M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 1G
myisam_repair_threads = 1
myisam_recover 

# INNODB Options
innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 128M
innodb_thread_concurrency = 2
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 4M
innodb_log_file_size = 8M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_flush_method = O_DIRECT
innodb_lock_wait_timeout = 120
innodb_file_per_table 

[mysqldump]
quick
max_allowed_packet = 16M 

[mysql]
no-auto-rehash 

[myisamchk]
key_buffer_size = 128M
sort_buffer_size = 128M
read_buffer = 16M
write_buffer = 16M

[mysqlhotcopy]
interactive-timeout 
</pre>
<p class="wp-flattr-button"></p> <p><a href="http://www.frederico-araujo.com/?flattrss_redirect&amp;id=229&amp;md5=af6bb486c689d840a4808dc02bd532c1" title="Flattr" target="_blank"><img src="http://www.frederico-araujo.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.frederico-araujo.com/2011/07/30/installing-rails-on-os-x-lion-with-homebrew-rvm-and-mysql/feed/</wfw:commentRss>
		<slash:comments>52</slash:comments>
		</item>
		<item>
		<title>OpenSSH Server Security tips</title>
		<link>http://www.frederico-araujo.com/2011/07/30/openssh-server-security-tips/</link>
		<comments>http://www.frederico-araujo.com/2011/07/30/openssh-server-security-tips/#comments</comments>
		<pubDate>Fri, 29 Jul 2011 18:29:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.frederico-araujo.com/?p=222</guid>
		<description><![CDATA[Small tips for securing a server with from SSH login

1. Disable Password Login

edit /etc/ssh/sshd_config and set the following

PasswordAuthentication no

now you can only login via ssh keys. 
generate your local keys using ssh-keygen -t rsa
then put your id_rsa.pub in the user account on the server 
i.e. /root/.ssh/authorized_keys


2. Random Passwords

Set all user passwords to large pseudo-random ...]]></description>
			<content:encoded><![CDATA[<p>Small tips for securing a server with from SSH login</p>
<p><strong>1. Disable Password Login</strong></p>
<p>edit /etc/ssh/sshd_config and set the following</p>
<p>PasswordAuthentication no</p>
<p>now you can only login via ssh keys.<br />
generate your local keys using ssh-keygen -t rsa<br />
then put your id_rsa.pub in the user account on the server<br />
i.e. /root/.ssh/authorized_keys</p>
<p><strong>2. Random Passwords</strong></p>
<p>Set all user passwords to large pseudo-random strings.<br />
i.e. I set all users on all servers with different passwords looking like this:<br />
Z4Q7H6pI53Xtsbgs8qKC<br />
20 random alpha-numeric characters (a-z, A-Z, 0-9)</p>
<p>see here for more passwords https://www.grc.com/passwords.htm<br />
you can test the password with the brute force search space calculator with https://www.grc.com/haystack.htm</p>
<p><strong>3. Login alerts by email</strong></p>
<p>Everytime a user has logged in the system, you should get an email alert.<br />
For that I do put login_alert.sh and appended it to the end of /etc/profile</p>
<p>At the end of the file /etc/profile add this line:</p>
<pre>
sh /etc/login_alert.sh
</pre>
<p>then create a file /etc/login_alert.sh</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code"><pre class="shell" style="font-family:monospace;">#!/bin/sh
SERVER_NAME=`hostname -f`
SEND_TO=&quot;myemail@gmail.com&quot;
LOGIN_WHO=`who -m | cut -d&quot;(&quot; -f2 | cut -d&quot;)&quot; -f1 | tr -d \r`
&nbsp;
echo &quot;
Shell Login Access to ${SERVER_NAME}
From: ${LOGIN_WHO}
Date: `date`
&nbsp;
Active Users:
 `who`
&nbsp;
Uptime: 
 `uptime`
&nbsp;
&quot; | mail -s &quot;Alert: SSH Login to ${SERVER_NAME} from ${LOGIN_WHO}&quot; $SEND_TO</pre></td></tr></table></div>

<p>so you will get an email like this every time someone login to the server.</p>
<pre>
Subject: Alert: Shell Login to 'hostname' from ppp-122-122-122-122.evip2.xxxxxx.xx.xx

Shell Login Access to mail9.hostname.net
From: ppp-122-122-122-122.evip2.xxxxxx.xx.xx
Date: Fri Jul 29 18:23:19 UTC 2011

Active Users:
 root     pts/0        2011-07-29 17:57 (ppp-122-122-122-122.evip2.xxxxxx.xx.xx)

Uptime:
  18:23:19 up 189 days,  2:38,  1 user,  load average: 0.05, 0.08, 0.07
</pre>
<p>4. System Updates</p>
<p>Always keep updated. I run &#8220;aptitude full-upgrade&#8221; everyday on all debian machines.<br />
also goes for Mac and Windows.</p>
<p class="wp-flattr-button"></p> <p><a href="http://www.frederico-araujo.com/?flattrss_redirect&amp;id=222&amp;md5=08835073458e29f2ed83cb0a2852faf4" title="Flattr" target="_blank"><img src="http://www.frederico-araujo.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.frederico-araujo.com/2011/07/30/openssh-server-security-tips/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Strongly typed Languages and Security</title>
		<link>http://www.frederico-araujo.com/2011/01/25/strongly-typed-language-and-security/</link>
		<comments>http://www.frederico-araujo.com/2011/01/25/strongly-typed-language-and-security/#comments</comments>
		<pubDate>Tue, 25 Jan 2011 15:02:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.frederico-araujo.com/?p=215</guid>
		<description><![CDATA[Strongly typed Languages and Security. From Schneier on Security. 
A Great comment I believe it's worth sharing. Source http://www.schneier.com/blog/archives/2010/10/firesheep.html#c478900


I can't agree more that the average quality of programmers (and therefore reusable components) is miserable. Code reuse can be very messy and anyone serious about quality is forced to reinvent the wheel over and over.

Of ...]]></description>
			<content:encoded><![CDATA[<p>Strongly typed Languages and Security. From Schneier on Security.<br />
A Great comment I believe it&#8217;s worth sharing. Source <a href="http://www.schneier.com/blog/archives/2010/10/firesheep.html#c478900">http://www.schneier.com/blog/archives/2010/10/firesheep.html#c478900</a></p>
<p><quote><br />
I can&#8217;t agree more that the average quality of programmers (and therefore reusable components) is miserable. Code reuse can be very messy and anyone serious about quality is forced to reinvent the wheel over and over.</p>
<p>Of course I also agree that not all standards are good, as I don&#8217;t consider the web&#8217;s standards good.</p>
<p>However, there are fake high level languages and real high level languages. You cannot really build a complex system in a low level language, and even if you did, it would be full of abstractions, effectively making it a high level language via design patterns.</p>
<p>Look at PHP, it&#8217;s a horrible mess, a big ball of crap thrown together to make a &#8220;framework&#8221; to &#8220;ease&#8221; web development. The developers don&#8217;t have a clue what they&#8217;re doing and there are lots of new vulns in it every month at both the high and low levels. The builtin functions are completely inconsistent, some things return magic values and some things raise exceptions. PHP just takes random features from other languages and piles them together in an incoherent way. PHP is weakly typed (which is _always_ useless and causes more bugs). PHP is configurable, different libraries depend on different configurations of it. PHP has a garbage optional security model thing called safe-mode, which doesn&#8217;t work as it&#8217;s just more crap incoherently thrown together.</p>
<p>Now look at a real high level language, like Haskell, everything is immutable, which immediately mitigates one of the big class of bugs. Lazy evaluation means everything is more efficient most of the time (most problems are best solved lazily), but can be turned off when needed. The type system tells you all the information you&#8217;d ever want to know about the architecture of a given program, as well as catches _lots_ of bugs up front. Functions can easily be reasoned about due to type safety and immutability. This is a language that was actually thought out, unlike PHP.</p>
<p>Also, there are capability-secure languages/OSs, such as E (language), where security is orthogonal and forces the principle of least authority upon the entire architecture from the ground up. They have already been proven easy to use (obviously, much easier to use than any *nix crap because they have strong typing and aren&#8217;t C) and exponentially more secure. E is basically reifies one of the things computing is meant to have but doesn&#8217;t currently: you can run any code without caring if it&#8217;s evil or crappy. Sort of like the web but not completely flawed/unusable/insecure. The capability model also stop programs from dumping random garbage all over your OS, which is what happens on *nix and Windows.</p>
<p>Did I mention POLA is important? Why one would ever want to run random code off the internet with full privileges is beyond me. Java has an actual _half_ decent security/object model BTW, but it was ruined by pragmatism, and now everyone just signs their applets and the users can&#8217;t run them unless they modify their JVM or allow the code to run with full privileges.</p>
<p>Heck, even QNX is vastly superior to *nix just because they took a few old academic ideas into practice.</p>
<p>But what I really want to get down to is that strong typing is mandatory. (Strong typing in the data sense as well as language).</p>
<p>What I mean by strong typing in the data level is that you don&#8217;t take a bunch of random text and try to interpret it. You don&#8217;t take a bunch of machine words off the stack/heap and try to interpret them. Data must be organized mechanically, never trust the human.</p>
<p>Stack smashing happens because of lack of strong typing; array&#8217;s don&#8217;t really exist, you just get pointers to memory and are free to do anything with them, integers don&#8217;t exist either, you just have machine words. Actually nothing exists because C is just one crappy abstraction with a ton of undefined behavior. Strongly typed arrays cannot be violated, nor can ints etc. C is another example of this nonsense re-usability notion, to make it &#8220;fast&#8221;, _as well_ as portable, it has to have tons of undefined behavior. A secure system would have a high level language and the underlying low level components would be written in a way specialized to that architecture, in which case you can get performance as well as **no** undefined behavior.</p>
<p>XSS is because of lack of strong typing, you are just taking a bunch of text and blindly treating it as code or crap to inject into some text that is meant to be code. This is about as unreliable as it gets. Strongly typed declarative data structures prevent this.</p>
<p>SQL Injection? Ditto. But has been solved by A) ORMs that aren&#8217;t vulnerable B) Object databases (which are on par and sometimes better than RDBMS with respect to performance, BTW) C) HaskellDB ;)</p>
<p>HTTP injection? Well this doesn&#8217;t happen as much because one typically uses a safe API to build the HTTP request as opposed to editing it and parameterizing it by hand. This is analogous to using a safe API to manipulate a binary data structure (that is strongly typed). Hey? Binary is compact and efficient, then why do we have text protocols and formats? Oh yeah, someone thought it would be a good idea to have plaintext stuff because maybe we would be able to edit it by hand or something. BS. Do they expect us to edit 20MB XML documents by hand? You should be using a graph editor that provides a set of idiomatic transforms and queries (does this exist for XML? it should.). The only time you can edit _any_ plaintext document by hand is when it&#8217;s tiny, except this still doesn&#8217;t work because you don&#8217;t know what character set encoding to use&#8230; XML sucks, it&#8217;s not a cyclic graph so you have to retype things instead of just putting a reference to them, or invent an ad-hoc way of doing this for your schema. This is clearly propagated by the &#8220;simple&#8221; design of plaintext XML, if it were binary, they probably would have just made a real cyclic graph. This stuff also reminds me of another major issue with *nix, everything is a file (which is nonsense, everything should be an object, or maybe there is something better? I dunno, but objects are already superior to files in every way. Want streams? read: lazy evaluation), which for some reason, means everything is text with an arbitrary grammar, so you have to write a ton of regular expressions to get anything done in *nix. Ooh and you have magic numbers as return values from programs. Except these both break all the time as new versions of the programs come out. And they are a bitch to fix because they aren&#8217;t objects; you have to rewrite the parsers (text) instead of using the new fields (objects). Even the input to any *nix program is braindead and violates strong typing principles so they can&#8217;t be used without causing new vulnerabilities. Even if you escape the input to make it safe for bash or whatever shell you are using, the data within that parameter might still need to be further escaped because it&#8217;s passed as an SQL string or some other weakly typed system. I don&#8217;t know why &#8220;command line&#8221; mantra even exists anymore (now that we don&#8217;t use ancient terminal things anymore, well some people do, but not me at least), every program that has an interactive bash shell thing is different and crappy and has no multiline input and a lot of them overwrite your input as you&#8217;re typing it with output. Command line apps shouldn&#8217;t exist, there should just be objects that you invoke methods on with a _real_ (bash isn&#8217;t a real language) statically strongly typed language and get back some other objects. Static typing allows *rich* auto-completion for free. The shell can infer the variables in the local namespace that match the input parameter you are on, and then suggest them all. And the shell should actually be a decent thing, not a stupid pair of I/O streams. *nix terminal things suck **hard**. If you copy and paste some text from a web page, it might contain malicious code followed by a newline (a page can make you copy something other than what is displayed and highlighted on it), and you get owned. Oooh, oooh, X11 is also broken, it doesn&#8217;t let non-you users display to a constricted area on it, so you have to run random crap programs off the internet as you, and they get to steal all your non-root stuff (the stuff that *actually* matters). But they get root by ptracing your bash shell and escalating to root the next time you sudo or su. The Qubes OS tries to fix some of this stuff, but fails miserably, because it&#8217;s not even as good as or better than the Object Capability Model, which was invented decades ago, but I guess this is because they want compatibility with current software, which means they have to diminish security. Maybe they would be better off joining Tunes.</p>
<p>Computing sucks hard for many other reasons, but I&#8217;m getting tired of writing for now and am hungry.</p>
<p>What does this all have to do with firesheep? Dunno, but it&#8217;s not surprising what firesheep can do, and it&#8217;s about time someone is stepping up and trying to expose more loudly one of the many critical flaws that have been being used for malicious purposes for the past decades. I predict the next movement is for someone to write a nice metamorphic virus and take over hundreds of millions of boxes on the internet and all those crappy embedded devices. (It&#8217;s not that hard to pull off.)</p>
<p>Anyone interested in creating a secure computing paradigm and ditch all this other nonsense? Call me.<br />
</quote></p>
<p class="wp-flattr-button"></p> <p><a href="http://www.frederico-araujo.com/?flattrss_redirect&amp;id=215&amp;md5=7e17daf5d78b1ce9e21b82e9022b11cc" title="Flattr" target="_blank"><img src="http://www.frederico-araujo.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.frederico-araujo.com/2011/01/25/strongly-typed-language-and-security/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>AFP on centos 5.5 that works</title>
		<link>http://www.frederico-araujo.com/2011/01/01/afp-on-centos-5-5-that-works/</link>
		<comments>http://www.frederico-araujo.com/2011/01/01/afp-on-centos-5-5-that-works/#comments</comments>
		<pubDate>Sat, 01 Jan 2011 09:18:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[osx]]></category>

		<guid isPermaLink="false">http://www.frederico-araujo.com/?p=206</guid>
		<description><![CDATA[I had to setup AFP (netatalkd) on a centos 5.5 machine. Many tutorials had something missing. so I took the best of each and put here.

You will need gcc and some packages/libs for building berk-db and netatalkd, like "patch" and "make"
  yum install openssl.x86_64 libssl-dev gcc automake autoconf GSSAPI libgssapi-devel libgssapi  libgssapi-devel ...]]></description>
			<content:encoded><![CDATA[<p>I had to setup AFP (netatalkd) on a centos 5.5 machine. Many tutorials had something missing. so I took the best of each and put here.</p>
<p>You will need gcc and some packages/libs for building berk-db and netatalkd, like &#8220;patch&#8221; and &#8220;make&#8221;</p>
<pre>  yum install openssl.x86_64 libssl-dev gcc automake autoconf GSSAPI libgssapi-devel libgssapi  libgssapi-devel krb5-devel pam-devel shadow-devel openssl-devel cracklib wget</pre>
<p>1. Download the latest berkeley-db 4.8 (5.0 and 5.1 did not work for me), compile and install</p>
<pre>wget http://download.oracle.com/berkeley-db/db-4.8.30.tar.gz
tar xpf db-4.8.30.tar.gz
cd db-4.8.30/build_unix/
../dist/configure
make
make install</pre>
<p>2.  Download latest netatalkd, compile, install and copy config files to /etc/atalk<br />
AFP works fine with the default configuration files.</p>
<pre>wget "http://downloads.sourceforge.net/project/netatalk/netatalk/2.1.5/netatalk-2.1.5.tar.bz2?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fnetatalk%2F&amp;ts=1293643408&amp;use_mirror=biznetnetworks"
tar xpf netatalk-2.1.5.tar.bz2
cd netatalk-2.1.5

./configure --enable-redhat --enable-pgp-uam --enable-krb4-uam --enable-krbV-uam --with-bdb=/usr/local/BerkeleyDB.4.8/
make
make install
mkdir -p /etc/atalk/
cp -a config/*.conf /etc/atalk/
chkconfig netatalk on
service netatalk start
</pre>
<p></p>
<h3>Extra:</h3>
<p>
When you mount this filesystem on mac, all files and directory permissions will be reset to 755, which is really annoying, specially if you use git. Git will show all the file permission changes to 755 instead of 644 for files.
</p>
<p>
so, to solve the problem edit the file /etc/atalk/AppleVolumes.default and update the last line on the file
</p>
<pre>  vi /etc/atalk/AppleVolumes.default
  # change from
    :DEFAULT: options:upriv,usedots
  # to
    :DEFAULT: options:upriv,usedots dperm:0755 fperm:0644</pre>
<p>Resources:</p>
<ul>
<li> <a href="http://www.linuxquestions.org/questions/red-hat-31/how-to-get-netatalk-installed-on-centos-5-1-a-636147/">
<p>http://www.linuxquestions.org/questions/red-hat-31/how-to-get-netatalk-installed-on-centos-5-1-a-636147/</p>
<p></a></li>
<li> <a href="http://permalink.gmane.org/gmane.network.netatalk.user/20594">
<p>http://permalink.gmane.org/gmane.network.netatalk.user/20594</p>
<p></a></li>
</ul>
<p class="wp-flattr-button"></p> <p><a href="http://www.frederico-araujo.com/?flattrss_redirect&amp;id=206&amp;md5=0de77484a0d1ea445875682180343f95" title="Flattr" target="_blank"><img src="http://www.frederico-araujo.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.frederico-araujo.com/2011/01/01/afp-on-centos-5-5-that-works/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Monit and Unicorn rails</title>
		<link>http://www.frederico-araujo.com/2010/11/19/monit-and-unicorn-rails/</link>
		<comments>http://www.frederico-araujo.com/2010/11/19/monit-and-unicorn-rails/#comments</comments>
		<pubDate>Fri, 19 Nov 2010 12:18:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[monit]]></category>

		<guid isPermaLink="false">http://www.frederico-araujo.com/?p=197</guid>
		<description><![CDATA[This is a monit recipe for a rails app with 4 Unicorn threads using SOCKET. The app averages a total memory usage of 600 MB.
If it goes over 800 MB send email alert only. 
If over 860 MB, reload the app.
Also if it's using too much CPU, alert by email.

I use unicorn_rails on socket ...]]></description>
			<content:encoded><![CDATA[<p>This is a monit recipe for a rails app with 4 Unicorn threads using SOCKET. The app averages a total memory usage of 600 MB.<br />
If it goes over 800 MB send email alert only.<br />
If over 860 MB, reload the app.<br />
Also if it&#8217;s using too much CPU, alert by email.</p>
<p>I use unicorn_rails on socket mode with nginx, and preload_app = true. </p>
<pre>
check process myapp_unicorn
  with pidfile /var/www/apps/my_app.com/shared/pids/unicorn.pid
group unicorn
if totalmem &gt; 800 MB for 2 cycles
  then alert
if totalmem &gt; 860 MB for 2 cycles
  then exec "kill -HUP `cat /var/www/apps/my_app.com/shared/pids/unicorn.pid`"
if cpu &gt; 40% for 2 cycles then alert
if cpu &gt; 20% for 4 cycles then alert
if failed
  unixsocket /var/www/apps/my_app.com/shared/pids/unicorn.sock
  then alert
</pre>
<p>note: the HUP signal will reload the children processes without reloading code changes. This is fast and desirable.</p>
<p>Resources:<br />
<a href="http://unicorn.bogomips.org/SIGNALS.html">http://unicorn.bogomips.org/SIGNALS.html</a><br />
<a href="http://mmonit.com/monit/documentation/monit.html">http://mmonit.com/monit/documentation/monit.html</a></p>
<p class="wp-flattr-button"></p> <p><a href="http://www.frederico-araujo.com/?flattrss_redirect&amp;id=197&amp;md5=6f170e7dcdc5e6ee1a30f1d6db15ca5c" title="Flattr" target="_blank"><img src="http://www.frederico-araujo.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.frederico-araujo.com/2010/11/19/monit-and-unicorn-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Install a Rails enviroment on Snow Leopard with Macports, Mysql and ModRails Passenger (updated)</title>
		<link>http://www.frederico-araujo.com/2010/08/19/installing-rails-enviroment-on-snow-leopard-with-macports-mysql-and-modrails-passenger/</link>
		<comments>http://www.frederico-araujo.com/2010/08/19/installing-rails-enviroment-on-snow-leopard-with-macports-mysql-and-modrails-passenger/#comments</comments>
		<pubDate>Thu, 19 Aug 2010 08:36:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[sphinx]]></category>

		<guid isPermaLink="false">http://www.frederico-araujo.com/?p=175</guid>
		<description><![CDATA[UPDATE: New version for OS X Lion HERE

I choose the simple and I believe clean way to use everything from macports and passenger.

The advantage is that it's all isolated from the OS X system and using latest cutting edge version of softwares.

I assume you have textmate, because it's easy to edit files that need ...]]></description>
			<content:encoded><![CDATA[<p>UPDATE: New version for OS X Lion <a href="http://www.frederico-araujo.com/2011/07/30/installing-rails-on-os-x-lion-with-homebrew-rvm-and-mysql/">HERE</a></p>
<p>I choose the simple and I believe clean way to use everything from macports and passenger.</p>
<p>The advantage is that it&#8217;s all isolated from the OS X system and using latest cutting edge version of softwares.</p>
<p>I assume you have textmate, because it&#8217;s easy to edit files that need sudo access. Textmate will just ask for your password.</p>
<p>Try and download the 30 days trial for easy of this tutorial. <a href="http://macromates.com/">http://macromates.com/</a></p>
<p>Trust me, you will love Textmate, it&#8217;s state of the art editor.</p>
<p>ps: I use &#8220;mate&#8221; instead of &#8220;open -a TextMate&#8221; but not everyone might have the mate symlink.</p>
<h3>Requirements:</h3>
<ul>
<li> Snow Leopard 10.6.4 or greater</li>
<li> Xcode 3.2.3, 2.4.1 or greater</li>
<li> Admin privileges on your mac.</li>
</ul>
<h3>Software preliminary:</h3>
<ul>
<li> Mysql 5.1.49 (macports)</li>
<li> Ruby 1.8.7 (macports)</li>
<li> Apache 2.2.9 (part of OS X)</li>
<li> Rubygems (download)</li>
<li> passenger (gem)</li>
<li> ImageMagick</li>
<li> rmagick</li>
</ul>
<h3>1. Preparing System</h3>
<p>If you are upgrading from Leopard to Snow Leopard, I recommend you delet your old installation.</p>
<pre class="command">sudo rm -rf \
    /opt/local \
    /Applications/DarwinPorts \
    /Applications/MacPorts \
    /Library/LaunchDaemons/org.macports.* \
    /Library/Receipts/DarwinPorts*.pkg \
    /Library/Receipts/MacPorts*.pkg \
    /Library/StartupItems/DarwinPortsStartup \
    /Library/Tcl/darwinports1.0 \
    /Library/Tcl/macports1.0 \
    ~/.macports
</pre>
<h4>1.1 Prepare PATH environment:</h4>
<pre class="command">$ open -a TextMate ~/.bash_profile
</pre>
<p>Edit your ~/.bash_profile file and add these 2 line.<br />
Check if they are not there already.</p>
<pre>export PATH=/opt/local/bin:/opt/local/sbin:$PATH
export MANPATH=/opt/local/share/man:$MANPATH
</pre>
<h4>1.2 Download and Install Xcode</h4>
<p><a href="http://developer.apple.com/technologies/xcode.html">http://developer.apple.com/technologies/xcode.html</a></p>
<h4>1.3 Download Macports and install</h4>
<p>Download Page: <a href="http://www.macports.org/install.php">http://www.macports.org/install.php</a></p>
<p>Download Direct Link: <a href="http://distfiles.macports.org/MacPorts/MacPorts-1.9.2-10.6-SnowLeopard.dmg">http://distfiles.macports.org/MacPorts/MacPorts-1.9.2-10.6-SnowLeopard.dmg</a></p>
<p>You might use this guide for installing Macports:</p>
<p>Full Install Guide: http://guide.macports.org/#installing</p>
<h4>1.3.1 Update macports</h4>
<pre class="command">sudo port -v selfupdate</pre>
<h3>2. Mysql</h3>
<h4>2.1 Intall Mysql</h4>
<pre class="command">sudo port -v install mysql5-server mysql5</pre>
<h4>2.2 Make mysql autoload on startup</h4>
<pre class="command">sudo port load mysql5-server
sudo -u mysql mysql_install_db5
</pre>
<h3>3. Memcached (Optional)</h3>
<pre class="command">sudo port -v install memcached libmemcached</pre>
<h4>3.1 Autoload memcached on startup</h4>
<pre class="command">sudo port load memcached</pre>
<h3>4. Ruby, Rubygems, Rails, other gems</h3>
<p>4.1 Install Ruby from macports</p>
<pre class="command">sudo port -v install ruby</pre>
<pre class="command">$ ruby -v
ruby 1.8.7 (2010-08-08 patchlevel 302) [x86_64-darwin10]
</pre>
<h4>4.2 download rubygems from http://rubygems.org/pages/download</h4>
<pre class="command">cd /tmp
wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz
tar xpf rubygems-1.3.7.tgz
cd rubygems-1.3.7
sudo ruby setup.rb
</pre>
<h4>4.3 Install rails, rake, rspec etc.</h4>
<pre class="command">sudo gem install rake rails thin tzinfo capistrano ruby-debug rspec</pre>
<p>extra:</p>
<h4>4.4 install mysql gem</h4>
<pre class="command">sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/opt/local/lib/mysql5/bin/mysql_config
</pre>
<h3>5. ImageMagick, Rmagick and mini_magick (Optional)</h3>
<p>lets install ImageMagick with support for JPEG, TIFF, WMF, PDF, and PNG images, and for Postscript and TrueType fonts.</p>
<pre class="command">sudo port -v install tiff -macosx imagemagick +q8 +gs +wmf</pre>
<pre class="command">sudo gem install mini_magick rmagick</pre>
<p>Test rmagick</p>
<pre class="command">$ irb -rubygems -r RMagick
&gt;&gt; puts Magick::Long_version
This is RMagick 2.13.1 ($Date: 2009/12/20 02:33:33 $) Copyright (C) 2009 by Timothy P. Hunter
Built with ImageMagick 6.6.3-0 2010-08-19 Q8 http://www.imagemagick.org
Built for ruby 1.8.7
Web page: http://rmagick.rubyforge.org
Email: rmagick@rubyforge.org
=&gt; nil
</pre>
<h3>6. Passenger</h3>
<h4>6.1 Install Passenger gem</h4>
<pre class="command">sudo gem install passenger</pre>
<h4>6.2 Check Passenger path</h4>
<pre class="command">passenger-config --root</pre>
<pre> -&gt; /opt/local/lib/ruby/gems/1.8/gems/passenger-2.2.15</pre>
<h4>6.3 Build passenger for apache</h4>
<p>follow instructions on screen</p>
<pre class="command">sudo passenger-install-apache2-module</pre>
<h4>6.4 Enable Passenger on apache:</h4>
<pre class="command">open -a TextMate /etc/apache2/extra/httpd-passenger.conf</pre>
<p>Put this on that file, change wherever necessary for your directories.</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">LoadModule</span> passenger_module /opt/local/lib/ruby/gems/<span style="color: #ff0000;">1.8</span>/gems/passenger-2.2.15/ext/apache2/mod_passenger.so
PassengerRoot /opt/local/lib/ruby/gems/<span style="color: #ff0000;">1.8</span>/gems/passenger-2.2.15
PassengerRuby /opt/local/bin/ruby
PassengerMaxPoolSize <span style="color: #ff0000;">6</span>  <span style="color: #adadad; font-style: italic;"># maximum global rails servers</span>
PassengerMaxInstancesPerApp <span style="color: #ff0000;">2</span>  <span style="color: #adadad; font-style: italic;"># maximum rails servers per application</span>
RailsFrameworkSpawnerIdleTime <span style="color: #ff0000;">1800</span>
RailsAppSpawnerIdleTime <span style="color: #ff0000;">600</span>
PassengerPoolIdleTime <span style="color: #ff0000;">600</span>
PassengerMaxRequests <span style="color: #ff0000;">1000</span>  <span style="color: #adadad; font-style: italic;"># after 1000 requests will restart server, to skip memory leak :)</span>
&nbsp;
<span style="color: #adadad; font-style: italic;"># Enabling NameBased Virtualhost</span>
<span style="color: #00007f;">NameVirtualHost</span> *:<span style="color: #ff0000;">80</span>
&nbsp;
<span style="color: #adadad; font-style: italic;"># my rails app virtual host 1</span>
&lt;<span style="color: #000000; font-weight:bold;">VirtualHost</span> *:<span style="color: #ff0000;">80</span>&gt;
    <span style="color: #00007f;">ServerName</span> my-rails-app.local
    <span style="color: #00007f;">DocumentRoot</span> <span style="color: #7f007f;">&quot;/Users/fred/rails/my-rails-app/public&quot;</span> <span style="color: #adadad; font-style: italic;"># change this to match your folder</span>
    RailsEnv <span style="color: #7f007f;">&quot;development&quot;</span>
   &lt;<span style="color: #000000; font-weight:bold;">Directory</span> /Users/fred/rails/my-rails-app/public&gt;
        <span style="color: #adadad; font-style: italic;"># change this to match your folder</span>
        <span style="color: #adadad; font-style: italic;"># MultiViews must be turned off</span>
        <span style="color: #00007f;">Options</span> -MultiViews
        <span style="color: #00007f;">AllowOverride</span> <span style="color: #0000ff;">All</span>
        <span style="color: #00007f;">Order</span> <span style="color: #00007f;">allow</span>,<span style="color: #00007f;">deny</span>
        <span style="color: #00007f;">Allow</span> from <span style="color: #0000ff;">all</span>
    &lt;/<span style="color: #000000; font-weight:bold;">Directory</span>&gt;
    <span style="color: #adadad; font-style: italic;"># logs are optional, change this to match your folder</span>
    <span style="color: #00007f;">CustomLog</span>  <span style="color: #7f007f;">&quot;/Users/fred/rails/my-rails-app/log/access_log&quot;</span> combined
    <span style="color: #00007f;">ErrorLog</span>   <span style="color: #7f007f;">&quot;/Users/fred/rails/my-rails-app/log/error_log&quot;</span>
&lt;/<span style="color: #000000; font-weight:bold;">VirtualHost</span>&gt;
&nbsp;
<span style="color: #adadad; font-style: italic;"># my rails app virtual host 2</span>
&lt;<span style="color: #000000; font-weight:bold;">VirtualHost</span> *:<span style="color: #ff0000;">80</span>&gt;
    <span style="color: #00007f;">ServerName</span> myapp-xyz.local
    <span style="color: #00007f;">DocumentRoot</span> <span style="color: #7f007f;">&quot;/Users/fred/rails/myapp-xyz/public&quot;</span>  <span style="color: #adadad; font-style: italic;"># change this to match your folder</span>
    RailsEnv <span style="color: #7f007f;">&quot;development&quot;</span>
    &lt;<span style="color: #000000; font-weight:bold;">Directory</span> /Users/fred/rails/my-rails-app/public&gt;
        <span style="color: #adadad; font-style: italic;"># change this to match your folder</span>
        <span style="color: #adadad; font-style: italic;"># MultiViews must be turned off</span>
        <span style="color: #00007f;">Options</span> -MultiViews
        <span style="color: #00007f;">AllowOverride</span> <span style="color: #0000ff;">All</span>
        <span style="color: #00007f;">Order</span> <span style="color: #00007f;">allow</span>,<span style="color: #00007f;">deny</span>
        <span style="color: #00007f;">Allow</span> from <span style="color: #0000ff;">all</span>
    &lt;/<span style="color: #000000; font-weight:bold;">Directory</span>&gt;
    <span style="color: #00007f;">CustomLog</span>  <span style="color: #7f007f;">&quot;/Users/fred/rails/myapp-xyz/log/access_log&quot;</span> combined
    <span style="color: #00007f;">ErrorLog</span>  <span style="color: #7f007f;">&quot;/Users/fred/rails/myapp-xyz/log/error_log&quot;</span>
&lt;/<span style="color: #000000; font-weight:bold;">VirtualHost</span>&gt;</pre></div></div>

<p>6.5 Enable Virtual host on apache:</p>
<pre class="command">open -a TextMate /etc/apache2/httpd.conf</pre>
<p>Add this new line at the bottom:</p>
<pre># Include Passenger ModRails config file
Include /private/etc/apache2/extra/httpd-passenger.conf
</pre>
<h4>6.6 Add your .local domain to /etc/hosts/</h4>
<pre class="command">open -a TextMate /etc/hosts</pre>
<p>Add this line to that file and change to the name of your choosen application</p>
<p>You might add as many as you want, each line for each that ServerName on your VirtualHost blocks</p>
<pre>127.0.0.1 my-rails-app.local
127.0.0.1 myapp-xyz.local
</pre>
<p>I have more than 50 .local apps in there.</p>
<h4>5 Start Apache</h4>
<p>first let&#8217;s test apache configuration:</p>
<pre class="command">apachectl configtest</pre>
<p>if you get &#8220;Syntax OK&#8221; then you are ready to start it</p>
<pre class="command">sudo apachectl start</pre>
<p>If you want Apache to autostart when you boot your computer,<br />
then enable Web Sharing from preferences.</p>
<h4>7. Final</h4>
<p>go to your browser and open the url of your application http://my-rails-app.local</p>
<p>If it works, congratulations.</p>
<p>If didn&#8217;t work, let me know here in the comments.</p>
<h3>Extras</h3>
<h4>Nokogiri</h4>
<pre class="command">  sudo port -v install libxml2 libxslt
  sudo gem install nokogiri -- --with-xml2-include=/opt/local/include/libxml2 --with-xml2-lib=/opt/local/lib --with-xslt-dir=/opt/local
</pre>
<h4>Sqlite</h4>
<pre class="command">sudo port install sqlite3
sudo gem install sqlite3-ruby
</pre>
<h3>9. Sphinx, thinking-sphinx, sphinxsearchlogic</h3>
<pre class="command">sudo port install sqlite3
sudo gem install thinking-sphinx sphinxsearchlogic
</pre>
<h4>Update:</h4>
<p>From the comments, some people might want to enable php and your Sites folder.</p>
<p>To be able to enable php and others you will have to enable another default vhost with localhost as servername.</p>
<p>Edit the file /etc/apache2/httpd.conf to enable vhosts</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #adadad; font-style: italic;"># Virtual hosts</span>
<span style="color: #00007f;">Include</span> /private/etc/apache2/extra/httpd-vhosts.conf</pre></div></div>

<p>then open /private/etc/apache2/extra/httpd-vhosts.conf file,<br />
delete or comment everything from there and add this block only:</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #adadad; font-style: italic;">#</span>
<span style="color: #adadad; font-style: italic;"># Use name-based virtual hosting.</span>
<span style="color: #adadad; font-style: italic;">#</span>
<span style="color: #00007f;">NameVirtualHost</span> *:<span style="color: #ff0000;">80</span>
&nbsp;
<span style="color: #adadad; font-style: italic;"># Change /Users/fred/ to your appropriate login name</span>
&lt;<span style="color: #000000; font-weight:bold;">VirtualHost</span> *:<span style="color: #ff0000;">80</span>&gt;
    <span style="color: #00007f;">ServerName</span> localhost
    <span style="color: #00007f;">DocumentRoot</span> /Users/fred/Sites/
    <span style="color: #00007f;">RewriteEngine</span> <span style="color: #0000ff;">On</span>
    <span style="color: #00007f;">DefaultType</span> text/html
    &lt;<span style="color: #000000; font-weight:bold;">Directory</span> <span style="color: #7f007f;">&quot;/Users/fred/Sites&quot;</span>&gt;
        <span style="color: #00007f;">DefaultType</span> text/html
        <span style="color: #00007f;">Options</span> +ExecCGI <span style="color: #0000ff;">FollowSymLinks</span> <span style="color: #0000ff;">Indexes</span>
        <span style="color: #00007f;">AllowOverride</span> <span style="color: #0000ff;">All</span>
        <span style="color: #00007f;">Order</span> <span style="color: #00007f;">allow</span>,<span style="color: #00007f;">deny</span>
        <span style="color: #00007f;">Allow</span> from <span style="color: #0000ff;">all</span>
    &lt;/<span style="color: #000000; font-weight:bold;">Directory</span>&gt;
&lt;/<span style="color: #000000; font-weight:bold;">VirtualHost</span>&gt;</pre></div></div>

<h3>Links and Resources</h3>
<p><a href="http://rmagick.rubyforge.org/install-osx.html">http://rmagick.rubyforge.org/install-osx.html</a></p>
<p><a href="http://wiki.github.com/tenderlove/nokogiri/what-to-do-if-libxml2-is-being-a-jerk">http://wiki.github.com/tenderlove/nokogiri/what-to-do-if-libxml2-is-being-a-jerk</a></p>
<p><a href="http://www.macports.org/install.php">http://www.macports.org/install.php</a></p>
<p><a href="http://guide.macports.org/#installing">http://guide.macports.org/#installing</a></p>
<p><a href="http://distfiles.macports.org/MacPorts/MacPorts-1.9.1-10.6-SnowLeopard.dmg">http://distfiles.macports.org/MacPorts/MacPorts-1.9.1-10.6-SnowLeopard.dmg</a></p>
<p><a href="http://rob.by/2009/installing-mysql-via-macports-on-snow-leopard-for-ruby-development">http://rob.by/2009/installing-mysql-via-macports-on-snow-leopard-for-ruby-development</a>/</p>
<p><a href="http://macromates.com/">http://macromates.com/</a></p>
<p><a href="http://github.com/joost/sphinxsearchlogic">http://github.com/joost/sphinxsearchlogic</a></p>
<p><a href="http://www.sphinxsearch.com/">http://www.sphinxsearch.com/</a></p>
<p class="wp-flattr-button"></p> <p><a href="http://www.frederico-araujo.com/?flattrss_redirect&amp;id=175&amp;md5=be7fd42f32664ab254944597720652e0" title="Flattr" target="_blank"><img src="http://www.frederico-araujo.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.frederico-araujo.com/2010/08/19/installing-rails-enviroment-on-snow-leopard-with-macports-mysql-and-modrails-passenger/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
	</channel>
</rss>

