829-832.html

来自「linux-unix130.linux.and.unix.ebooks130 l」· HTML 代码 · 共 161 行

HTML
161
字号
<HTML>

<HEAD>

<TITLE>Linux Unleashed, Third Edition:Setting up a Gopher Service</TITLE>

<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->




<!--ISBN=0672313723//-->

<!--TITLE=Linux Unleashed, Third Edition//-->

<!--AUTHOR=Tim Parker//-->

<!--PUBLISHER=Macmillan Computer Publishing//-->

<!--IMPRINT=Sams//-->

<!--CHAPTER=50//-->

<!--PAGES=829-832//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="826-829.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="../ch51/833-836.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<P>The plus signs used in the <TT>Port</TT> and <TT>Host</TT> fields instruct the FTP service on the remote machine to return results to this machine using default ports (such as TCP port 21 for FTP). For a link to a WAIS directory, the format is:</P>

<!-- CODE SNIP //-->

<PRE>

Name=More Sales Info

Type=7

Port=&#43;

Path=waisrc:/usr/wais/data

Host=&#43;

</PRE>

<!-- END CODE SNIP //-->

<P>Finally, you may want to have a menu item execute a program. You can do this by having the <TT>Path</TT> field use the <TT>exec</TT> command:</P>

<!-- CODE SNIP //-->

<PRE>

Path=exec: &#147;<I>args</I>&#148; : <I>do_this</I>

</PRE>

<!-- END CODE SNIP //-->

<P>where <I>do_this</I> is the program you want to execute and <I>args</I> are any arguments to be passed to <I>do_this</I>. If you have no arguments to pass, leave the quotation marks empty. This format is a little awkward, but it does work.</P>

<H3><A NAME="Heading9"></A><FONT COLOR="#000077">Starting Gopher</FONT></H3>

<P>A Gopher server can be started either from the <TT>rc</TT> startup files, from the command line, or from the <TT>inetd</TT> daemon. From the command line or the <TT>rc</TT> files, you need a command line similar to this:</P>

<!-- CODE SNIP //-->

<PRE>

/usr/local/etc/gopherd /usr/gopher/gopher-data 70

</PRE>

<!-- END CODE SNIP //-->

<P>which starts the daemon with the directory the startup Gopher menus reside in and the port number for connections.

</P>

<P>The <TT>gopherd</TT> command line accepts a number of optional flags to control its behavior, although most mirror entries in the configuration files. Valid flags are as follows:</P>

<CENTER>

<TABLE WIDTH="90%"><TR>

<TD WIDTH="30%"><TT>-C</TT>

<TD WIDTH="70%">Disables directory caching.

<TR>

<TD><TT>-c</TT>

<TD>Runs without <TT>chroot</TT> restrictions.

<TR>

<TD><TT>-D</TT>

<TD>Enables debugging.

<TR>

<TD><TT>-I</TT>

<TD><TT>inetd</TT> is used to invoke <TT>gopherd.</TT>

<TR>

<TD><TT>-L</TT>

<TD>Followed by a value for the maximum load average.

<TR>

<TD VALIGN="TOP"><TT>-l</TT>

<TD>Log file to record connections (filename follows the option).

<TR>

<TD VALIGN="TOP"><TT>-o</TT>

<TD>Specifies an alternate configuration file from <TT>gopherd.conf</TT> (filename follows the option).

<TR>

<TD VALIGN="TOP"><TT>-u</TT>

<TD>Sets the name of the owner running <TT>gopherd</TT> (valid username must follow the option).

</TABLE>

</CENTER>

<P>To help secure your system, use <TT>chroot</TT> to create a separate file system structure for the Gopher area (as you did with FTP: see Chapter 48, &#147;Setting up an FTP and Anonymous FTP Site&#148;). The <TT>-c</TT> option is not as secure as running <TT>gopherd</TT> with <TT>chroot</TT> active. Also, the <TT>-u</TT> option should be used to make <TT>gopherd</TT> run as a standard user&#146;s process, instead of as <TT>root</TT>. This helps protect against holes in the daemon that a hacker could exploit.</P>

<P>If you want to run Gopher under <TT>inetd</TT> (started whenever a request for the service arrives), modify the <TT>/etc/services</TT> and <TT>/etc/inetd.conf</TT> file to include a line for Gopher. Normally, the entry in <TT>/etc/services</TT> looks like this:</P>

<!-- CODE SNIP //-->

<PRE>

gopher   70/tcp

</PRE>

<!-- END CODE SNIP //-->

<P>and the entry in <TT>/etc/inetd.conf</TT> looks like this:</P>

<!-- CODE SNIP //-->

<PRE>

gopher   stream   tcp   nowait   root

    /usr/local/etc/gopherd gopherd -I -u <I>username</I>

</PRE>

<!-- END CODE SNIP //-->

<P>where <I>username</I> is the name of the user to run <TT>gopherd</TT> as (you can set up a specific account for <TT>gopher</TT> in /<TT>etc/passwd</TT> with standard permissions).</P>

<P>Once the Gopher server process is up and running, you can test your Gopher installation. First, though, you will need a Gopher client. Then use the Gopher client to connect to your Gopher server (using your host name), and you should see the top directory of your Gopher resources. Another way to test your Gopher system is to use Telnet. Use Telnet to connect to the Gopher port, using a command like this:</P>

<!-- CODE SNIP //-->

<PRE>

telnet gopher 70

</PRE>

<!-- END CODE SNIP //-->

<P>If the connection is properly made, you will see your Gopher system on the screen.

</P>

<P>Yet another alternative to test your system is to use the program <TT>gopherls</TT>, which requires the name of the directory your Gopher source resides in. To start <TT>gopherls</TT>, issue a command as follows:</P>

<!-- CODE SNIP //-->

<PRE>

gopherls /usr/wais/gopher/data

</PRE>

<!-- END CODE SNIP //-->

<P>specifying your Gopher data directory. You can use this technique to test new Gopher directories as you develop them.

</P>

<H3><A NAME="Heading10"></A><FONT COLOR="#000077">Letting the World Know</FONT></H3>

<P>Because you have spent a lot of time setting up your Gopher service, you can now let everyone else on the Internet know about it. (Of course, you should only do this when your Gopher service is ready, and if you want to allow general access. Don&#146;t follow these steps if you are granting access only to a few people or your local area network.)

</P>

<P>To have your Gopher service listed in the main Gopher service directories, send an email message to the address:</P>

<!-- CODE SNIP //-->

<PRE>

gopher&#64;boombox.micro.umn.edu

</PRE>

<!-- END CODE SNIP //-->

<P>and include the Gopher service&#146;s full name as it appears on your main menu, your host&#146;s name and IP address, the port number Gopher uses (which should be TCP port 70 for general Internet access), the email account of the Gopher administrator, and a short paragraph describing your service. If you want, you can also provide a string that gives the path to the data directory, although since most Gopher systems start in the root directory, this string isn&#146;t necessary unless you have sub-menus for different purposes.

</P>

<H3><A NAME="Heading11"></A><FONT COLOR="#000077">Summary</FONT></H3>

<P>After all that, your Gopher service is ready to use. You do need to set up the Gopher file entries, but that is beyond the scope of this chapter. Consult a good Internet or Gopher book for more information on Gopher directories, files, and entries. Gopher is a handy utility if you have volumes of information you want to share, and although the configuration process can take a while, once it&#146;s completed, the Gopher system tends to work very well. To learn more about:

</P>

<DL>

<DD>How to set up a World Wide Web server on your Linux machine, see Chapter 51, &#147;Configuring a WWW Site.&#148;

<DD>How to program in HTML to set up your home pages for the Web, see Chapter 53, &#147;HTML Programming Basics.&#148;

<DD>How to use Java to provide more flexibility to your home pages, see Chapter 54, &#147;Java and JavaScript Basics.&#148;

<DD><TT>make</TT> and the <TT>makefile</TT> utility, see Chapter 56, &#147;Source Code Control.&#148;

</DL>

<P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="826-829.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="../ch51/833-836.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>





</td>
</tr>
</table>

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?