by oneafrikan on June 16, 2006
If you’ve been reading this blog you’ll know that I’ve been through an IBM T42p Thinkpad nightmare, where I pretty much ended up with a new hard drive (not out of the woods yet – another month of smooth operations and I’ll be happy), so I lost my laptop development environment, and had to go back to my Dell desktop to get client work done.
Anyhoo – I’ve just set up Apache2 on the laptop now, so I can carry on working on it as per normal, and have everything the way it was configured before, on the desktop, and for client work.
My environment is that I’m either at my office where I run a 192.168.0.x network off a Netgear router, so development machines are either local, or assigned by IP address. I don’t like fixing my IP address in Apache ‘cos I’m often at client sites and their networks are all configured differently – good old localhost is the lowest common denominator and it works for me.
So, when I start a project, I set up and configure a new virtual host in Apache’s httpd.conf file, and get started – that way I’m almost always ensured of a smoother transition to the production server. It’s the difference between http://localhost/2006/client/project-name/httpdocs/ and http://project-name/…
So here are the basic steps to follow:
Most web hosts will be running Apache version 2.x.x on their Linux servers, and since itâ€™s generally a good idea to run the same software versions in your development environment as your production environment, install Apache2 as a service on your local Windows machine for local development.
The first step is to head over to the Apache HTTP Server Project web site and download the same version that your web host has deployed. In my case, my web host is running version 2.0.46, so we went to the distribution archive and found the Win32-x86 no src version (which uses a Windows MSI installer).
Once youâ€™ve downloaded the file, double click to run the installer, accepting the terms in the license agreement and following the instructions. I chose to do a stock standard â€œTypicalâ€ installation as that is what most people need. There are however various machine port issues that may prevent the installation from going smoothly.
If youâ€™re running Skype, you should quit Skype before running the Apache installation as it seems to watch port 80 on your machine, which prevents Apache from installing as a service correctly. You’re probably going to get an error something like:
< OS 10048 > Only one usage of each socket address
Unable to open logs.
So that’s the first thing to check. You could also open up the command prompt, and also do a â€œnetstat â€“a â€“nâ€ to find out what services or apps are watching which ports.
Once youâ€™ve completed that, you should be able to open up your browser and either type in http://127.0.0.1/ or http://localhost/ to get the default Apache welcome page. From there onwards, you can either use the default directory structure found in Apache on Windows, or you can point Apache to another directory on your machine so that you can better manage your files. I don’t like doing the default structure thing, so I have a folder on my C drive called, surprisingly, “www”…
Once youâ€™ve got Apache pointing to your web files, youâ€™re probably going to want to separate different projects from each other, so that instead of http://localhost/client-name/project-name/httpdocs/ you can set up something like http://project-name/ as a virtual server, and do that for each project. When you set up the virtual server, make sure that NameVirtualHost is set to â€œ*â€ and that in each Virtual Server config, the VirtualHost is set to â€œ*â€. The only other thing to do is make sure that your HOSTS file has an entry for the above virtual host as well, otherwise try as you might, it just won’t work.
And that’s about it ;-)
I’ve taken my Apache httpd.conf file and stripped it down so that it’s easier to edit – you can download for your perusal here.