Unfortunately I could not find proper node.js RPM available, so I had to resort to building it from source. Completely against RH ideology but what else you can do?
For reason of personal preference node.js developers resorted to python as the configuration generator (I guess they are so innovative and ahead of their time that autoconf/automake just isn’t going to cut it for them – knowing/using this ancient technology is totally below them). But I digress, the problem is that they also insisting on python 2.6 which is not Centos 5 stock version.
So, let’s begin:
- You will need to install EPEL repo and install python26 RPM out of it.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556#yum -y install python26Loaded plugins: downloadonly, fastestmirrorLoading mirror speeds from cached hostfile* base: pubmirrors.reflected.net* epel: mirror.us.leaseweb.net* extras: mirror.cogentco.com* ius: mirrors.ircam.fr* updates: mirror.7x24web.netExcluding Packages in global exclude listFinishedSetting up Install ProcessResolving Dependencies--> Running transaction check---> Package python26.x86_64 0:2.6.8-1.el5 set to be updated--> Processing Dependency: libpython2.6.so.1.0()(64bit) for package: python26--> Running transaction check---> Package python26-libs.x86_64 0:2.6.8-1.el5 set to be updated--> Finished Dependency ResolutionDependencies Resolved================================================================================Package Arch Version Repository Size================================================================================Installing:python26 x86_64 2.6.8-1.el5 epel 6.5 MInstalling for dependencies:python26-libs x86_64 2.6.8-1.el5 epel 695 kTransaction Summary================================================================================Install 2 Package(s)Upgrade 0 Package(s)Total download size: 7.2 MDownloading Packages:(1/2): python26-libs-2.6.8-1.el5.x86_64.rpm | 695 kB 00:01(2/2): python26-2.6.8-1.el5.x86_64.rpm | 6.5 MB 00:01--------------------------------------------------------------------------------Total 2.7 MB/s | 7.2 MB 00:02Running rpm_check_debugRunning Transaction TestFinished Transaction TestTransaction Test SucceededRunning TransactionInstalling : python26-libs 1/2Installing : python26 2/2Installed:python26.x86_64 0:2.6.8-1.el5Dependency Installed:python26-libs.x86_64 0:2.6.8-1.el5Complete! - Get latest node.js from the developers node.js download and unpack it at your $SRC directory (mine is usually at /usr/local/src).
12345#cd /usr/local/srcwget http://nodejs.org/dist/v0.8.7/node-v0.8.7.tar.gztar xzf node*gzcd node*7 - Next step would be to use python26 to generate node.js build configs and install it under /usr prefix as other common daemons
123456789101112131415161718192021222324# python26 ./configure --prefix=/usr{ 'target_defaults': { 'cflags': [],'default_configuration': 'Release','defines': [],'include_dirs': [],'libraries': []},'variables': { 'host_arch': 'x64','node_install_npm': 'true','node_install_waf': 'true','node_no_strict_aliasing': 1,'node_prefix': '/usr','node_shared_openssl': 'false','node_shared_v8': 'false','node_shared_zlib': 'false','node_use_dtrace': 'false','node_use_etw': 'false','node_use_openssl': 'true','target_arch': 'x64','v8_no_strict_aliasing': 1,'v8_use_snapshot': 'true'}}creating ./config.gypicreating ./config.mk#make >>../nodejs-build.log 2>&1 && make install
It’s ready now. - At some point in the future you might need node.js startup script to serve your js content. Here is the one I have:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859#!/bin/sh## chkconfig: 235 99 99# description: Node.js /home/nodejs/sample/app.js#. /etc/rc.d/init.d/functionsUSER="apache"DAEMON="/usr/bin/node"ROOT_DIR="/home/some/root/dir"SERVER="$ROOT_DIR/server.js"LOG_FILE="$ROOT_DIR/app.js.log"LOCK_FILE="/var/lock/subsys/node-server"do_start(){if [ ! -f "$LOCK_FILE" ] ; thenecho -n $"Starting $SERVER: "runuser -l "$USER" -c "$DAEMON $SERVER >> $LOG_FILE &" && echo_success || echo_failureRETVAL=$?echo[ $RETVAL -eq 0 ] && touch $LOCK_FILEelseecho "$SERVER is locked."RETVAL=1fi}do_stop(){echo -n $"Stopping $SERVER: "pid=`ps -aefw | grep "$DAEMON $SERVER" | grep -v " grep " | awk '{print $2}'`kill -9 $pid > /dev/null 2>&1 && echo_success || echo_failureRETVAL=$?echo[ $RETVAL -eq 0 ] && rm -f $LOCK_FILE}case "$1" instart)do_start;;stop)do_stop;;restart)do_stopdo_start;;*)echo "Usage: $0 {start|stop|restart}"RETVAL=1esacexit $RETVAL
You will have to adjust ROOT_DIR and node.js user to accommodate your situation and register the service with chkconfig.
Update:
As of nodejs release 0.8.8 usage of python26 on ./configure script is not enough anymore. In order to properly install you have to create PYTHON environment variable and point it to python26.
So instead of
1 2 |
# make >>../nodejs-build.log 2>&1 && make install |
It will have to be
1 2 |
# export PYTHON=python26 && make >>../nodejs-build.log 2>&1 && make install |
0 Comments.