As I said earlier, Apache Server is almost infinitely configurable, which is one of the reasons why it is far and away the most popular server in use today.
Apache starts out with all it’s configuration information stored in one file: httpd.conf, which is located in the conf folder inside the main (Apache2.2) folder. If you’re thinking about making a back-up copy before you change anything, that’s good thinking but it’s a belt & suspenders approach: there already is a copy of the original in the conf/default folder, entitled httpd-default.conf.
A decision you’ll have to make (some day) is whether to keep all the configuration info in one big file, or parcel it out into smaller chunks. I chose to start separate config files for specific chores, rather than dump everything into one big file, but that’s a personal choice. I think a good argument could be made either way when you’re just starting out – it’s only when your configuration issues get really large and complicated that you would really need separate files. At any rate, I’ll show how to make and include separate configuration files when we get to the Virtual Hosting section of these config files.
Before we jump into things, let’s talk about resources. The Internet offers almost infinite help – if you can find it. Your best resource, however, is installed in the Apache2.2 folder – the Apache Manual. Any time you need it, just type “http://localhost/manual” into your browser and help is on hand immediately.
The two things most folks usually want to do fairly quickly is activate SSI and change where their root directory is located. Because I want to explain more completely what SSI (Server Side Includes) are and how to use them, I’ve done a separate section on them. Here I’ll show how to change the name and location of your root directory.
Assuming you want a change, the first thing you need to decide is where you want the root file to be. And, if you want to change it’s name, what the new name will be. Then create a folder in that location, named for your new root directory. To clarify (and for instructional purposes) let’s assume you want the root folder to be on drive F:, where you do all your web development. Let’s also assume that you’re happy with Apache’s default names. You’d then create a folder on drive F: named “localhost” (Apache’s default name for your website) and in that folder you’d create a folder named “htdocs“. You will need an “index.html” file in that folder: create your own or copy the one from Apache’s default htdocs folder.
Now you’ll need a text editor. You can use Window’s default text editor Notepad, but we highly recommend you download and use a superior free text editor named Notepad++ or, equally as good, PSPad.
To start our changes, use a your text editor to open the httpd.conf file. We will change 3 lines in this file.
First, find the line that starts with DocumentRoot. It should be about line 149 and will probably look something like this:
DocumentRoot “C:/Program Files/Apache Group/Apache2_2/htdocs”.
You want to comment out that line – that is put an pound sign (this thing: #, aka a hash mark or an octalthorpe) in front of it so it looks like this: #DocumentRoot “C:/Program Files/Apache Group/Apache2_2/htdocs” – and right below it you want to type in your new address. What you wind up with should look something like this:
#DocumentRoot “C:/Program Files/Apache Group/Apache2_2/htdocs”
DocumentRoot “F:/localhost/htdocs”
Next, find the line that starts with <Directory “C:/Program… (probably about line 177), comment it out and add another with your directory. You should wind up with something that looks like this:
#<Directory “C:/Program Files/Apache Group/Apache2_2/htdocs”>
<Directory “F:/localhost/htdocs”>
Finally, about 20 lines below that <Directory line (line 198 in my file), there is a line that reads:
AllowOverride None
Change it to:
AllowOverride All
This last change I’m not too positive about; that is, I don’t really know the reason for it. But it was suggested in a couple of the tutorials I read, so here it is.
That’s it. Save the httpd.conf file and reset Apache (see the note below) so the changed configuration file takes effect. If Apache restarts successfully, you’ve edited the file correctly. You can then type “http://localhost/” in your browser’s address bar and you should see the contents of the index.html file in your new location.
Note: To reset Apache, click on the Apache icon in your taskbar and choose “Restart.” Or, go to: Start Menu > All Programs > Apache HTTP Server 2.2.4 > Control Apache Server and click on Restart.