- I've recently been introduced to jQuery which is an insanely powerful improvement over the javascript I became familiar with in highschool... like 10 years ago.
- The idea that I can use my (MVC) Model on the server and client side seems pretty elegant. I'd be able to send objects back and forth using AJAX without having two different implementations of the objects.
- The server-side javascript project that sparked my interest, node.js, just looks so easy. Building a web service should take no time at all and deploying the web service looks even easier. You just call:
node myjavascriptfile.js
Unfortunately, installing all of this was more difficult than I had hoped for, especially because I'm developing on a Windows XP laptop and node.js currently only works in Linux. Fortunately, there are two tutorials that have been written for this exact situation, one for getting node.js onto an Ubuntu VM and another for installing DBSlayer on that same VM. But though these tutorials are pretty good, they didn't work perfectly for me. I'll go over the problems I ran into along the way in hopes that someone (possibly my future self) can benefit from the added tips.
A quick note: I'm relatively new to VirtualBox so I made one awkward mistake that must be quite common. I left my virtual Ubuntu installation CD in my virtual CD drive! If it looks like your virtual drive is not being fully used and it says your 3.1GB drive is full when you have a bigger than 3.1G drive then you've probably made a similar mistake. Took me 2 hours to figure that one out. I guess I should consider myself lucky.
The first problem with the first tutorial that I ran into involved OpenSSL. Along with the other few apt-get installs I needed to do a:
sudo apt-get install libssl-dev
When validating my node.js install using the helloworld.js described in the first tutorial, the script didn't work. The error I saw was:
/home/amcknight/node/helloworld.js:4
res.sendHeader(200, {'Content-Type': 'text/html'});
^
TypeError: Object #<a ServerResponse> has no method 'sendHeader'
at Server.
at Server.emit (events:27:15)
at HTTPParser.onIncoming (http:885:14)
at HTTPParser.onHeadersComplete (http:88:31)
at Stream.ondata (http:806:22)
at IOWatcher.callback (net:499:29)
at node.js:604:9
Instead I used the first hello world code shown on the node.js front page and everything worked out fine.
As for the second part of the tutorial for installing dbslayer, I recommend running
sudo apt-get update
first to avoid any errors.The error I was getting involved not being able to find a libapr-1.so.0 file. I'm not sure what exactly resolved this problem for me but I eventually started over (and found those two tutorials) and the only difference I can think of is that I used the apt-get update command and installed libssl-dev the second time around. So unfortunately I can't pinpoint the cause, but if it ever happens to me again I'll post a comment about it (or you can).
Other than that, the tutorial should work fine if you fingers are tightly crossed.
Ultimately, these are the relevant commands I ran, in order, and not including the validation steps that are explained on the two tutorial pages. From a clean install of Ubuntu 10.04, taking the steps below should get you up and running.
sudo apt-get install git-core
git clone git://github.com/ry/node.git
sudo apt-get install libssl-dev
cd node
./configure
make
sudo make install
cd ..
sudo apt-get install subversion
svn co http://www.dbslayer.org/svn/dbslayer/trunk
dbslayer
sudo apt-get update
sudo apt-get install libapr1-dev
sudo apt-get install libaprutil1-dev
sudo apt-get install libmysqlclient-dev
cd dbslayer
./configure
make
sudo make install
sudo apt-get install mysql-server
dbslayer -s localhost -u root -x YOUR_PASSWORD -c void