What’s Behind an Apache Web Site?

It might be a good idea to get a firm idea of what, in the Apache business, a web site is: it is a directory somewhere on the server, say, /usr/www/APACHE3/site.for_instance. It usually contains at least four subdirectories. The first three are essential:

conf

Contains the Config file, usually httpd.conf, which tells Apache how to respond to different kinds of requests.

htdocs

Contains the documents, images, data, and so forth that you want to serve up to your clients.

logs

Contains the log files that record what happened. You should consult .../logs/error_log whenever anything fails to work as expected.

cgi-bin

Contains any CGI scripts that are needed. If you don’t use scripts, you don’t need the directory.

In our standard installation, there will also be a file go in the site directory, which contains a script for starting Apache.

Nothing happens until you start Apache. In this example, you do it from the command line. If your computer experience so far has been entirely with Windows or other Graphical User Interfaces (GUIs), you may find the command line rather stark and intimidating to begin with. However, it offers a great deal of flexibility and something which is often impossible through a GUI: the ability to write scripts (Unix) or batch files (Win32) to automate the executables you want to run and the inputs they need, as we shall see later.

Get Apache: The Definitive Guide, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.