Building a working web service in 24 hours – straight


Happy business campers!

It’s the middle of the night and I’m in a big hallroom full of people all of them hacking on their computers.

The event is called 24 hours Business Camp and the goal is to bring 90 entrepreneurial people together and have them build a service in 24 hours.

There are 52 teams (although it’s not a contest, there’s no winner) and the ideas are ranging from tampon subscriptions to Youtube wrappers.

Building a service in such an extremely short timespan has been (is, there’s still 9 hours left!) a learning experience, primarly about the importance of focusing on what’s really important.

A little too tired to write anything more right now but let’s just say that without my framework of choice, JBoss Seam, I wouldn’t have been as productive as I have been. A couple of hours have been lost doing stuff like configuring Apache proxies on my server or fixing Hibernate errors. Still, it’s really amazing how much you can do with all the frameworks and open APIs out there. Everything is in turbo speed compared to a couple of years ago.

But now I should get some sleep.

Standard

Copying a VirtualBox VDI file running Ubuntu Server and getting Drupal running

Sigh. Things are never as easy as you want them to be. šŸ™‚

I have two computers on my desk. My MacBook and my Asus EEE B202 running Windows XP. I wanted a development environment for Drupal (a php content management framework), so I tried running PHP on my MacBook.

It worked fine, but the first problem appeared when I tried to run Drupal. The PHP GD library was missing (used by Drupal for graphics). This is a known problem and requires a recompilation of PHP. The problem is, the Apache web server installed on the MacBook is used by OS X and may change in future updates to the OS by Apple. It also seemed a bit cumbersome to get it all to work as it should. So, I figured, why not in stead run a virtual machine with a developer setup in linux and get a clean separation between my day to day OS (OS X) and my developer server.

I decided to use VirtualBox, a free software provided by Sun, and run it on my XP machine (the B202). I installed Ubuntu Server 8.10 on the virtual machine.

If you haven’t used a software like VirtualBox or VMWare before, I can only say that it’s much easier than it sounds like. If you can install an operating system you can use VirtualBox. It’s a very slick and easy to use program.

But, there are of course a few problems.

The first problem was that Ubuntu Server was also missing PHP GD (not because of VirtualBox of course, but still). This time I only needed to do a:

apt-get install php5-gd

and voila, Drupal was running.

Now everything should have been fine and dandy if it hadn’t been for the bluescreens that suddenly started to occur on my EEE-box. After running VirtualBox and Ubuntu Server for a couple of minutes, maybe half an hour, XP decides to just crash. This happened over and over again.

Finding the cause of a bluescreen is never fun but it was clearly due to the VirtualBox setup.

But, hey, I’m in the virtual world here. So, I simply copied the .vdi-file (the file that VirtualBox uses to store the operating system on – it’s like a virtual hard drive) to my MacBook and set up a virtual machine with the vdi-file.

Everything worked as it should, except networking (I’m using hosted networking, making the virutal machine appear just like a third computer on my network – very neat, when it works).

The problem is that, although the environments are similar, the virtual network adapter gets a new MAC address. So, the Ubuntu OS gets confused and can’t find the network adapter. This is easily fixed by simply deleting an autogenerated file:

rm /etc/udev/rules.d/70-persistent-net.rules

and rebooting.

Now I have Ubuntu Server 8.10 running on my MacBook. I don’t have any desktop environment set up, making it rather slim (I use 384MB RAM and the full OS only takes about 1,5GB hard drive space). You probably want something like Webmin to make configuration a bit simpler. Here are instructions for setting it up.

Now, let’s just hope my MacBook doesn’t bluescreen.

Standard

Setting up PHP and web server on OS X 10.5 (Leopard)

Your shiny Mac comes preinstalled with a web server and php but you need to set it up to get going. Starting the web server is as easy as enabling “Web Sharing” under networks settings. I did this but the server did not respond at http://localhost. So, what was wrong?

Well, I recently upgraded my hard drive to a 500GB version and I used Time Machine to restore my operating system. The problem is that this is not a clone of my previous setup but a copy and it leaves out certain files that Time Machine ignores to save space. One of those folders is the apache web server log folder which is required by apache at startup. Unfortunately OS X doesn’t tell you anything about this error when you enable Web Sharing, it just doesn’t work.

Anyhow, simply create the folder:

sudo mkdir /private/var/log/apache2

and you’re good to go. You might have to disable and enable Web Sharing again to restart the process.

So, now the web server is running. What about php? Edit the apache config file located at /etc/apache2/httpd.conf and remove the ‘#’ (comment) from the line that says:

LoadModule php5_module

Now you can test that it works by adding a file called helloworld.php to the folder /Library/WebServer/Documents. Add the following code snippet to the file:


< ?php echo 'Hello World!'; ?>

And point a browser to http://localhost/helloworld.php. Now three things can happen. 1) no response. Did you restart the server? 2) The exact content of the file is shown in the browser. This means the PHP module is not loaded. Make sure the httpd.conf file has the comment character removed as described above and then restart the web server by disabling and then enabling web sharing again. 3) Hello World! (and nothing else) is printed in the browser. Success!

The next step is probably to set up MySQL. Here are some resources for doing that. Good luck and happy PHP hacking.

Standard