Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (303.85 KB, 29 trang )
World Wide Web
C H A P T E R 27
27.1 WWW
The World Wide Web (WWW) uses the HyperText Markup Language (HTML), a subset of the
Standard Generalized Markup Language (SGML), as one of its formats. This allows you publish
your own multimedia documents on the network. The Internet protocol used is HyperText Transfer
Protocol (http), which allow the client and server to negotiate the transfer representation of the
document. We’ll use this as an example of how to set up a complicated server on your workstation.
27.2 URLs
Uniform Resource Locators, URLs, reference where a resource can be found in the form:
service_scheme://machine_name[:port_number]/directory/sub-directory_list/file[?keyword]
where the items in brackets are optional. Some of the more common service_schemes are:
•
•
•
•
•
ftp - file transfer protocol, a “;type=
(e.g. an “I” for image, or an “A” for text)
http - hypertext transfer protocol
gopher - gopher protocol
news - Usenet news via NNTP
telnet, rlogin, or tn3270
The service_scheme could, optionally, include a user name and password, if required for the service.
The machine_name may be followed by a decimal port_number, separated from the machine_name
by a colon, if something other than the default port number, 80, is used by the service.
The remainder of the address is the path, with subdirectories separated by “/” and ending with the
desired file name or program. The latter may optionally be followed by a “?” and a keyword that can
be used as an argument to the program. The specs for URLs can be found on:
http://www.w3c.org/Addressing/URL/Overview.html
UNIX System Administration
© 1998 University Technology Services, The Ohio State University
257
World Wide Web
27.3 WWW Server
You have many choices of free servers, but one stands out; the others that were once most popular
have been discontinued because Apache is so good.
•
Apache - Hypperreal’s extensions to the original NCSA server.
http://www.apache.org/
This usually comes in source form, though binaries may be available.
27.4 WWW Browsers
There are four main browsers that you might be interested in:
•
Netscape - from Netscape Communications, Corp., the second generation browser
http://home.netscape.com/download/ - for a pre-compiled binary.
•
Mozilla - the public development version of Netscape Navigator.
http://www.mozilla.org/ - for source or binary.
•
HotJava - from Sun, written in Java and requires Java to run
Comes with Solaris 2.6+, or get it from http://java.sun.com/products/hotjava/.
•
Lynx - a powerful text only browser
http://lynx.browser.org/.
27.5 Setting up your Server
For our example we’ll use the Apache httpd server. After retrieving the source from the reference
above check out the README and src/INSTALL files for installation and configuration information.
To compile your own daemon uncompress and un-tar the source tree and edit the default control files
in the conf directory: srm.conf, access.conf, httpd.conf. Then edit the src/Configuration file to select
a compiler to use, options, and the modules to include. Some things you might change:
CC= cc
CFLAGS= -DMAXIMUM_DNS DXBITHACK
AUX_CFLAGS= -DSOLARIS2
AUX_LIBS= -lsocket -lnsl
Module agent_log_module
Module referer_log_module
Module config_log_module mod_log_config.o
or
or
or
or
CC=gcc
CFLAGS= -O2
AUX_CFLAGS= -DSUNOS4
AUX_LIBS=
You can set the paths for the various services, control files, and log files in httpd.h. Some examples
of entries you might change are:
#define HTTPD_ROOT "/usr/local/etc/httpd¨
258
© 1998 University Technology Services, The Ohio State University
UNIX System Administration
Setting up your Server
#define DEFAULT_ADMIN "[no address given]" -->
#define DEFAULT_PORT 80
#define DEFAULT_XFERLOG "logs/access_log"
#define DEFAULT_INDEX "index.html"
#define ACCESS_CONFIG_FILE "conf/access.conf"
"webmaster"
27.5.1 Compilation of the programs
To compile the http daemon, httpd, first go to the src subdirectory (cd src) and type "./Configure"
and respond to any questions, then type “make”. It will default to using the Makefile in that
directory. Then build any support files needed in the support directory (cd ../support) after editing
the Makefile to select the desired compiler and programs. Then install the necessary programs in
their desired directories.
The full list of steps can be found at: ftp://wks.uts.ohiostate.edu/pub/solaris2/src/UTSinfo_apache-httpd-1.0.3, along with the source and compiled binaries
in the file apache_1.0.3.tar.gz in the same directory.
WWW will support applications other than just display. There are a few sample auxiliary programs
you can compile in the cgi-src directory and install in the cgi-bin directory, which already contains a
few sample shell scripts. If you’re not going to support these services than you can ignore this step.
27.5.2 Configuration
For complete documentation on how to set up your server use netscape or mosaic to web to
http://www.apache.org/. There you can find step-by-step instructions on how to configure the server.
The configuration file can be found in the conf directory. There is an example file you can use,
httpd.conf-dist, to create your server configuration file, httpd.conf.
Some of the entries you’ll want to check out are:
ServerType standalone
Port 80
User http
Group http
ServerAdmin you@your.address
ServerRoot /usr/local/httpd
or
inetd
The latter determines the directory hierarchy for your service. It could have sub-directories such as:
cgi-bin, conf, htdocs, icons, and logs.
This is a service you don’t want to run as root, so you should create a special user and group just for
it. So in /etc/passwd you might have an entry similar to:
http:nologin:999:999:World Wide Web Server:/usr/local/http:/bin/false
UNIX System Administration
© 1998 University Technology Services, The Ohio State University
259
World Wide Web
and a /etc/group entry similar to:
http:*:999:frank
You can run your server either as a standalone server, in which case you would start it up in an RC
script, or as a service controlled by inetd. In the latter case you would need an entry in /etc/services
similar to:
http
80/tcp
# WWW server
and another in /etc/inetd.conf similar to:
http stream tcp nowait http /usr/local/etc/httpd -d /usr/local/httpd -f /usr/local/httpd/conf/httpd.conf
where
-d
-f
specifies the ServerRoot and where the daemon will look for it’s configuration file
(not necessary if you use the default ServerRoot path in the configuration file.)
specifies the configuration file
To set it up as a standalone server you might put an entry similar to the following in an RC script, e.g.
/etc/rc.local for SunOS 4.1.X:
if [ -f /usr/local/etc/httpd -a -d /usr/local/httpd -a -f /usr/local/httpd/conf/httpd.conf ]; then
/usr/local/etc/httpd -d /usr/local/httpd -f /usr/local/httpd/conf/httpd.conf; echo -n ’ httpd’
fi
For SunOS 5.X set up a script to start and stop the service as you go through run level 2.
Running httpd as a standalone daemon is more efficient, but running as a service of inetd provides
greater access control. If you’re using TCPwrapper you can specify which machines or subnets have
access to your http service when each connection is controlled by inetd.
27.6 Home Page
To complete your service you’ll want to set up a Home Page on your server.
You’ll need to know a little bit about HTML and the following primer will help you get started:
http://www.ncsa.uiuc.edu/General/Internet/WWW/HTMLPrimer.html
A good style guide can be found at:
http://www.sun.com/styleguide/
A simple home page could be something like this one, which you could once find on
http://wks.uts.ohio-state.edu, with the following HTML:
260
© 1998 University Technology Services, The Ohio State University
UNIX System Administration
Home Page