<<

. 48
( 69 .)



>>


The directives in the table below are some of the most want it to work. Most, if not all, of these reside in your
critical in setting up your Web site in the way that you httpd.conf file, though some appear in comment lines.


OPTION DESCRIPTION
Specifies options, such as whether directory browsing is enabled
Options
<Directory name> and </Directory> Block directive for handling a specific directory
Lists default documents, like index.html
DirectoryIndex
Specifies directory where Web pages reside
DocumentRoot
Specifies log directory relative to ServerRoot
ErrorLog
Specifies whether reverse lookups should be performed
HostnameLookups
Determines whether sessions endure beyond the first request
KeepAlive
Specifies port that server listens on, usually port 80
Listen
Defines content for the access log file
LogFormat
Determines what level errors should be logged
LogLevel
Sets a limit on the number of simultaneous connections
MaxClients
Connects a virtual name such as /cgi-bin/ with an actually directory
ScriptAlias
Provides e-mail address of Web site admin
ServerAdmin
Identifies directory containing your Web pages
ServerRoot
Determines how many server processes run when the server starts
StartServers
Determines how many threads a single process may support
StartThreads
Limits time that an inactive session is maintained
Timeout
Specifies userid under which Web processes run
User nobody
Identifies directory name that is used for personal Web sites
UserDir
<VirtualHost pattern> ... </VirtualHost> Block directive for virtual hosts


233
UNIX FOR MAC



SET UP YOUR DOCUMENT DIRECTORY
If your default document contains references to other files,

Y
ou can build a simple site using a single directory, or
such as image files, the links in your document must
organize your Web pages using a series of directories.
correspond to the directory structure that you create. For
The document directory or document root that you
example, if you refer to an image called mylogo.gif that
set up for your Apache server holds all the files that are part
resides in the images directory within your document
of your site. These files can all reside in the directory that
directory, you must refer to this file as images/mylogo.gif.
you assign to the DocumentRoot directive, or you can,
instead, divide your files into a series of directories to make
Your default document, index.html, not only has relevance
them easier to organize. For example, if you use a lot of
to your document root, but it also plays a role in every
image files, you may want to keep these in a separate images
directory that you create. Any time a visitor types in a URL
directory apart from your HTML files. Most people find that
ending in a directory name, your Web server attempts to
it is distracting to have hundreds of files in a single directory.
send back a default document from that directory. If it
does not find one, it returns a directory listing or an error,
The single point of entry for most visitors to your site is the
depending on whether you have disabled directory
page that you set up as your default document, assigned to
browsing.
the DirectoryIndex directive in your configuration file.
Called index.html by default, this is the document that your
Web server sends to visitors whenever they type your URL
into their browsers.

SET UP YOUR DOCUMENT DIRECTORY




‹ Type ls “l and press ‹ If there is a prompt, type
DISPLAY CONTENTS OF YOUR CREATE A DIRECTORY
DOCUMENT DIRECTORY FOR YOUR IMAGE FILES
Return. your password, and press
„ Type cd followed by a „ Type sudo mkdir followed Return.
– The contents of your
space. by a space. – The system creates a
document directory appear.
¤ Type the name of your ¤ Type images and press directory for your image files.
document directory, and Return.
press Return.

234
14
SERVE WEB PAGES WITH APACHE




CREATE A SIMPLE WEB SITE
Web pages must have the extension .html or .htm, and

Y
ou can create a simple Web site in less than an hour.
must start with a tag, <html>, that identifies the content as
After you install Apache on your system, you can
HTML. Most formatting commands in HTML have both an
create a Web site by using a text editor to enter text
opening and a closing tag. For example, you start a Web
and a few formatting commands, and by copying image files
page by typing the opening tag <html> and end it by typing
as you need them.
the closing tag </html>. All closing tags in HTML follow the
convention of starting with a forward slash (/).
Static Web pages contain special formatting commands in a
language called HTML, along with the text or content of your
The simplest Web page, therefore, starts with <html>,
pages. For example, if you create a Web site that you want to
contains text, and <p> markers to indicate paragraph
call My Life Story in 50 Words or Less, you can enter your
breaks, and ends with </html>. A document as simple as
title and your text and then proceed to insert the commands
this can constitute a Web site. There is no requirement that
necessary to display the content as you want it to appear.
you insert images or links that point to other sites, or other
pages in your own Web site.
If you type multiple paragraphs into your Web document
without HTML formatting, the text that appears in a
browser looks like a single long paragraph. To break this
text into separate paragraphs, you must insert an HTML tag,
<p>, in between your paragraphs.

CREATE A SIMPLE WEB SITE




– Your new home page
„ Start Pico by typing ‹ Type a line of text, and „ Open Internet Explorer
press Return. from the Dock. appears.
sudo pico /sw/apache/htdocs/
index.html replacing the path
› Type </html> and press ¤ Type http://localhost
with your document root
Return. /index.html into your URL
directory.
field, and press Return.
ˇ Save your text, and exit
¤ Type <html> and press
Pico.
Return.
– Your new home page is
created. 235
UNIX FOR MAC



INTRODUCTION TO HTML
In some cases, you do not require tag pairs to format the

Y
ou can create Web pages using the most basic HTML
text you want to change, but it is considered good form to
markup code. While you can use the HTML language
use them. For example, if you mark the beginning of a
to create extremely complex and extensive Web
paragraph by inserting <p>, you should also mark the end
pages, you can also create attractive and functional pages
of the paragraph with </p>. Similarly, list items should
by inserting a few simple HTML tags into your documents.
begin with <li> and end with </li>.
These tags allow you to change the font of selected text,
making it bold or turning it into a heading that stands out.
To insert an image into your Web page, you can use the
They allow you to insert images, build tables, and insert
<img src=url> command. In the simplest form, this
links to other pages on your site or to other Web sites. You
command provides the location of an image file that you
can also mark selected text as preformatted so that Apache
want to display within your Web page. However, you can
does not wrap the text lines together.
also specify additional commands to control the size and
placing of the image.
Most HTML tags come in pairs. That is, there is an open tag
as well as a close tag. For example, if you want to underline
To add a link to another page or Web site, you can insert a
a phrase in your document, you indicate the text you want
command such as <a
to underline by inserting <ul> where the underlining
href="http://www.idyllmtn.com">click
should start, and </ul> where it should end.
here</a>.



INTRODUCTION TO HTML




– Pico opens with your ‹ Type <p> and press
ADD AN IMAGE TO
YOUR WEB PAGE current Web page. Return.
„ Type sudo pico ¤ Position your cursor at the › Type another line of text,
/sw/apache/htdocs/index.html end of a line of text, and and press Return.
and press Return. press Return.



236
14
SERVE WEB PAGES WITH APACHE


The most fundamental HTML tags should enable you to construct a basic Web page.

TAG(S) DESCRIPTION
<html> and </html> Start and end of HTML formatting
<head> and </head> Start and end of header
<title> and </title> Start and end of title, often displayed in browser title bar
<body> and </body> Start and end of body
<p> and </p> Start and end of a paragraph
Insertion of a line break
<br>
<a> and </a> Start and end of a link definition
<h?> and </h?> Start and end of a heading, where ? is a number between 1 and 9
<li> and </li> Start and end of an individual item in a list
Image insertion, where ? is the location and name of an image
<img src="?">
<table> and </table> Start and end of a table
<tr> and </tr> Start and end of a row in a table
<td> and </td> Start and end of a cell in a table
<th> and </th> Start and end of a column header




– Your home page appears,
ˇ Type <img src=" followed ‡ Save your text, and exit TEST YOUR WEB PAGE
by the name of an image file Pico. complete with image and
„ Open Internet Explorer
in your documents folder or link.
– Your Web page now from the Dock.
images directory.
– Clicking the image takes
contains a link to an image.
¤ Type http://localhost into
Á Type width= followed by a you to the Idyll Mountain
your URL field, and press
number and height= followed Web site.
Return.
by a number to control the
size of your image. Then
237
type "> and press Return.
UNIX FOR MAC



<<

. 48
( 69 .)



>>