By Ben Laurie, Peter Laurie
Book Price: $39.95 USD
£28.50 GBP
PDF Price: $31.99
Cover | Table of Contents | Colophon
<scheme>://<host>/<path>
http, meaning that the browser should use
HTTP (Hypertext
Transfer Protocol); <host> is
www.butterthlies.com ; and
<path> is /,
traditionally meaning the top page of the host. The <host> may contain
either an IP address or a name, which the browser will then convert
to an IP address. Using HTTP 1.1, your browser might send the
following request to the computer at that IP address:
GET / HTTP/1.1 Host: www.butterthlies.com
GET, but could equally be
PUT, POST,
DELETE, or CONNECT; the Uniform
Resource Identifier (URI) /; the version of the
protocol we are using; and a series of headers that modify the
request (in this case, a Host header, which is
used for name-based virtual hosting: see Chapter 4). It is then up to the web server running on
that host to make something of this message.
<scheme>://<host>/<path>
http, meaning that the browser should use
HTTP (Hypertext
Transfer Protocol); <host> is
www.butterthlies.com ; and
<path> is /,
traditionally meaning the top page of the host. The <host> may contain
either an IP address or a name, which the browser will then convert
to an IP address. Using HTTP 1.1, your browser might send the
following request to the computer at that IP address:
GET / HTTP/1.1 Host: www.butterthlies.com
GET, but could equally be
PUT, POST,
DELETE, or CONNECT; the Uniform
Resource Identifier (URI) /; the version of the
protocol we are using; and a series of headers that modify the
request (in this case, a Host header, which is
used for name-based virtual hosting: see Chapter 4). It is then up to the web server running on
that host to make something of this message.
//<user>:<password>@<host>:<port>/<url-path>
Some or all of the parts "<user>:<password>@", ":<password>",":<port>", and "/<url-path>" may be omitted. The scheme specific data start with a double slash "//" to indicate that it complies with the common Internet scheme syntax.
ping www.apache.org
Pinging www.apache.org [63.251.56.142] with 32 bytes of data: Reply from 63.251.56.142: bytes=32 time=278ms TTL=49 Reply from 63.251.56.142: bytes=32 time=620ms TTL=49 Reply from 63.251.56.142: bytes=32 time=285ms TTL=49 Reply from 63.251.56.142: bytes=32 time=290ms TTL=49 Ping statistics for 63.251.56.142:
Host header in HTTP
1.1 — to decide which virtual host is the target of this request.
The virtual host then looks at the path, which was handed to it in
the request, and reads that against its configuration to decide on
the appropriate response, which it then returns.
http://www.linux.org, and there are more than 160 different distributions from
which Linux can be obtained free or in prepackaged pay-for formats.
It is rather ominously described as a
"Unix-type" operating system, which
sometimes means that long-established Unix standards have been
"improved", not always in an
upwards direction.
http://httpd.apache.org/docs/windows.html.
http://httpd.apache.org/dist/httpd/binaries.)
|
aix
|
aux
|
beos
|
bs2000-osd
|
bsdi
|
|
darwin
|
dgux
|
digitalunix
|
freebsd
|
hpux
|
|
irix
|
linux
|
macosx
|
macosxserver
|
netbsd
|
|
netware
|
openbsd
|
os2
|
os390
|
osf1
|
|
qnx
|
reliantunix
|
rhapsody
|
sinix
|
solaris
|
|
sunos
|
./configure <other flags> --with_mpm=<name of MPM>
http://httpd.apache.org/docs-2.0/mpm.html and
http://httpd.apache.org/docs-2.0/misc/perf-tuning.html.
./configure --prefix=/usr/local
./configure --help | more
make
make install
http://www.microsoft.com/windows95/downloads/contents/WUAdminTools/S_WUNetworkingTools/W95Sockets2.
Be warned that the Dialup Networking 1.2 (MS DUN) updates include a
Winsock2 that is entirely insufficient, and the Winsock2 update must
be reinstalled after installing Windows 95 dialup networking. Windows
98, NT (Service Pack 3 or later), and 2000 users need to take no
special action; those versions provide Winsock2 as distributed.
http://www.apache.org/dist,
and click on the version you want, which will be in the form of a
self-installing .exe file (the
.exe extension is how you tell which one is the
Win32 Apache). Download it into, say, c:\temp,
and then run it from the Win32 Start menu's Run
option.
> cd c:\<apache directory> > dir
Volume in drive C has no label
Volume Serial Number is 294C-14EE
Directory of C:\apache
. <DIR> 21/05/98 7:27 .
.. <DIR> 21/05/98 7:27 ..
DEISL1 ISU 12,818 29/07/98 15:12 DeIsL1.isu
HTDOCS <DIR> 29/07/98 15:12 htdocs
MODULES <DIR> 29/07/98 15:12 modules
ICONS <DIR> 29/07/98 15:12 icons
LOGS <DIR> 29/07/98 15:12 logs
CONF <DIR> 29/07/98 15:12 conf
CGI-BIN <DIR> 29/07/98 15:12 cgi-bin
ABOUT_~1 12,921 15/07/98 13:31 ABOUT_APACHE
ANNOUN~1 3,090 18/07/98 23:50 Announcement
KEYS 22,763 15/07/98 13:31 KEYS
LICENSE 2,907 31/03/98 13:52 LICENSE
APACHE EXE 3,072 19/07/98 11:47 Apache.exe
APACHE~1 DLL 247,808 19/07/98 12:11 ApacheCore.dll
MAKEFI~1 TMP 21,025 15/07/98 18:03 Makefile.tmpl
README 2,109 01/04/98 13:59 README
README~1 TXT 2,985 30/05/98 13:57 README-NT.TXT
INSTALL DLL 54,784 19/07/98 11:44 install.dll
_DEISREG ISR 147 29/07/98 15:12 _DEISREG.ISR
_ISREG32 DLL 40,960 23/04/97 1:16 _ISREG32.DLL
13 file(s) 427,389 bytes
8 dir(s) 520,835,072 bytes free
httpd -d /usr/www/APACHE3/site.for_instance -f...
apache -d c:/usr/www/APACHE3/site.for_instance
httpd -d /usr/www/APACHE3/site.for_instance -f...
apache -d c:/usr/www/APACHE3/site.for_instance
The next step is to edit the configuration files for the server. In the subdirectory called conf you should find distribution versions of the three configuration files: srm.conf-dist, access.conf-dist, and httpd.conf-dist.
-d flag (notice
the full pathname to the site.toddle directory,
which will probably be different on your machine):
% httpd -d /usr/www/APACHE3/site.toddle
% cat > /usr/local/bin/go test -d logs || mkdir logs httpd -f 'pwd'/conf/httpd$1.conf -d 'pwd' ^d
^d is shorthand for Ctrl-D, which ends the input
and gets your prompt back. This go will work on
every site. It creates a logs directory if one
does not exist, and it explicitly specifies paths for the ServerRoot
directory (-d) and the Config file
(-f). The command
'
pwd
'
finds the current directory with the Unix command
pwd
. The back-ticks are
essential: they substitute pwd's
value into the script — in other words, we will run Apache with
whatever configuration is in our current directory. To accomodate
sites where we have more than one Config file, we have used
...httpd$1... where you might expect to see
...httpd... The symbol $1
copies the first argument (if any) given to the command
go
. Thus ./go
2 will run the Config file called httpd2.conf,
and ./go by itself will run
httpd.conf.
pwd's return will
be nonsense, and Apache will complain that it 'could not
open document config file ...'.
% chmod +x go % go
go: command not found
% ./go
psvary from Unix to Unix):
% ps -aux
>ping 127.0.0.1
Pinging 127.0.0.1 with 32 bytes of data: Reply from 127.0.0.1: bytes=32 time<10ms TTL=32 ....
>cd "\Program Files\apache"
>apache -s
go[RETURN]go"
throughout the book when Apache is to be started, and thus save
lengthy explanations.
Apache/<version number> Syntax error on line 44 of /apache/conf/httpd.conf ServerRoot must be a valid directory
ServerName
gives the hostname of the server to use
when creating redirection URLs, that is, if you use a
<Location> directive or access a directory
without a trailing /.
ServerName hostname
Server config, virtual hostDocumentRoot directory
Default: /usr/local/apache/htdocs
Server config, virtual hostAlias, the
server appends the path from the requested URL to the document root
to make the path to the document. For example:
DocumentRoot /usr/web
DocumentRoot has a trailing slash
(e.g., DocumentRoot
/usr/web/),
so please avoid that. It is worth bearing in mind that the deeper
DocumentRoot goes, the longer it takes Apache to
check out the directories. For the sake of performance, adopt the
British Army's universal motto: KISS (Keep It
Simple, Stupid)!
ServerRoot specifies where the subdirectories
conf and logs can be found.
ServerRoot directory Default directory: /usr/local/etc/httpd Server config
-f (file) option, you
need to include the ServerRoot directive. On the
other hand, if you use the -d (directory) option,
as we do, this directive is not needed.
ErrorLog
directive sets the name of the file to which the server will log any
errors it encounters.
ErrorLog filename|syslog[:facility] Default: ErrorLog logs/error_log Server config, virtual host
--enable-shared=max. You will find
/usr/etc/httpd
/
httpd.conf.default:
copy the list from it into your own Config file, and edit
it as you need.
LoadModule env_module libexec/mod_env.so LoadModule config_log_module libexec/mod_log_config.so LoadModule mime_module libexec/mod_mime.so LoadModule negotiation_module libexec/mod_negotiation.so LoadModule status_module libexec/mod_status.so LoadModule includes_module libexec/mod_include.so LoadModule autoindex_module libexec/mod_autoindex.so LoadModule dir_module libexec/mod_dir.so LoadModule cgi_module libexec/mod_cgi.so LoadModule asis_module libexec/mod_asis.so LoadModule imap_module libexec/mod_imap.so LoadModule action_module libexec/mod_actions.so LoadModule userdir_module libexec/mod_userdir.so LoadModule alias_module libexec/mod_alias.so LoadModule access_module libexec/mod_access.so LoadModule auth_module libexec/mod_auth.so LoadModule setenvif_module libexec/mod_setenvif.so # Reconstruction of the complete module list from all available modules # (static and shared ones) to achieve correct module execution order. # [WHENEVER YOU CHANGE THE LOADMODULE SECTION ABOVE UPDATE THIS, TOO] ClearModuleList AddModule mod_env.c AddModule mod_log_config.c AddModule mod_mime.c AddModule mod_negotiation.c AddModule mod_status.c AddModule mod_include.c AddModule mod_autoindex.c AddModule mod_dir.c AddModule mod_cgi.c AddModule mod_asis.c AddModule mod_imap.c AddModule mod_actions.c AddModule mod_userdir.c AddModule mod_alias.c AddModule mod_access.c AddModule mod_auth.c AddModule mod_so.c AddModule mod_setenvif.c
LoadModules, then
ClearModuleList, followed by
AddModules to activate the ones you
want. As we said earlier, it is all rather
cumbersome and easy to get wrong. You might want put the list in a
separate file and then http://oreilly.com/catalog/apache3/. For the
sake of a little extra realism, we will base the site loosely round a
simple web business, Butterthlies, Inc., that creates and sells
picture postcards. We need to give it some web addresses, but since
we don't yet want to venture into the outside world,
they should be variants on your own network ID. This way, all the
machines in the network realize that they don't have
to go out on the Web to make contact. For instance, we edited the
\windows\hosts file on the Windows 95 machine
running the browser and the /etc/hosts file on
the Unix machine running the server to read as follows:
127.0.0.1 localhost 192.168.123.2 www.butterthlies.com 192.168.123.2 sales.butterthlies.com 192.168.123.3 sales-IP.butterthlies.com 192.168.124.1 www.faraway.com
test -d logs || mkdir logs
httpd -d 'pwd' -f 'pwd'/conf/httpd.conf
c>cd \program files\apache group\apache c>apache -k start c>Apache/1.3.26 (Win32) running ...
c>apache -k stop c>cd logs c>edit error.log
http://oreilly.com/catalog/apache3/. For the
sake of a little extra realism, we will base the site loosely round a
simple web business, Butterthlies, Inc., that creates and sells
picture postcards. We need to give it some web addresses, but since
we don't yet want to venture into the outside world,
they should be variants on your own network ID. This way, all the
machines in the network realize that they don't have
to go out on the Web to make contact. For instance, we edited the
\windows\hosts file on the Windows 95 machine
running the browser and the /etc/hosts file on
the Unix machine running the server to read as follows:
127.0.0.1 localhost 192.168.123.2 www.butterthlies.com 192.168.123.2 sales.butterthlies.com 192.168.123.3 sales-IP.butterthlies.com 192.168.124.1 www.faraway.com
test -d logs || mkdir logs
httpd -d 'pwd' -f 'pwd'/conf/httpd.conf
c>cd \program files\apache group\apache c>apache -k start c>Apache/1.3.26 (Win32) running ...<