Configuring Apache 2.0.X on Windows
In my last article we talked about installing the Apache server on windows. Now let’s talk about configuring it and making use of it.
Now, by default, if you followed my directions before, you should have a directory on your computer called: C:/Program Files/Apache Group/Apache2/htdocs . This is where your current website (www.mydomain.com) lives. Any files you place in here will appear if you go to this site.
A couple of key things to remember before we continue
- Configuration changes only take hold after you restart Apache.
- You can test a configuration change before you restart Apache by clicking on Start->Programs->Apache HTTP Server 2.0->Configure Apache Server->Test Configuration
- There is a link to the main configuration file in Start->Programs->Apache HTTP Server 2.0->Configure Apache Server
- You can Stop/Start and Restart Apache easily from the Start->Programs->Apache HTTP Server 2.0->Control Apache Server
Often, you will want to host multiple websites (or subdomains). I have found it easier to break them down by domains and or subdomains and that it’s easier if the web content was in a seperate folder away from Apache.
So the first thing I do is create a directory structure such as this:
C:\home
C:\home\webpub\ (this is where all sites will live)
C:\home\webpub\www.mydomain.com (this is where www.mydomain.com will live)
C:\home\logs\ (this is where your logs will live)
By doing the above we can then easily breakout log files and web content away from the apache directory so future changes won’t require moving files in and out of C:/Program Files/Apache Group/Apache2/htdocs (the default location)
So, now how do we tell Apache to get your (www.mydomain.com) website from the new directory C:\home\webpub\www.mydomain.com?It’s pretty straight forward.
First open the apache configuration file: httpd.conf
Find the line(s) that say C:/Program Files/Apache Group/Apache2/htdocs and replace them with C:\home\webpub\www.mydomain.com . Save the file and restart apache. That was it. Now, any files placed in C:\home\webpub\www.mydomain.com will appear on your site. Easy? Yes, yes it was.
Next, lets change the location of the log file. In apache you have 2 main types of logs. Access logs which will log all visitors coming to the apache server and Error logs which log any type of errors such as an invalid page, coding errors etc. Typically if someone tries to go to http://www.mydomain.com/madeuppage.html and madeuppage.html doesn’t exist, well then that error will get logged to the Error log.
So, for ease of use, let’s stick the access and error logs into c:\home\logs\
Open youre httpd.conf file and find the lines that say:
ErrorLog logs/error.log
CustomLog logs/access.log common
And change them to:
ErrorLog c:/home/logs/mydomain.com-error.log
CustomLog c:/home/logs/mydomain.com-access.log combined
This will tell apache that the logs are now called mydomain.com-error.log and mydomain.com-access.log and now live in c:/home/logs . The word combined at the end tell apache that it should use the combined format which logs more information (such as the webbrowser of the visitor). As usual, save and restart apache.
Leave a Reply
You must be logged in to post a comment.