About Me

Curriculum Vitae

A brief list of my current skill set

Bloggybits

Playing Around With HTML5's Canvas
Friday, 10th August 2012, 16:19

Speccy loading screens in a browser!

Scripting in Node.js AKA How to Watch for Olympic Tickets Using a Script
Tuesday, 7th August 2012, 23:37

Let Node refresh the webpage so you don't have to!

A Javascript Confirm/Alert Replacement jQuery Plugin
Monday, 6th August 2012, 23:06

Much prettier than the horrible alert and confirm dialogs

A Few Node.js Essential Modules
Friday, 3rd August 2012, 14:40

As essential as they can be anyway

Retro Coding Corner: Loading ZX Spectrum Snapshots off Microdrives - Part 2
Tuesday, 31st July 2012, 18:20

It's like juggling 8 balls with one hand behind your back

One Layout To Rule Them All
Monday, 30th July 2012, 16:03

Designing a layout to fit every screen

Retro Coding Corner: Loading ZX Spectrum Snapshots off Microdrives - Part 1
Thursday, 26th July 2012, 16:57

From emulation to super fast tape

Upgrading Libxml2 on CentOS 5.8 fixes Libxmljs
Wednesday, 25th July 2012, 11:33

Fixes strange compile errors and everyfin

Installing Node.js 0.8.x under CentOS 5.8
Tuesday, 24th July 2012, 14:13

It's just an upgrade of Python away

Node.js and Object Oriented Programming
Sunday, 22nd July 2012, 23:46

Make pages inherit pages

MinnaHTML.js - A HTML Web Framework For Node.js
Saturday, 14th July 2012, 22:53

Make webpages the OOP way

Everyone Should Learn to Debug Without a Debugger
Monday, 11th June 2012, 22:42

Because one day they'll all get eaten

Geeky Things What I Wrote Elsewhere
Wednesday, 2nd May 2012, 17:51

A few links to geeky articles I posted on another website

How to Get TypeKit to Working Inside TinyMCE
Monday, 2nd April 2012, 20:36

It's all about the setup baby

Projects and Sillyness

MAME Cabinet Diary

How I built my own arcade cabinet

Loading Screen Simulator

I don't miss the ZX Spectrum, I still use it!

The Little Guy Chat Room

It's a Pitfall inspired chat room

GPMad MP3

A fully featured MP3 player what I wrote

GP Space Invaders

My first little emulator

GP32 Development Page

Some info and links about this cute little handheld

Disney Nasties

Uncensored images, you must be 18 to view them

Minna's World

The cuttest fluffy puppy in the world

Diary of a Hamster

Learn about how hamsters think, first hand

Utilities

Time Calculator

A simple little online utility for working out how many hours to bill a client

A Few Links

Installing Node.js 0.8.x under CentOS 5.8
Tuesday, 24th July 2012, 14:13

So, the 0.8 branch of Node.js hit a few weeks ago now, and we have had some updates (to 0.8.3 at the time of writing) as well. Certainly my initial attempts at upgrading to it resulted in a quick jump back to the tried and tested 0.6.x stable versions, partly because it always takes module maintainers a few weeks to get up to speed, and there is always a straggler who is busy with other commitments and not managed to do it yet.

Well, I think now is the time to move, certainly for me. Everything I rely on appears to work fine under 0.8.x, so I'm going to take my live server and make the jump my test server has been flirting with on and off ever since it came out.

The only snag is, node-waf has been depreciated and in its place is node-gyp, something that helps to make cross platform compatibility easier. On its own, no big deal, unless you run CentOS 5.8 in which case it is, as that requires a newer version of Python than we have installed.

You'll have no doubt encountered this the moment you tried ./configure in the extracted node 0.8 directory. An error message like this probably appeared pretty quickly:

prompt# ./configure 
File "./configure", line 273
o['default_configuration'] = 'Debug' if options.debug else 'Release'
^
SyntaxError: invalid syntax

The cause? Python 2.4. So just upgrade Python you say! It isn't quite that easy, as parts of the CentOS system are based on specific versions which shouldn't be changed during the long life cycle of the OS version, and Python is one of those. So we are stuck with 2.4 as our base one, but don't be disheartened, we can still manage it if we get a bit fiddly.

Step One - Installing Python 2.6

We are definitely not going to install this from source, because we need to preserve the 2.4 version for the base OS and only swap to 2.6 when required.

First job is to add a repository that contains it, and will let us install alongside existing ones. For this we use the Extra Packages for Enterprise Linux (EPEL) repo as recommended on the official CentOS Wiki page, so run the following as root:

prompt# rpm -i http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm

This will add two repos to your /etc/yum.repos.d directory:

epel.repo
epel-testing.repo

Now we can install the 2.6 version, again as root:

prompt# yum install python26

This should install three packages, and will probably also ask you about importing a GPG key to which you should say yes. You should now have the following installed:

python26
python26-libs
libffi

Finally, we'll use the alternatives program to let us swap between Python versions:

prompt# alternatives --install /usr/bin/python python /usr/bin/python2.4 20
prompt# alternatives --install /usr/bin/python python /usr/bin/python2.6 10
prompt# rm /usr/bin/python
prompt# alternatives --auto python

Don't panic about removing the python executable, because it's actually a copy of /usr/bin/python24. The last line creates the symlink for whatever is the highest priority, which isn't the lowest number provided when installing but the highest, so in this case Python 2.4 is effectively the default.

Now just make sure the version you are running by default is still 2.4 by trying it:

prompt# python
Python 2.4.3 (#1, Jun 18 2012, 08:55:23)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

Press CTRL-D to exit, then run alternatives --config python and select 2.6:

prompt# alternatives --config python

There are 2 programs which provide 'python'.

Selection Command
-----------------------------------------------
*+ 1 /usr/bin/python2.4
2 /usr/bin/python2.6

Enter to keep the current selection[+], or type selection number: 2

prompt# python
Python 2.6.8 (unknown, Apr 12 2012, 20:59:36)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

All good, just remember when you need to use any module that requires node-gyp, run the alternatives config thingy and swap it to 2.6, then put it back to 2.4 so base CentOS stuff still works when you are finished.

Step Two - Installing Node 0.8

Now comes the easy bit, download Node 0.8.x, configure, install, run npm update and everything should be good to go.

prompt# cd /home/somewhere_you_download_files_to
prompt# wget http://nodejs.org/dist/v0.8.3/node-v0.8.3.tar.gz
prompt# tar zxvf node-v0.8.3.tar.gz
prompt# cd node-v0.8.3
prompt# ./configure && make && make install

prompt# cd /var/www/wherever_you_have_node_modules
prompt# npm update

Hopefully you have been sensible and kept the previous working 0.6.x release somewhere safe, so if you encounter problems you can always reinstall that.

Comments

posted by dhan on Wednesday, 24th October 2012, 14:53

thanks... a terrible centos 5.8 .. super annoying why still use 2.4 version... looks older..

posted by LIJE on Saturday, 27th October 2012, 23:33

Hi there,

I have a shared server running CentOS release 5.8 (Final) and I need to install nodejs v0.9.3.

I see you use rpm files for Python. I was using the sources. Fair enough, so I ran this line:
rpm -i http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm

and got this:
warning: /var/tmp/rpm-xfer.IsFy8K: Header V3 DSA signature: NOKEY, key ID 217521f6
error: can't create transaction lock on /var/lib/rpm/__db.000

Do you know why?
Also, do you need python 2.6 just to install nodejs or also to run it? Because we need to switch from Python 2.4 to 2.6/2.7.

The first time I tryed to install Python from the sources, I got this error message:
Python build finished, but the necessary bits to build these modules were not found:
_sqlite3 _tkinter bsddb185
readline sunaudiodev

Will I get the same with yum?

Thanks for you help.

posted by gasoved on Thursday, 17th January 2013, 04:40

Thanks for the great tutorial!
p.s. It's also giving errors with python 3.1.

posted by jsgies on Friday, 15th February 2013, 23:45

Thanks so much for this, a real lifesaver! Worked like a charm!

Add Your Own Comment