Compilación de nodeJS sobre Oracle Solaris 11

Page last edited hace 2117 días 3 horas
De Solaris-ES
Saltar a: navegación, buscar

Librerias necesarias en el sistema[editar]

root@sol11:~# pkg list *gcc*
NAME (PUBLISHER)                                  VERSION                    IFO
developer/gcc-3                                   3.4.3-0.175.0.0.0.2.537    i--
system/library/gcc-3-runtime                      3.4.3-0.175.0.0.0.2.537    i--
system/library/gcc-45-runtime                     4.5.2-0.175.0.0.0.2.537    i--

root@sol11:~# pkg list *make*
NAME (PUBLISHER)                                  VERSION                    IFO
developer/build/gnu-make                          3.81-0.175.0.0.0.2.537     i--
developer/build/make                              0.5.11-0.174.0.0.0.0.0     i--

root@sol11:~# pkg list *header*
NAME (PUBLISHER)                                  VERSION                    IFO
system/header                                     0.5.11-0.175.0.9.0.4.1     i--

root@sol11:~# pkg list *python*
NAME (PUBLISHER)                                  VERSION                    IFO
runtime/python-26                                 2.6.4-0.175.0.0.0.2.537    i--


Bajamos de github la ultima version de nodeJS[editar]

root@sol11:/var/tmp# git clone https://github.com/joyent/node.git
Cloning into node...
remote: Counting objects: 77341, done.
remote: Compressing objects: 100% (20059/20059), done.
remote: Total 77341 (delta 60814), reused 71985 (delta 56183)
Receiving objects: 100% (77341/77341), 52.60 MiB | 306 KiB/s, done.
Resolving deltas: 100% (60814/60814), done.
root@sol11:/var/tmp# cd node
root@sol11:/var/tmp/node# git checkout v0.6.18
Note: checking out 'v0.6.18'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

HEAD is now at 4bc1d39... 2012.05.15 Version 0.6.18 (stable)

Compilacion de nodeJS[editar]

root@sol11:/var/tmp/node# ./configure
Checking for program g++ or c++          : not found 
Checking for program c++                 : not found 
/var/tmp/node/wscript:273: error: could not configure a cxx compiler!

Declaracion del environment para la compilacion[editar]

root@sol11:/var/tmp/node# export PYTHON=`which python`
root@sol11:~# echo $PATH        --> /opt/solarisstudio12.3/bin:/usr/bin:/usr/sbin
root@sol11:/var/tmp/node# export PATH=$PATH:/usr/sfw/bin:/usr/xpg4/bin:/usr/gnu/bin
root@sol11:~# echo $PATH    --> /opt/solarisstudio12.3/bin:/usr/bin:/usr/sbin:/usr/sfw/bin:/usr/xpg4/bin

Inicio de la configuracion y compilacion[editar]

root@sol11:/var/tmp/node# ./configure --prefix=/usr/gnu
Checking for program g++ or c++          : /usr/sfw/bin/g++ 
Checking for program cpp                 : /usr/sfw/bin/cpp 
Checking for program ar                  : /usr/bin/ar 
Checking for program ranlib              : /usr/bin/ranlib 
Checking for g++                         : ok  
Checking for program gcc or cc           : /usr/sfw/bin/gcc 
Checking for program ar                  : /usr/bin/ar 
Checking for program ranlib              : /usr/bin/ranlib 
Checking for gcc                         : ok  
Checking for library dl                  : yes 
Checking for openssl                     : not found 
Checking for function SSL_library_init   : yes 
Checking for header openssl/crypto.h     : yes 
Checking for library util                : not found 
Checking for library rt                  : yes 
Checking for ifaddrs on solaris          : yes 
Checking for library socket              : yes 
Checking for library nsl                 : yes 
Checking for library kstat               : yes 
Checking for fdatasync(2) with c++       : yes 
'configure' finished successfully (0.805s)
root@sol11:/var/tmp/node# gmake
Waf: Entering directory `/var/tmp/node/out'
DEST_OS: sunos
DEST_CPU: ia32
Parallel Jobs: 1
...
Waf: Leaving directory `/var/tmp/node/out'
'build' finished successfully (4m51.558s)
-rwxr-xr-x   1 root     root        8.7M Aug  1 14:23 out/Release/node


root@sol11:/var/tmp/node# gmake install
Waf: Entering directory `/var/tmp/node/out'
DEST_OS: sunos
DEST_CPU: ia32
Parallel Jobs: 1
Product type: program
...
* symlink /tmp/nodeJS/bin/npm (-> ../lib/node_modules/npm/bin/npm-cli.js)
* installing out/Release/node as /tmp/nodeJS/bin/node
* installing out/Release/src/node_config.h as /tmp/nodeJS/include/node/node_config.h
Waf: Leaving directory `/var/tmp/node/out'
'install' finished successfully (0.783s)
root@sol11:~# node --version
v0.6.18

Prueba de fincionalidad[editar]

Nota: This simple web server written in Node responds with "Hello World" for every 

Ejemplo 1[editar]

Server[editar]

root@sol11:~# cd /tmp
root@sol11:/tmp# vi server.js
#!/usr/gnu/bin/node

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
root@sol11:/tmp# chmod 755 server.js
root@sol11:/tmp# ./server.js
Server running at http://127.0.0.1:1337/

Cliente[editar]

root@sol11:/var/tmp/node# wget 127.0.0.1:1337
--2012-08-01 14:50:22--  http://127.0.0.1:1337/
Connecting to 127.0.0.1:1337... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/plain]
Saving to: `index.html'

    [ <=>                                                                                       ] 12          --.-K/s   in 0s      

2012-08-01 14:50:22 (1.09 MB/s) - `index.html' saved [12]
root@sol11:/var/tmp/node# more index.html 
Hello World

Ejemplo 2[editar]

Server[editar]

root@sol11:/tmp# vi server2.js
#!/usr/gnu/bin/node
var net = require('net');

var server = net.createServer(function (socket) {
  socket.write('Echo server\r\n');
  socket.pipe(socket);
});

server.listen(1337, '127.0.0.1');

Cliente[editar]

root@sol11:/var/tmp/node# telnet 127.0.0.1 1337
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
Echo server
Hola
Hola
123
123
Connection to 127.0.0.1 closed by foreign host.


Paquete precompilado[editar]

NodeJS.0.8.4-OSolaris11-x86-local.gz for Oracle Solaris 11 x86