Hazelong.com

Malaysian Beauty Blog, Art, Geekery & more...

Monthly Archives ∝ April 2011

Deploying Rails to Centos 5 : Ruby, Gems & Rails

Hi there, if you have been following this series you would roughly know that I am trying to setup a remote Centos server to house my rails apps. After installing Apache, mySQL and Git, we are now ready to install Ruby, RubyGems & Rails.

Deploying Rails to Centos 5

As I like to have multiple versions of Ruby in my system, I am going to install RVM to handle them. But before all that, we should check if ruby already exists. SSH into your remote server and run

 ruby -v

If terminal shoots you back with a Ruby version number you already have Ruby installed and you should move on to installing rails.

Let’s install RVM by running this:

$ bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

When you are done installing, you should edit your .bash_profile To do just that,

 vim ~/.bash_profile

Hit I to edit the file and paste in the following:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.

Now, hit ESC to exit editing mode and SHIFT+Z twice to get out of vim. After this, you should log out of ssh and then log back in again to refresh the session.

When you are back in again, run this

type rvm | head -1

and they should reply with this:

 rvm is a function

If it doesn’t it means that the .bash_profile isn’t updated yet.

 rvm notes

Run this to see if you missed any dependencies for installing ruby. The missing dependencies should be listed out for you. Just follow the instructions before proceeding.

Now you can finally install Ruby,

rvm get head
rvm reload
rvm install 1.8.7
rvm install 1.9.2

Create a separate gemset for all your ruby versions by running:

rvm --create 1.8.7
rvm --create use 1.9.2

And make one of them your default by typing

rvm --default use 1.9

You can also check if ruby is installed by running

 ruby -v

They should be using your default version that you just set.

The good thing about installing RVM is that they automatically include RubyGems for you already. To check this fact,

 which gem
/Users/mhartl/.rvm/rubies/ruby-head/bin/gem

Now you can install Rails!

gem install rails --version 3.0.6

Check if it is installed by running

 rails -v

Now you can has rails. Woot.
Next, we will set up a test application for rails to try and make it work with Passenger.

Deploying Rails to Centos 5 : Git

Welcome to the rails deployment series. Today, we will be installing Git on your remote server. I am not going to go into the debate of SVN vs Git. *yawnz. The purpose of installing Git in the remote server is mainly cuz my local runs Git as well and I will also be installing Gitosis in the remote server to act as a repo where I can push changes to.

Deploying Rails to Centos 5

So to start off, make sure you have all the dependencies by installing

 yum install curl-devel expat-devel gettext-devel \
openssl-devel zlib-devel

Head to http://git-scm.com/download and grab the latest link for Linux. The link is at the top right sidebar. Took me a while to find it. darn. lol.

 wget paste-link-for-git

Once it is downloaded, you can install it by running

tar -jxf git-1.7.2.2.tar.bz
cd git-1.7.2.2
make prefix=/usr/local all
sudo make prefix=/usr/local install

Make sure you type in your git archive’s name, and not the one in the code above. icon biggrin : Deploying Rails to Centos 5 : Git

When the installation is done, you can now safely remove the tar files and the git-1.7.2.2 folder by doing

 rm git-1.7.2.2.tar.gz
rm -rf git-1.7.2.2

Once you are done installing, you can check if you have git install by running

 git

You are done for now! Leave git alone and let’s install some rubies and rails!

Deploying Rails to Centos 5 : mySQL

Hello, this is part two of the series!

If you have played with Rails before, you would know that the default database is SQLite. That is fine for development, for production having mySQL is better for handling more queries.

Deploying Rails to Centos 5

Make sure you have Apache installed before doing this. There are a few dependencies that you should install as well. Connect via ssh to your remote server and run this command

 yum install httpd-devel\
openssl-devel\
zlib-devel\
gcc\
gcc-c++\
curl-devel\
expat-devel\
gettext-devel\
mysql-server\
mysql-devel

Once you are done, you can boot up mysql by doing this

 service mysqld start

And also make sure that mySQL starts when you boot up your server.

chkconfig mysqld on

Now, let’s make sure that we have a database prepped for a test rails application. To do that, run

/usr/bin/mysql -u root -p

Enter your root password if there is any.

You should be greeted with a friendly :

 mysql> 

If you want to change your root password you can do so by running this,

UPDATE mysql.user SET Password = PASSWORD('password') WHERE User = 'root';
FLUSH PRIVILEGES;

Let’s create a database for our rails test application. icon biggrin : Deploying Rails to Centos 5 : mySQL

CREATE DATABASE demodb;

And add a user for this database.

 INSERT INTO mysql.user (User,Host,Password) VALUES('loginname','localhost',PASSWORD('yourpassword'));
GRANT ALL PRIVILEGES ON demodb.* to loginname@localhost;
FLUSH PRIVILEGES;

Now you have a working database! Yay!

For a list of handy commands to communicate with your mySQL database, head here.

Next : Git

Deploying Rails to Centos 5 : Apache

This is part one of another series. I sorta lost my shell history so I figured I might as well blog it out so that I can has a reference next time.

Bear in mind that I started out with the ambition of configuring an existing Apache, PHP, mySQL, DirectAdmin running on a Centos 5.5 machine to work with rails deployment. Not a surprise, but I failed badly and managed to wreck a few working websites.

In the end, the nice people at IPserverONE have to help me reformat the server. Lol. And what’s more, the server is sponsored by them just for me to learn rails. Damn I love them.

Deploying Rails to Centos 5

First you need ssh access to the remote server. Then pop up your shell, terminal or PuTTy if you are on windows and type

 ssh root@111.111.111.111 

or if your server admin specifically tell you the port to ssh in, you could do this :

 ssh root@111.111.111.111 -p 1234 

By the way, I am running all this from my Mac Terminal fyi. :p
Enter the password as prompted and when you are in, check if apache is available by running:

 httpd 

if it says “no command found”, then installing apache is a good idea. icon smile : Deploying Rails to Centos 5 : Apache

yum install httpd mod_ssl

When it is done installing, make sure to make apache start on boot.

chkconfig --levels 235 httpd on

Now, you are going to have to configure apache by editing the configuration file thru the terminal using the vim command.

 vim /etc/httpd/conf/httpd.conf

If by doing this shoots you some error of not being able to find a file, you can locate the httpd.conf file by doing so:

 locate httpd.conf

Then you can replace the path with the previous command.

Now you should have accessed the httpd.conf file. You can use arrows to scroll up and down and read the file etc.
Replace the values with the ones below once you can locate them. If they are commented out(has a # just before the line) remove the #. To start editing the file, hit i on your keyboard.

Timeout 30
KeepAlive On
MaxKeepAliveRequests 500
KeepAliveTimeout 3
Listen 80
ServerAdmin webmaster@yourdomain.com
ServerName domain.com:80

Options FollowSymLinks
AllowOverride None
Order deny, allow
Deny from all

Options -Indexes +FollowSymLinks +MultiViews +Includes
DirectoryIndex index.html index.html.var index.shtml index.html.erb
Order allow,deny
Deny from all

Order allow,deny
Deny from all
Order allow,deny
Deny from all
Order allow,deny
Deny from all
Order allow,deny
Deny from all
Order allow,deny
Deny from all

Now you have to do some domain tying up. Your domain should be pointing to your ip address, in this example 111.111.111.111. If it isn’t pointing to it yet, you would have to tinker with your domain’s DNS settings.

In the same file, type the following when you have located the chunk that you need to replace/type:

 NameVirtualHost 111.111.111.111:80

ServerAdmin webmaster@localhost
AliasMatch ^/~([^/]+)(/.*)* /home/$1/public$2
DocumentRoot /var/www/html/
ServerName localhost

Now you are ready to add in your domains right below the chunk of code above in your config file.


ServerName www.yourdomain.com
ServerAlias yourdomain.com www.yourdomain.com
ServerAdmin webmaster@yourdomain.com
DocumentRoot /home/yourdomain/public

Options -Indexes FollowSymLinks MultiViews Includes
AllowOverride All
Order allow,deny
Allow from all

If you have multiple domains you can use the same code above for the other domains.
You are done configuring Apache! Hit Esc to get out of editing mode and Shift+Z twice to exit vim.

To make things happen, you need to create the directories first. Create all the directories for your domains like so:

 mkdir /home/yourdomain/
mkdir /home/yourdomain/public

Repeat for all domains.

Now you need to start up Apache. But before you do that run:

 httpd

and see if it shoots up any syntax errors. Ammend them first before proceeding.

To do that, either one of these commands should work

 /usr/sbin/apachectl -k start
httpd -k start

Now go to your browser and type one of the domains in and see if you are greeted by Centos Apache’s introduction page. If the domain does not show any sign of Apache like mine then it is probably Centos firewall ipTables that is blocking the port.

If so, you can try if this works

 iptables -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT 

Save the new iptables configuration

/etc/init.d/iptables restart

Now, restart your apache by doing

 httpd -k restart 

It should work icon smile : Deploying Rails to Centos 5 : Apache

Next : mySQL

Carlsberg Mural Final Part – Mr. Happy & Results

day 8 02 500x351 : Carlsberg Mural Final Part   Mr. Happy & Results

Our finalized elephant gate without the car changes.

We finally finished the wall. It was painful, difficult but in the end we just gaped at it for long periods of time. Feeling every ounce of pride our 5 feet bodies could allow.

day 8 03 500x262 : Carlsberg Mural Final Part   Mr. Happy & Results

Multiple walls of art.

And it even continues to the next wall. Note that we left out the kid’s corner. lol.. damn.

day 8 08 332x500 : Carlsberg Mural Final Part   Mr. Happy & Results

Continuing art on the other side of the wall. with a little yellow bird.

That’s a close up of how it looks like from perspective view.

day 8 01 500x419 : Carlsberg Mural Final Part   Mr. Happy & Results

Vinn and I started to work our magic on the final wall.

With that wall done, we started to work on the other wall. We quickly divided jobs. Vinn was to work on the horse and the milkman and I would fix everything else.

day 8 04 500x355 : Carlsberg Mural Final Part   Mr. Happy & Results

Painting the building and beer stripes is alot of work. Plus the cart too!

I finished the cart easily with Matthew’s base. I had a tough time working on the buildings cuz the colours were all wrong. In the end it worked out alright. When I worked on the beer stripes, Vinn was already pretty much done with the horse.

day 8 05 332x500 : Carlsberg Mural Final Part   Mr. Happy & Results

Vinn worked on the horse and milkman.

Vinn did an amazing job with the horse. icon biggrin : Carlsberg Mural Final Part   Mr. Happy & Results Now comes the milkman.

day 8 06 500x332 : Carlsberg Mural Final Part   Mr. Happy & Results

Mr. Happy. I managed to paint Mr. Happy and crack Vinn up.

She blended and asked for me to help with the face. Yeh so I had plenty of experience working on portraits but I managed to fuck this up at an epic level. lol. The milkman look so ridiculously happy that Vinn could no longer work on it without cracking herself up. Lol. Ok for disclaimer’s sake, I blame it on the size! The brushes are too big for me to work on the details. Plus, if you notice, the milkman’s nipple is right on the switch. Fucking hell.

day 8 07 500x332 : Carlsberg Mural Final Part   Mr. Happy & Results

Vinn fix Mr. Happy.

Vinn could finally fix Mr. Happy. with geometric shapes just like in the mock up. lol.

day 8 09 : Carlsberg Mural Final Part   Mr. Happy & Results

I couldn't help but add some stuff there. OMG its just triangles.

Ok done. I added some eyes and mouth. Better than Mr. Happy. He is Mr. Nobody now. It’s all good. lol

finalhorse 416x500 : Carlsberg Mural Final Part   Mr. Happy & Results

The final mural. Done. Job Wrapped.

Phew. That’s all done. Looks awesome. icon smile : Carlsberg Mural Final Part   Mr. Happy & Results Finally its a awesome job wrapped. Great experience and Vinn is really a pleasure to work with. Reminds me of our Uni days. Only that we are now shopping for groceries instead of make up and clothes. FOL

portrait1 500x375 : Carlsberg Mural Final Part   Mr. Happy & Results

Paintlust official pix for the time. I guess icon smile : Carlsberg Mural Final Part   Mr. Happy & Results

portrait2 500x416 : Carlsberg Mural Final Part   Mr. Happy & Results

This would do too icon biggrin : Carlsberg Mural Final Part   Mr. Happy & Results

What’s next?

We are now officially a team. and working on our company registration for my web design/dev stuff and her paintlust. Yes, Paintlust will nao be under Vinn Pang.

On other note, we are seeking like minded people to join our team. Preferably an all rounder when it comes to art, design and web. English proficient and outgoing, crazy and utterly passionate about ramping up Malaysia’s art & design scene. If you are interested, email me your portfolio and resume at hazelong@gmx.com.

We are currently based in PJ, so if you are nearby that will be great. We will only be getting an office space sometime later in the year or early next year so for nao its home based.

Complete Carlsberg Wall Mural Series

Carlsberg Mural Part 5 – Elephants & Walls

day 7 02 500x500 : Carlsberg Mural Part 5   Elephants & Walls

Another ride to Carlsberg. Destroyed my day.

My car’s road tax were overdued. I had to take KY‘s car. It broke down halfway with an unsettling boiling steam sound. FML. I sent to the mechanics and it seems like the coolant leaked cuz it was punctured. I called my dear fiance only to be told that he knew about it and has been managing this problem since forever. I raged at the injustice of mistreating a nice Toyota MR2 and wanted to just drive the car straight to a lamp post when I saw the mechanic start up the engine. The hood was  up and the engine trembled, shuddered and GROWLED into life. Omg it was the most beautiful sight I have ever seen. All my rage dissipated. Sigh.

day 7 01 500x373 : Carlsberg Mural Part 5   Elephants & Walls

New wall, painted by Matthew

The night before, Matthew traced the lines for the new wall and started work on it already.

day 7 07 500x332 : Carlsberg Mural Part 5   Elephants & Walls

Matthew from The One Academy painting.

He painted the tones for the cart and building. It helped ease our job alot.

day 7 03 359x500 : Carlsberg Mural Part 5   Elephants & Walls

Vinn's blending for the elephant head.

Meanwhile we did the elephants. Vinn started blending the elephant’s head. Since she had been blending from the beginning with the stones, pillars and bricks she had no problem getting started.

day 6 02 500x500 : Carlsberg Mural Part 5   Elephants & Walls

No big brush? I can fix that!

Vinn Pang came into the project fully prepared. She have a whole barrack of tools equipped for her comfort. Cloth. Egg cartons for holding paint. Plastic spoons. Pro nylon brushes for painting. Iphone. Earphones.

Ok I am not as lucky, I have been using leftover brushes from the Family’s Day. It’s not the tools its the skills as they say. wtf. Yeh I need a big brush and all I can do is masking tape 3 of them together. Turns out it became one of my favourite brush. I can rotate it to do the thin lines. Cool.

day 7 04 360x500 : Carlsberg Mural Part 5   Elephants & Walls

My attempt at doing the head.

I however, had trouble since I was doing textures and details right from the beginning. My brushes were never bigger than my finger since I only need to do details. Now I had no brush and no experience doing the blending. FML.

day 7 05 500x227 : Carlsberg Mural Part 5   Elephants & Walls

I just want to finish, go home and do some coding.

Somehow I managed to get a hang of it in the middle. Doing that and matching each other’s painting style is difficult enough.

day 7 06 500x361 : Carlsberg Mural Part 5   Elephants & Walls

Finally, we are painting without bumping heads. But we are still spilling water and paint.

In between elephants, we did the carlsberg logo plate and also the City of Carlsberg typography only to have them badly misaligned. No can do. Perfection is what we want to have.

day 7 08 408x500 : Carlsberg Mural Part 5   Elephants & Walls

My turn to do some detailing and texture for the elephant's body

After half a day, we decided to maximise our potential on the stuff that we are good at. I started doing the details for Vinn‘s elephant body  and pillars..

day 7 09 420x500 : Carlsberg Mural Part 5   Elephants & Walls

Vinn helped me out by doing the blending for the pillars behind my elephant.

Meanwhile, I was sick of doing blending and I had already finished my elephant other than the body. Vinn helped me out by blending the rest of the pillars and body.

day 7 10 500x332 : Carlsberg Mural Part 5   Elephants & Walls

Our elephants. Lacking some trunk and some details.

At the end of the day, our trick paid off. All that is left is for Vinn to do the elephant’s trunk and for me to do my own elephant body’s details. Phew.

Next – Final Part, Mr. Happy and Results.