Setting up a Ruby on Rails server - Part 2 - install Ruby, Rubygems and Rails

By Nick | March 29, 2007

Installing Ruby and Rubygems on CentOS turned out to be not that simple. First of all you can’t just say ‘yum install ruby’, because there won’t be a version of Ruby higher than 1.8.4 available. So the easiest way to install Ruby is from source. In order to get Ruby and Rubygems running smoothly, you have to make sure the zlib library is installed, otherwise you get all sorts of errors and you can start all over again.

Install zlib:

yum install zlib-devel

tar xvfz zlib-1.2.3.tar.gz
cd zlib-1.2.3
make test
make install

Once zlib is installed you can start with Ruby (note that I haven’t got the latest version of Ruby installed):

tar -zxvf ruby..
yum install gcc
make install

You can test your Ruby installation with the command: ruby -v

To finish you need to install Rubygems in order to install other gems (again note that I have n’t got the latest version of Rubygems)

tar -zxvf rubygems-0.9.0.tgz
ruby setup.rb

After the installation you should update Rubygems, in order to do so run the command: gem update –system

In case you can’t install Rubygems, because it gives you a zlib error you need to make sure you remove everything from Ruby and Rubygems and start all over again.

Once all the above is installed you can finally install Rails, which is the easy part, just enter:

gem install rails --include-dependencies

And your done, Rails should be running!
Next stop, install MySQL to interact with.

Topics: Rails | No Comments »

Setting up a Ruby on Rails server - Part 1

By Nick | March 22, 2007

Developing in Ruby on Rails is easy, but making your application available to the world is a little bit harder. I have managed to do it and many others have and you can find good tutorials all over the internet. I will also try to share my experience with you. And if somebody finds it useful, I’ll be happy.

First thing you need to consider is what type of hosting you are looking for: shared hosting, virtual private server or dedicated server. Which type you choose depends on your specific needs. When you have decided on the type, you can look for a good host. A good starting point is off course my own Rails Hosting Info site.

I have settled on a dedicated server, mainly because it gives me full control over everything (except the occasional outages, due to power or hardware failures). It was also because I needed Java, Ruby on Rails and a bit more RAM (the most I could squeeze out of my tiny budget). The biggest problem was that I didn’t really had that much experience with installing a complete box from scratch. So two weeks went into setting up a virtual environment on my PC (I used the free version of VMWare) and then roll the whole thing out in a couple of days. In the process I learned a lot, so it was a fun experience and having a dedicated server is a nice feeling. You want to start a new project? Just register a new domain name, setup a vhost and you’re off.

My dedicated server has an AMD Sempron 2400+ processer and 1GB of RAM and currently hosts 4 separate domains.

Choosing the operating system was a bit difficult. You have a lot of options Windows, Linux, BSD or even Mac. Windows and Mac weren’t really an option, because they aren’t free. My first option was OpenBSD or FreeBSD, but there were some problems with Java or so it seemed. And since Java was a must, I had to look at Linux. Biggest problem with Linux these days is that there are so many flavors. For example: Debian, Red Hat, CentOS, Ubuntu, … Luckily the hosting company I choose only supports two flavors: Centos and Debian. I first wanted to use Debian, since I already had some experience with it. But the packages were a bit outdated and there was a major release (Edge) pending, but it had some delay. So CentOS it was. CentOS is based on Red Hat Enterprise Linux, but contrary to RHEL it is free. What I learned from experimenting with two different Linux versions is that it doesn’t really matter which Linux version you choose, they are capable enough to do the job. So choose the one you are most comfortable with.

In the next couple of posts I will turn my attention to:

You will notice that I often take the path of least resistance. If it is to difficult to setup, I’ll look elsewhere. And trust me not everything was as easy as I initially thought.

Topics: Rails | No Comments »

How to drive more traffic to your website?

By Nick | March 22, 2007

My first question to you is. How on earth do you get more traffic to your website? What actions do you take to get more people to visit your site? This is what I have done so far:

If you know of other good means to attract more visitors, please post your comments. Thanks.

Topics: Various | No Comments »

WordPress - Rails - Litespeed

By Nick | March 20, 2007

Pretty urls these days are pretty important if you want a decent ranking in Google. In order to get pretty url’s enabled in WordPress, you have to add some rewrite rules. All my WordPress files are located in the /public/blog directory of my Rails project. You shouldn’t add your rewrite rules to .htaccess as is suggested in the WordPress admin interface. Instead you have to add it to your virtual host in Litespeed. Add the following rewrite rules to Litespeed:

RewriteEngine On
RewriteBase /blog/
RewriteCond %{REQUEST_URI} ^/blog.*
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]

And now all your blog posts have pretty urls.

Topics: Rails, WordPress, Litespeed | No Comments »

WordPress installation - Error establishing a database connection

By Nick | March 19, 2007

First post and first complaint. For all of you wondering why I am using a php blog, I would like to say that I looked first at Mephisto. But unfortunately I didn’t manage to get it running :( So I thought I’ll try the market leader WordPress, that should be fairly easy to install. And yes, they have a five minute installation guide. Five more minutes and I’ll be blogging …

Not exactly! I got the error: Error establishing a database connection, even though I had everything configured fine in wp-config.php So after a lot of searching on the WordPress forum (a lot of people already had encountered this error!) I found the solution.

I added the following line to wp-db.php (in the wp-includes folder)

function wpdb($dbuser, $dbpassword, $dbname, $dbhost)
$this->dbh = @mysql_connect($dbhost, $dbuser, $dbpassword, true);

//Add this line:
echo (mysql_error());

This returned the error “Client does not support authentication protocol requested by server; consider upgrading MySQL client

Since I’m already running MySQL 5 I didn’t see any point of upgrading it. So I continued my quest for a solution. And there it was …

WordPress apparently isn’t to keen on the new password structure of MySQL 5, so I had to run the following query to give my WordPress user an “old” password.

SET PASSWORD FOR [email protected]_host = OLD_PASSWORD('your_old password_here');

And as you may have noticed I have managed to get it running!! So stay tuned for some Rails gossip :D

Topics: WordPress | 4 Comments »

Next Entries »