Sunday, January 29, 2012

Running multiple vHosts on same Apache - Passenger

Not a big deal, just make sure that your VirtualHost settings are set properly :



# This is import... don't forget to use NameVirtualHost if you're using a unique IP for multi Vhosts..



ServerAlias your_hostname_here.com *.your_hostname_here.com
ServerName www.your_hostname_here.com
DocumentRoot /var/www/your_hostname_here/current/public

AllowOverride all
Options -MultiViews





# Then.. you can just copy and paste, changing the hostname...

Sunday, August 7, 2011

How to install mod_ssl on Apache2 - Ubuntu

Execute the following :

# sudo a2enmod ssl


Then, restart apache:

apachectl restart

To make sure that the SSL module was loaded properly :

apache2ctl -t -D DUMP_MODULES | grep ssl

If you see :
ssl_module (shared)
(The module is loaded.)

That's it.

Wednesday, May 4, 2011

How to install SQLite3 on Fedora


First install the libraries using yum :

# sudo yum install sqlite-devel
# sudo yum install ruby-devel

Then, just install the sqlite3 gem :

sudo gem install sqlite3-ruby

That's it.

Sunday, May 1, 2011

How to upgrade to Rails 3 on Mac manuallly

I've done the process described bellow totally by hand. I'm sure that there is a better method out there, however that one worked for me.

Pre-reqs
You will have to have XCode installed in your Mac.

Update the Ruby
I've download the Ruby source code from :
http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p180.tar.gz

Untar the binary

tar -xvf ruby-1.9.2-p180.tar.gz

Let's configure, make and make install ruby
that will install 1.9.2 in your Mac.


cd ruby-1.9.2-p180
./configure
make
make install



If you don't see any errors t you should see the new version on your Mac:

ruby -v


Let's install gem.. Ok, for each Ruby installation there is a exclusive gem installation for it.
So, even though you've done the ruby update you will still see that gem is using the old Ruby 1.8.7.
So, let's start installing gem
Download the source:

http://rubyforge.org/frs/download.php/74619/rubygems-1.7.2.tgz

# cd rubygems-1.7.2
ruby setup.rb


Now, let's remove the old gem...(As a good practice..take a backup first, we never know..)
On my Mac gem was in /usr/bin/gem

mv /usr/bin/gem /usr/bin/bk_gem.old

Let's link the new version

ln -s /usr/local/bin/gem gem

Now you should see the new gem version:
gem -v 1.7.2

Now, go ahead and install Rails 3.0
gem install rails

One last thing..update rake as well :


sudo mv /usr/bin/rake /usr/bin/rake.old
$ cd /usr/bin
$ sudo ln -s /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/bin/rake rake


That's it.. You've done the upgrade to Rails3 manually.

Wednesday, July 14, 2010

Finding an Object's method using grep

I've found that would be pretty handy finding a method on an object :

1 - Use the Rails console
./server/console

2 - How to find a method by name :

Syntax.:
Object.new.methods.grep(/pattern/).sort

Example.:

User.new.methods.grep(/*[Uu]ser*/).sort

You also can compare two objects :

User.new.methods.grep(/*user*/).sort - Object.new.methods

Tuesday, December 22, 2009

Installing Postgres gems manually

Here is a way that I've found to install Postgres gems on Leopard Mac OS X :

# gem install postgres -- --with-pgsql-include-dir=/usr/local/pgsql/include --with-pgsql-lib-dir=/usr/local/pgsql/lib

It will launch a lot of errors, no worries, let's work that around :

First, set the enviroment variable :

# export ARCHFLAGS="-arch i386"

Go to the directory :
# YOUR_RAILS_INSTALL_DIR/.gem/ruby/1.8/gems/ruby-pg-0.7.9.2008.01.28/ext

Execute the following :
# ruby extconf.rb --with-pgsql-include=/usr/local/pgsql/include --with-pgsql-lib=/usr/local/pgsql/lib

(Change the PostGres installation directory accordingly )

From the sam directory execute :
gem install ruby-pg -- --with-pgsql-include-dir=/usr/local/pgsql/include/ --with-pgsql-lib-dir=/usr/local/pgsql/lib/

( This will install the postgres gems manually )

You should be good at this point.

Hope that helps.