-->

Previous | Table of Contents | Next

Page 160

The Port directive has no effect on an inetd server. A standalone server uses this configuration information to learn which port it should be listening to. Because inetd does the binding between the port and the software, this setting has no effect on an inetd configuration.

Configuring inetd

inetd is the "Internet superserver." It gets started when the machine boots by /etc/rc. After it is launched, inetd listens for connections on Internet socket ports. When it finds a connection, it starts the program responsible for managing that port. When the request is served and the program exits, inetd continues to listen for additional requests on that port.

To make Apache work from inetd, you need to edit /etc/inetd.conf and /etc/services. Configuring an inetd server requires a bit more system configuration than a standalone server.

First, you need to edit your /etc/services file. The /etc/services database contains information about all known services available on the Internet. Each service is represented by a single line listing the following information:

Official service name
Port number
Protocol name
Aliases by which the service is known

Each entry is separated by a tab or spaces. An entry describing httpd looks like this:


http portnumber/tcp httpd httpd

TCP/IP RESERVED PORTS
TCP/IP ports range from 0 to 65,535; however, the first 1,024 ports are reserved. A reserved port is controlled and assigned by the IANA and, on most systems, can be used only by system (or root) processes or by programs executed by privileged users. (The IANA is the Internet Assigned Numbers Authority. More details about the IANA and reserved ports are available at http://www.sockets.com/services.htm#WellKnownPorts.) If you want to run the server at port 80 (the default for httpd), the superuser must start httpd.

Set portnumber to the port number on which you want to run the server. Typically, this port will be port 80 for a standalone server. inetd servers run better at port 8080, so your entry will look like this:


http 8080/tcp httpd httpd

Page 161

If you are running NetInfo, you can type this line into a temporary file, such as /tmp/services, and then run


niload services . < /tmp/services

Next, you need to edit /etc/inetd.conf to configure inetd to listen for httpd requests. Each line in inetd.conf contains the following information:

Service name
Socket type
Protocol
Wait/no wait
User the server program will run as
Server program
Server program arguments

My completed entry looks like this:


httpd  stream  tcp  nowait nobody  /sbin/httpd httpd -f /etc/httpd/conf/httpd.conf

WARNING
The preceding example starts the server as nobody. Typically, you will want a standalone server to be started by the root user so that the server can bind to port 80, the standard HTTP port, and be able to change the UID and GID of its children processes. When the standalone server starts, it forks children processes. These children processes run with a UID of nobody and a GID of nogroup, unless you specified a different setting with the User and Group directives. The children processes handle the HTTP requests. The main process, owned by root, has as its duty the creation and destruction of its children processes. This makes the standard, standalone server secure.

If you specify the root UID in this example with the intention of running the inetd server on port 80, the process handling the request is owned by root. This setup can create security problems; unlike a standalone server, the inetd server doesn't fork any children processes, so it handles requests with the UID and GID of the process owner.

After adding the httpd entry to /etc/inetd.conf, you need to restart inetd. You can easily do so by finding out the inetd process number by using ps and sending it a HANGUP signal:


# kill -HUP InetdProcessID

Replace the InetdProcessID with the process number listed by the ps command. If the PID listed is 86, you would type kill -HUP 86.

inetd then restarts, rereading the configuration file that instructs it to listen for a request for port 8080.

Page 162

Running the Web Server for the First Time

Before you can run the server for the first time, you need to create an HTML document. The standard Apache distribution includes such a file, but I have created another file that is more useful, and I am sure that you'll use it time and time again. Using your favorite text editor, create a file called index.html inside the htdocs directory with this content:


<HTML>

<HEAD>

<TITLE>Red Hat Linux Unleashed</TITLE>

</HEAD>

<BODY BGCOLOR="#ffffff" LINK="#000080" VLINK="#000080">

<H1><CENTER>Red Hat Linux Unleashed </CENTER></H1>

<H2><CENTER>Congratulations! Your Apache server was successfully

installed.</CENTER></H2>



<H3>Here are some interesting sites that host information about

the Apache server: </H3>



<UL>

<LI>The official homepage for the

<A HREF="http://www.apache.org">Apache Group</A>



<LI>The official homepage for

<A HREF="http://www.us.apache-ssl.com">Community Connexion</A>

developers of Stronghold: Apache-SSL-US (A Netscape compatible

SSL server based on Apache)



<LI>The official homepage for

<A HREF="http://www.algroup.co.uk/Apache-SSL">Apache-SSL</A>

(A Netscape compatible SSL server based on Apache - only available

to users outside of the United States).



<LI><A HREF="http://www.zyzzyva.com/server/module_registry/">

Apache Module Registry</A>, the place where you can find information

about 3<SUP>rd</SUP> party Apache modules and other development stuff.



<LI><A HREF="http://www.apacheweek.com">The Apache Week Home</A>,

here you will find an essential weekly guide dedicated to Apache server

Âinformation.



<LI><A HREF="http://www.ukweb.com">UK Web's Apache Support Center</A>



<LI><A HREF="http://www.fastcgi.com">The FastCGI Website</A>

</UL>



<P>

<STRONG>Deja News a very handy USENET news search engine:</STRONG>

<FORM ACTION="http://search.dejanews.com/dnquery.xp" METHOD=POST>



<P>

<CENTER>

<STRONG>Quick Search For:</STRONG> <INPUT NAME="query" VALUE="Apache" SIZE="37">

<INPUT TYPE="submit" VALUE="Search!"><INPUT NAME="defaultOp" VALUE="AND"

ÂTYPE="hidden">

<INPUT NAME="svcclass" VALUE="dncurrent" TYPE="hidden">

<INPUT NAME="maxhits" VALUE="20" TYPE="hidden">

Previous | Table of Contents | Next