You should be already used to my religious prototyping habits – I tend to try out a lot of stuff, build a lot of things that I later discard and so on.
Knowing that I do this a lot, I tend to actively look for tools that are either very easy to set up or that don’t even have an install footprint. Last year (I think) I found Mongoose, and used it to replace my normal prototyping instance – an Apache instance that I had running all the time on my dev machine.
Mongoose turned out to be the best choice, being just an executable (small – in the hundreds of kilo range) that you can run to get an instant web server, serving files from any folder.
Well, tonight I got my revenge. I needed some dynamic calls to test a RESTful API, and because my API builder is not ready yet I had to resort to some fast PHP hacking.
As my new home dev machine is not fully configured yet and I had no Apache installed and configured I thought what the hell, how’s about trying to hook up the Mongoose CGI. I knew it had support for it but I never tried it before, until now.
So, without further a due, I present the fastest setup for a prototyping web stack (on Windows) ever:
1. Create a folder – duh
2. Get the latest Mongoose binary from http://code.google.com/p/mongoose/downloads/list and copy it to the folder
3. Get the latest PHP zip distribution from http://windows.php.net/download/, unzip it and copy the php support files for CGI to the folder (php-cgi.exe, php5.dll and php.ini are enough)
4. Create a mongoose.conf file with the following lines:
listening_ports 80 document_root . cgi_pattern **.php$ cgi_interpreter .\php-cgi.exe
5. Run the Mongoose binary (I usually rename mine to mng.exe) and access it with your favorite browser
And that’s it, you now have a web server and PHP configured, all under 5 minutes. Enjoy!
You should only use this for prototyping stuff – NOT FOR ANYTHING SERIOUS LIKE A PRODUCTION OR CLIENT-ACCESSIBLE INSTANCE!