Archive for the 'Apache' Category

Configuring Apache 2.0.X on Windows

Thursday, January 31st, 2008

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

  1. Configuration changes only take hold after you restart Apache.
  2. 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
  3. There is a link to the main configuration file in Start->Programs->Apache HTTP Server 2.0->Configure Apache Server
  4. 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.

Installing Apache 2.0.X on Windows

Thursday, January 31st, 2008

Here’s a quick and dirty out of the box way of getting Apache 2.0.x running on windows.

  1. First, let’s go to http://httpd.apache.org
  2. Next, find the version you want (in this case 2.0.63) and clickdownload
  3. On the download screen you have two choices for Windows. Win32 with SSL or Win32 without SSL. Choose with OpenSSL since you might at one time in the future want to use SSL certificates for encryption.
  4. Ok, since we’re using 2.0.63 click on apache_2.0.63-win32-x86-openssl-0.9.7m.msi and download it
  5. Open the file by double-clicking on it.
  6. ap-inst1.JPG
    Click NEXT
  7. ap-inst2.JPG
    Select”I accept” and click NEXT
  8. ap-inst3.JPG
    Click NEXT
  9. ap-inst4.JPG
    In the server information you will the basics for your site. You can easily change these later. When finished, click NEXT

    • Network domain is the hostname of your site.
    • Server name is the website. Usually www.
    • Administrators email is where email should be directed if there’s a problem or question
    • You can run Apache on ANY port and ANY ip address, but the default port that all webbrowers know about is port 80. So choose this.
  10. ap-inst5.JPG
    Choose typical and click NEXT
  11. ap-inst6.JPG
    Click NEXT
  12. ap-inst7.JPG
    Click INSTALL
  13. ap-inst8.JPG
    Click FINISH

And that’s it! You’ve installed Apache! Congrats. Now, open your webbrowser and test it out by going to: http://localhost

ap-inst9.JPG

Why Apache webserver?

Thursday, January 31st, 2008

Even if you’re running windows as your hosting platform, I’ve always like Apache as webserver for the pure reason that it’s incredibly flexible and powerful. Granted IIS is as well but I’ve spent the majority of my time on configuring and stabilizing Apache so that’s what I will focus on in these articles. Also if you learn to configure and work with Apache, you will have an easier time in the future if you switch to a non-windows platform such as RedHat Linux.

Apache is a key ingredient in configuring your hosting platform.  It will serve up pages from your domains and will allow you to build dynamic sites.  Out of the box it will let you password protect directories, setup virtual hosts, specify multiple paths, etc. There are hundreds of plugins for it allowing for different languages such as Java/PHP/Python/Perl and even .NET applications to run on it. You can use Apache as proxy for web surfing as well. So, that’s why in a nutshell I lean toward Apache as a webserver.