old-www/LDP/solrhe/Securing-Optimizing-Linux-R.../chap13sec111.html

626 lines
9.6 KiB
HTML

<HTML
><HEAD
><TITLE
>Build, Install software on your system</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.60"><LINK
REL="HOME"
TITLE="Securing and Optimizing Linux"
HREF="index.html"><LINK
REL="UP"
TITLE="Linux -The Compiler functionality"
HREF="lin-compiler.html"><LINK
REL="PREVIOUS"
TITLE="Why choose tarballs?"
HREF="chap13sec110.html"><LINK
REL="NEXT"
TITLE="Software -Security/Monitoring"
HREF="soft-secmonitor.html"></HEAD
><BODY
CLASS="section"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Securing and Optimizing Linux: RedHat Edition -A Hands on Guide</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="chap13sec110.html"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 13. Linux -The Compiler functionality</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="soft-secmonitor.html"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="AEN7164"
>13.3. Build, Install software on your system</A
></H1
><P
>&#13; You will see from the next chapter right through Part 6 that we use many different compile commands to build and install programs on the server. These commands are UNIX compatible and are used on all variant
off <TT
CLASS="literal"
>*nix</TT
> machines to compile and install software.
</P
><P
>&#13; The procedures to compile and install software tarballs on your server follow:
</P
><DIV
CLASS="procedure"
><OL
TYPE="1"
><LI
><P
>&#13; First of all, you must download the tarball from your trusted software archive site. Usually from the main site of the software you hope to install.
</P
></LI
><LI
><P
>&#13; After downloading the tarball change to the <TT
CLASS="filename"
>/var/tmp/</TT
> directory, note that other paths are possible, as personal discretion and untar the archive by typing the commands as root as in the
following example:
<DIV
CLASS="example"
><A
NAME="AEN7175"
></A
><P
><B
>Example 13-1. Using tar</B
></P
><P
>&#13; <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="screen"
>&#13; [root@deep] /#<B
CLASS="command"
>tar</B
> xzpf foo.tar.gz
</PRE
></TD
></TR
></TABLE
>
The above command will extract all files from the example foo.tar.gz compressed archive and will create a new directory for them with the name of this software from the path where you are executing the command.
<P
></P
><DIV
CLASS="variablelist"
><DL
><DT
>The <TT
CLASS="literal"
>x</TT
> option</DT
><DD
><P
>&#13; tells tar to extract all files from the archive.
</P
></DD
><DT
>The <TT
CLASS="literal"
>z</TT
> option</DT
><DD
><P
>&#13; tells tar that the archive is compressed with gzip.
</P
></DD
><DT
>The <TT
CLASS="literal"
>p</TT
> option</DT
><DD
><P
>&#13; maintains the original and permissions the files had as the archive was created.
</P
></DD
><DT
>The <TT
CLASS="literal"
>f</TT
> option</DT
><DD
><P
>&#13; tells tar that the very next argument is the file name.
</P
></DD
></DL
></DIV
>
</P
></DIV
>
</P
></LI
></OL
></DIV
><P
>&#13; Once the tarball has been decompressed into the appropriate directory, you will almost certainly find a <TT
CLASS="filename"
>README</TT
> and/or an <TT
CLASS="filename"
>INSTALL</TT
> file included with the newly decompressed
files, with further instructions on how to build and compile the software package for use. You will need to enter commands similar to the following example:
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
>&#13; <B
CLASS="command"
>./configure</B
>
<B
CLASS="command"
>make</B
>
<B
CLASS="command"
>make install</B
>
</PRE
></TD
></TR
></TABLE
>
</P
><P
>&#13; The above commands;
<P
></P
><TABLE
BORDER="0"
><TBODY
><TR
><TD
>&#13; <B
CLASS="command"
>./configure</B
> will configure the software to ensure your system has the necessary functionality and libraries to successfully compile the package
</TD
></TR
><TR
><TD
>&#13; <B
CLASS="command"
>make</B
> will compile all the source files into executable binaries.
</TD
></TR
><TR
><TD
>&#13; Finally, <B
CLASS="command"
>make install</B
> will install the binaries and any supporting files into the appropriate locations.
</TD
></TR
></TBODY
></TABLE
><P
></P
>
Other specifics commands that you'll see in our book for compilation and installation procedure will be:
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
>&#13; <B
CLASS="command"
>make depend</B
>
<B
CLASS="command"
>strip</B
>
<B
CLASS="command"
>chown</B
>
</PRE
></TD
></TR
></TABLE
><P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><B
CLASS="command"
>make depend</B
></DT
><DD
><P
>&#13; command will build and make the necessary dependencies for different files.
</P
></DD
><DT
><B
CLASS="command"
>strip</B
></DT
><DD
><P
>&#13; command will discard all symbols from the object files. This means that our binary file will be smaller in size, will improve a bit the performance hit to the program since there will be fewer lines to read
by the system when it executes the binary.
</P
></DD
><DT
><B
CLASS="command"
>chown</B
></DT
><DD
><P
>&#13; command will set the correct files owner and group permission for the binaries.
</P
></DD
></DL
></DIV
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
><SPAN
CLASS="inlinemediaobject"
><IMG
SRC="./images/Note.gif"
ALT="Note"
></IMG
></SPAN
>: </B
>
More commands when necessary will be explained in the concerned installation procedure.
</P
></BLOCKQUOTE
></DIV
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="AEN7244"
>13.3.1. Edit files with the vi editor</A
></H2
><P
>&#13; The vi program is a text editor that you can use to edit any text and particularly programs. During installation of software, the user will often have to edit text files like <TT
CLASS="filename"
>Makefiles</TT
> or
configuration files to make and fit they changes. The following are some of the most important keystroke commands to get around in vi.
</P
><DIV
CLASS="glosslist"
><DL
><DT
><B
><B
CLASS="command"
>i</B
></B
></DT
><DD
><P
>&#13; To insert text before the cursor.
</P
></DD
><DT
><B
><B
CLASS="command"
>a</B
></B
></DT
><DD
><P
>&#13; To append text after the cursor.
</P
></DD
><DT
><B
><B
CLASS="command"
>dd</B
></B
></DT
><DD
><P
>&#13; To delete the current line.
</P
></DD
><DT
><B
><B
CLASS="command"
>x</B
></B
></DT
><DD
><P
>&#13; To delete the current character.
</P
></DD
><DT
><B
><B
CLASS="command"
>Esc</B
></B
></DT
><DD
><P
>&#13; To end the insert or append mode.
</P
></DD
><DT
><B
><B
CLASS="command"
>u</B
></B
></DT
><DD
><P
>&#13; To undo the last command.
</P
></DD
><DT
><B
><B
CLASS="command"
><B
CLASS="keycap"
>Ctrl</B
>+<B
CLASS="keycap"
>f</B
></B
></B
></DT
><DD
><P
>&#13; Scroll up one page.
</P
></DD
><DT
><B
><B
CLASS="command"
><B
CLASS="keycap"
>Ctrl</B
>+<B
CLASS="keycap"
>b</B
></B
></B
></DT
><DD
><P
>&#13; Scroll down one page.
</P
></DD
><DT
><B
><B
CLASS="command"
>/string</B
></B
></DT
><DD
><P
>&#13; Search forward for string.
</P
></DD
><DT
><B
><B
CLASS="command"
>:f</B
></B
></DT
><DD
><P
>&#13; Display filename and current line nmber.
</P
></DD
><DT
><B
><B
CLASS="command"
>:q</B
></B
></DT
><DD
><P
>&#13; Quit editor.
</P
></DD
><DT
><B
><B
CLASS="command"
>:q!</B
></B
></DT
><DD
><P
>&#13; Quit editor without saving changes.
</P
></DD
><DT
><B
><B
CLASS="command"
>:wq</B
></B
></DT
><DD
><P
>&#13; Save changes and exit editor.
</P
></DD
></DL
></DIV
><DIV
CLASS="warning"
><P
></P
><TABLE
CLASS="warning"
BORDER="1"
WIDTH="100%"
><TR
><TD
ALIGN="CENTER"
><B
><SPAN
CLASS="inlinemediaobject"
><IMG
SRC="./images/Warning.gif"
ALT="Warning"
></IMG
></SPAN
></B
></TD
></TR
><TR
><TD
ALIGN="LEFT"
><P
>&#13; Before proceeding to read the rest of this book, it should be noted that the text assumes that certain files are placed in certain directories. Where they have been specified, the conventions we adopt here for
locating these files are those of the Red Hat Linux distribution. If you are using a distribution of Linux or some other operating system that chooses to distribute these files in a different way, you should be
careful when copying examples directly from the text.
</P
></TD
></TR
></TABLE
></DIV
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="chap13sec110.html"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="soft-secmonitor.html"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Why choose <TT
CLASS="literal"
>tarballs</TT
>?</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="lin-compiler.html"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Software -Security/Monitoring</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>