Permalink
Browse files

Detailed installation instructions.

  • Loading branch information...
1 parent 6e504ee commit 570e6bdf01b43a00d2cf85c864796ed46f6a8344 @eee-c committed Jun 23, 2011
Showing with 139 additions and 0 deletions.
  1. +139 −0 INSTALL.md
View
@@ -0,0 +1,139 @@
+INSTALL express-spdy
+====================
+
+These instructions will install edge-openssl, edge-node.js and express-spdy in your home directory. This will *not* overwrite or affect any system libraries.
+
+I work with tarballs in `$HOME/src` and source code controlled code in `$HOME/repos`.
+
+Dependencies
+------------
+
+Dependencies are described for a vanilla Debian 64-bit system, but should work equally well for Ubuntu. It should be relatively easy to extrapolate dependencies for OSX.
+
+If not already installed, you need:
+
+* C and C++ compilers for openssl and node.js
+* Zlibh for SPDY compression
+* Git to obtain the latest node.js source
+* Python to configure node.js
+* Curl for installing the Node Package Manager (NPM)
+
+This can be accomplished on Debian / Ubuntu with:
+
+ sudo apt-get install build-essential zlib1g-dev git-core python curl
+
+Edge openssl
+------------
+
+SPDY requires Next Protocol Negotiation (NPN) extensions to work properly. This is only available in edge openssl. This can be obtained from the openssl CVS repository, but that would require installing CVS. It is easier to access the [openssl FTP server](ftp://ftp.openssl.org/snapshot/). Look for tar.gz files that begin with `openssl-SNAP-`. Following that prefix is a datestamp (the tarball from June 22 was `openssl-SNAP-20110622.tar.gz`). Unfortunately those tarballs are only available in a rolling 4 day window so permanent links are not possible.
+
+Once you have identified the correct openssl SNAP tarball, download and un-tar it in `$HOME/src`:
+
+ mkdir $HOME/src
+ cd $HOME/src
+ wget ftp://ftp.openssl.org/snapshot/openssl-SNAP-<datestamp>.tar.gz
+ tar zxf openssl-SNAP-<datestamp>.tar.gz
+ cd openssl-SNAP-<datestamp>
+
+Next configure openssl for your platform. For 32-bit linux, use:
+
+ ./Configure shared --prefix=$HOME/local no-idea no-mdc2 no-rc5 zlib enable-tlsext linux-elf
+
+If you are using 64-bit linux, replace `linux-elf` with `linux-x86_64`. If unsure what platform to use, run `./Configure` without any options to get a complete list.
+
+After configuring openssl, build and install it:
+
+ make depend
+ make
+ make install
+
+Edge node.js
+------------
+
+Install the source code in `$HOME/repos`:
+
+ mkdir $HOME/repos
+ cd $HOME/repos/
+ git clone https://github.com/joyent/node.git
+ cd node
+
+Configure node to use edge-openssl and to install locally:
+
+ ./configure --openssl-includes=$HOME/local/include --openssl-libpath=$HOME/local/lib --prefix=$HOME/local/node-v0.5.0-pre
+ make
+ make install
+
+Configure Bash to Use Edge openssl and node.js
+----------------------------------------------
+
+Add the following to $HOME/.bashrc:
+
+ # For locally installed binaries
+ export LD_LIBRARY_PATH=$HOME/local/lib
+ PATH=$HOME/local/bin:$PATH
+ PKG_CONFIG_PATH=$HOME/local/lib/pkgconfig
+ CPATH=$HOME/local/include
+ export MANPATH=$HOME/local/share/man:/usr/share/man
+
+ # For node.js work. For more info, see:
+ # http://blog.nodejs.org/2011/04/04/development-environment/
+ for i in $HOME/local/*; do
+ [ -d $i/bin ] && PATH="${i}/bin:${PATH}"
+ [ -d $i/sbin ] && PATH="${i}/sbin:${PATH}"
+ [ -d $i/include ] && CPATH="${i}/include:${CPATH}"
+ [ -d $i/lib ] && LD_LIBRARY_PATH="${i}/lib:${LD_LIBRARY_PATH}"
+ [ -d $i/lib/pkgconfig ] && PKG_CONFIG_PATH="${i}/lib/pkgconfig:${PKG_CONFIG_PATH}"
+ [ -d $i/share/man ] && MANPATH="${i}/share/man:${MANPATH}"
+ done
+
+Logout and log back in to ensure that your changes are applied correctly.
+
+Install NPM and Express.js
+--------------------------
+
+ curl http://npmjs.org/install.sh | sh
+ npm install -g express
+
+Create a Sample Express.js App to SPDY-ize
+------------------------------------------
+
+ cd $HOME/repos
+ express example-spdy
+ cd example-spdy
+ npm install express-spdy jade
+
+Copy SSL keys from node-spdy:
+
+ mkdir keys
+ cp node_modules/express-spdy/node_modules/spdy/keys/spdy* keys/
+
+Edit `app.js`. Replace the following at the top of the generated code:
+
+ var express = require('express');
+
+ var app = module.exports = express.createServer();
+
+Replacing it with:
+
+ var express = require('express-spdy')
+ , fs = require('fs');
+
+ var app = module.exports = express.createServer({
+ key: fs.readFileSync(__dirname + '/keys/spdy-key.pem'),
+ cert: fs.readFileSync(__dirname + '/keys/spdy-cert.pem'),
+ ca: fs.readFileSync(__dirname + '/keys/spdy-csr.pem'),
+ NPNProtocols: ['spdy/2']
+ });
+
+Run the Sample App
+------------------
+
+ node app.js
+
+If all has worked, you should see:
+
+ Express server listening on port 3000 in development mode
+
+And you should be able to access the SPDY-ized site at: https://localhost:3000 (proceed past certificate warnings).
+
+To verify that you are seeing a SPDY session and not just a plain-old HTTP session, checkout the SPDY tab in Chrome's `about:net-internals`.

0 comments on commit 570e6bd

Please sign in to comment.