Section 2.1. Installing Perl

   

2.1 Installing Perl

We described Perl's origins and advantages in Chapter 1. In this section, we'll describe the basics of the installation process for Perl. To obtain Perl and to get more detailed information about this process, check out these web sites:

http://www.perl.com
http://www.perl.org

Main Perl portals.

http://www. activestate .com

ActiveState Win32 Perl portal site. You'll find many other projects, including ActivePerl, under the main ActiveState portal; most ActiveState products tend to have fairly fluid web addresses, so we won't attempt to provide them here.

2.1.1 Installing Perl on Unix

There are three basic ways to get started with Perl on Unix and Linux systems, the third of which is best for reasons we'll explain shortly:

  1. Find Perl already installed on your system.

  2. Download a binary executable that will build Perl for you out of the box.

  3. Configure and build Perl yourself from the source code.

On most Unix versions, if you install Perl as the root user and accept the default installation directories, it will generally embed itself into either one of the following directories:

/usr/bin
/usr/local/bin

In most cases, this is fine; however, you may wish to install it somewhere else, such as /u01/app/perl .

There are several reasons why you might want to install Perl in a different location:

  • If you're an Oracle DBA who is working on other people's systems, you may be denied access to the root user's system directories.

  • You may have theoretical access, but jumping through the corporate hoops to get actual physical access on some production systems (and having to fill out all the necessary forms) may just not be worth it.

  • Some versions of Perl, may already exist on your system and be used by everyone else. However, you want your own latest-and-greatest private Perl to do the work you need it to do, without upsetting the informational applecart. Those guys in marketing may be happy relying on that ancient Perl 4 workhorse, but we need something a bit more developed.

There are also several secondary reasons:

  • Upgrading module versions, such as DBD::Oracle , when they become available, will be simpler if you're in complete control of the Perl installation location.

  • Adding new modules also becomes easier if you don't need to ask people's permission to do it, or to work within their weekly downtime window (you can almost guarantee that window will be Wednesday morning at 3:00 AM).

  • For similar reasons, upgrading Perl itself will also be painless. Your local neighborhood system administrators may even award you bonus points for keeping off their turf!

Although we'll assume in the following discussion that you're installing Perl in default locations as root (which is most often the case), we'll indicate the one place where you can change this default, if you want to install Perl under something more like the oracle or oramon user, in a nonstandard location.

This chapter assumes that you want to create your own version of Perl ” one that is distinct from the Perl executables provided automatically in Oracle releases beginning with Version 8.1.7. (Later in this chapter, in Section 2.1.1.3 we'll explain why we recommend that you create your own version of Perl.) You need to be careful not to get these two versions of Perl confused (people installing Perl for the first time sometimes do this). One way to keep the versions straight is to ensure that your own independent version of Perl comes first in your system's generic PATH variable.

2.1.1.1 Finding Perl already installed on your system

If Perl exists somewhere on your system (i.e., the main perl executable program is available under your operating system, via the PATH environment variable), you can usually find it by running the following command:

 $ perl -v 

If you believe that Perl is on your machine, but this command fails to return anything, you may want to discover where Perl is living and then add it to your executables PATH. To find it, try one of the following commands:

 $ type perl $ which perl $ whence perl $ locate perl 

If these fail to work, or if Perl is still unavailable on your flavor of Unix, try the ultimate blockbuster approach:

 $ find / -name "perl*" -print 2>/dev/null 

Click, whirr. Once you've found Perl, add its executable directory into your PATH and then run the perl -v command. What we're looking for is something like this:

 $ perl -v    This is perl, v5.6.1 built for i686-linux    Copyright 1987-2001, Larry Wall    Perl may be copied only under the terms of either the Artistic License  or the GNU General Public License, which may be found in the  Perl 5 source kit.    Complete documentation for Perl, including FAQ lists, should be found  On this system using `man perl' or `perldoc perl'.  If you have access  to the Internet, point your browser at http://www.perl.com/, the Perl  Home Page.    $ 

Most Linux machines (depending on the release date of the Linux distribution) have Perl already on them. If you find Perl 5.6, or above, that's good enough. For some bizarre reason, many proprietary versions of Unix fail to come presupplied with Perl, but that's OK. It's much more fun to install from source! We'll show you how shortly.

2.1.1.2 Installing Perl from a prebuilt package

Some Oracle DBAs running Unix systems choose to install Perl from a prebuilt executable binary. In general, we recommend against this approach. Even if this option is available to you, it has several disadvantages in comparison to building Perl from source, mainly because prebuilt binaries may not match the configuration of your local system ” for example:

  • They may implicitly point to libraries that are not available on the particular machine.

  • The original compiler options with which the package was created may not be supported on your current system.

  • They may assume default paths that don't exist. For example, most of the prebuilt Unix Perl packages assume that the main perl executable is going to live under /usr/local/bin . This is especially problematic if, as we mentioned earlier, write access is unavailable to these kinds of directories.

Building from source, as we describe in the next section, is the best way to overcome local difficulties of these kinds.

If you do need to go down the prepackaged route, for whatever reason, be aware that most proprietary Unixes do have some great freeware sites. Although we think Perl is best if built from source on Unix, you need to build it with compilers, and if you haven't got one, these sites and their packages are invaluable for providing you with prepackaged compilers such as gcc . Some of the best sites we've found are:

For Solaris

http://sunfreeware.com

For AIX

http://ftp.univie.ac.at/aix

ftp://aixpdslib.seas.ucla.edu/pub

For HP-UX

http://jazz.external.hp.com/src/index.html#perl

For IRIX

http://freeware.sgi.com/index.html

For OpenBSD

http://www.openbsd.org/ports.html

For Linux

Virtually every flavor of Linux also has its own home site, which is full of Unix freeware download opportunities. Here are just some of the possibilities:

http://www.redhat.com/apps/download/
http://www.suse.de/us/support/download/
http://www.linux-mandrake.com/en/ftp.php3
http://www.caldera.com/download/mirrors.html
http://www.debian.org/distrib/ftplist
http://www.turbolinux.com/download/
http://www.slackware.com/packages/

You'll find the appropriate installation instructions at each site, and a web search should uncover any others. Here we'll run through the typical steps for Solaris. These are only guidelines; be sure that you obtain, and read carefully , the most up-to-date installation information for your own platform.

  1. Download the latest Perl package for your version of Solaris from the web site.

  2. Unzip the download (using either gunzip or gzip -d ) as the root user.

  3. Use pkgadd -d to add the package to your system.

For example, the following commands would install the standard Perl 5.6.1 package as the root user:

 $ gzip -d perl-5.6.1-sol8-sparc-local.gz $ pkgadd -d perl-5.6.1-sol8-sparc-local 

These kinds of steps (as specified on the appropriate site FAQ or within any accompanying README files) will build a fully functioning Perl system for you, adding the Perl executable to a directory like /usr/local/bin/perl . You'll follow similar steps for most of the other Unixes.

Using some download browser screens, the prebuilt packages will occasionally download without the *.gz suffix. This confuses the gunzip program. If this problem occurs, you can solve it by simply renaming the downloaded file with the additional *.gz suffixed extension.

2.1.1.3 Installing Perl from source

This third option is the one we recommend for Unix. To use our PDBA Toolkit most effectively, we recommend that you install at least Perl 5.6 from source. It's true that you may have older versions of Perl on your system, or versions built from prepackaged executables. However, we need to lay a specific version of Perl DBI on top of Perl, and for that reason we must ensure that Perl 5.6 has been set up correctly for your machine. The best way of doing this is by building up from source.

2.1.1.3.1 Obtaining the required C compiler

You must have a C compiler before you can complete your Perl installation. Fortunately, Linux virtually always comes with a gcc C compiler already on board, and most proprietary Unix types often come with their own, which is usually called cc. Even if you already have a C compiler, though, you may want to get hold of gcc because most open source project installations are built and tested with it. Using gcc , rather than any other C compiler, automatically eliminates many compiler incompatibility problems.

The gcc compiler is the creation of the GNU project, which was started in 1984 by Richard M. Stallman with the goal of developing a completely free Unix-like operating system. This project culminated in the development of the various GNU/Linux operating systems, better known by their generic name "Linux" after their core kernel developed by Linus Torvalds. You can check out the GNU project's definition of the word "free," get information about gcc , and learn much more at:

http://www.gnu.org

Although gcc is usually the right choice, always read the appropriate README files within the stable.tar.gz Perl distribution for each operating system. For instance, here's what the README.aix file says about using gcc :

Perl can be compiled with either IBM's ANSI C compiler or with gcc . The former is recommended, as not only can it compile Perl with no difficulty, but also can take advantage of features listed later that require the use of IBM compiler-specific command-line flags.

With AIX, you may have difficulties unless you do use the proprietary cc compiler, as the note suggests. Most HP platforms are also better served with HP's "official" C compiler, which you may have to purchase as an extra-cost item.

If you enjoy a challenge, and you'd like to boot-strap gcc from its own source code using your own proprietary cc compiler as the bootstrapper, check out the GNU web site for details.

You won't need to compile gcc from source (unless you enjoy Catch-22-type challenges) because virtually every flavor of Unix has a gcc binary package built for it already by the open source community. You can get such packages from the freeware sites listed in the previous section.

For example, at the time this book went to press, the following sites contained the latest gcc package for three major commercial Unix flavors.

http://sunfreeware.com

For Solaris

http://ftp.univie.ac.at/aix/aix432

For AIX

http://jazz.external.hp.com/src/gnu/download2_95_2.html

For HP-UX

You'll find appropriate README installation instructions at each site. Here, we'll run through the typical steps for Solaris. These are only guidelines. Be sure you obtain the most up-to-date installation information for your own platform, from the site where you get the gcc package:

  1. Download the latest gcc package, for your version of Solaris, from the sunfreeware.com site.

  2. Unzip the download using either gunzip or gzip -d as the root user. This file will be called something like gcc-3.0.3-sol8-sparc-local.gz .

  3. Use pkgadd -d to add the package to your system.

For example, if you're logged on as the root user, the following commands will install the gcc package:

 # gzip -d gcc-3.0.3-sol8-sparc-local.gz # pkgadd -d gcc-3.0.3-sol8-sparc-local 

The actual executable will usually get dispatched to /usr/local/bin/gcc .

As a final compilation caveat, note that the default Perl installation process looks for a generic cc compiler, unless you alter this behavior by following the detailed instructions in the Perl INSTALL file. To make sure you still pick up gcc anyway, move your old cc compiler somewhere safe, such as cc.old , or place a new cc location higher up in your PATH. Now we symbolically link in the new cc file to point at the real gcc compiler, to achieve a situation similar to the following:

 $ type cc cc is /home/oracle/bin/cc $ ls -l /home/oracle/bin/cc /home/oracle/bin/cc -> gcc $ type gcc gcc is /usr/local/bin/gcc 
2.1.1.3.2 Obtaining the source for Perl.

Once the compiler is ready, it's time to get the Perl source code itself. To obtain the latest version, visit CPAN, the Comprehensive Perl Archive Network:

http://www.perl.com/CPAN/README.html

This will probably direct you to download the most recent stable version of Perl ” for example:

http://www.perl.com/CPAN-local/src/stable.tar.gz

Once you've obtained your own copy of stable.tar.gz , follow these basic steps to install Perl:

  1. Download the zipped tar file (or "tarball," as we'll call it from now on) into a temporary directory accessible to the root user.

  2. Unpack the main bundled file into its own directory:

     # ls *.gz stable.tar.gz # gzip -d stable.tar.gz # ls *.tar stable.tar # tar xvf stable.tar 
  3. Change into the new Perl directory once the extraction process has completed, and then carefully work through the instructions in the README and INSTALL files:

     # ls perl-5.6.1 # cd perl-5.6.1 # vi README INSTALL 
  4. These instructions ask us to run an intelligent and friendly configuration program, Configure , a sort of Hitchhiker's Guide to the Perl installation process. By now, this program has been run, quite literally, a few million times, so there are few installation issues the program has failed to cope with. You should have no problems running it, especially if you're happy with a totally default install. For re-installations, the following preparation step also ensures that no previously existing master configuration files will interfere with the process:

     # rm -f config.sh Policy.sh 

    If you wish to install Perl as a non- root user within a nonstandard area, this is the place where we deviate from the path of root enlightenment. Pick your target installation directory (say, /u01/app/perl ) and then run the Configure program slightly differently, perhaps as an oracle or oramon user:

     $ ./Configure -Dprefix=/u01/app/perl 

    This tells Perl all it needs to know. When you run make install shortly, /u01/app/perl will become the parent directory where Perl will get installed.

    To get back to the main flow, root users will simply run the following:

     # sh Configure -de 

    (If you use sh Configure -des , the final "s" will take all the defaults for your system.)

  5. Answering the configuration questions will only take a few minutes (if in doubt, simply accept the defaults supplied). Once this Q&A session is completed, we're ready to begin the build and installation stages. Make sure any configuration errors are dealt with before you proceed with each next step (although you're unlikely to encounter any unless your machine or workstation is fairly nonstandard). Run through the next few steps:

     $ make $ make test $ make install 
  6. Once you've completed these, Perl should now be installed. Check it out with the perl -v command, as described earlier. Make sure it's the one you were expecting ” at least the 5.6 version.

2.1.2 Installing Perl on Win32

For Win32, although you can build from source (if you have the relevant Win32 compilers, or you can use Cygwin (as described later in this chapter), most people use the prebuilt ActiveState binaries, and that's what we'll do here.

Follow these steps:

  1. Consult the main portal page for ActiveState to see all of the latest information for installing ActivePerl (and many other products, including ActivePython and ActiveTcl):

    http://www.activestate.com

    You'll be able to go from there to pages like this:

    http://aspn.activestate.com/ASPN/Downloads/ActivePer
    http://aspn.activestate.com/ASPN/Downloads/ActivePerl/More
  2. You can download the latest binary executable build of ActivePerl from a web address such as the following:

    http://downloads.activestate.com/ActivePerl/Windows/5.6

    The download file will be named something like the following:

    ActivePerl-5.6.1.628-MSWin32-x86-multi-thread .msi
  3. You will need the appropriate MSI Microsoft Windows program installer. If it's not already available within your particular Win32 system (it comes as standard with Windows 2000), you'll need to obtain it. You'll generally find that the ActiveState site is the best place to direct you to the latest location and version for this purpose. We provide the current Microsoft addresses, but note that these do tend to move around a bit. If the following URLs are invalid, the ActiveState Perl download pages will contain the latest address:

    http://download.microsoft.com/download/platformsdk/wininst/1.1/NT4/EN-US/InstMsi.exe

    For WinNT

    http://download.microsoft.com/download/platformsdk/wininst/1.1/W9X/EN-US/InstMsi.exe

    For Win98 and Win95

    Install the MSI Microsoft installer itself by double-clicking on it in Windows Explorer (this installation may be almost instantaneous).

  4. Once the MSI program is confirmed as having been installed, double-click on the actual ActivePerl download, in Windows Explorer, as in Figure 2-1.

  5. After answering some questions about where you want Perl to be installed and where you accepted the defaults, Win32 Perl is then installed directly onto your system, in the standard Win32 way.

    Once the process is complete, you can then test your Perl installation with the perl -v test (also shown in Figure 2-1).

Because of the standard security architecture of Win32 systems, network shares and shared drives in a cluster are sometimes unavailable to the SYSTEM user. Therefore, any Perl scripts running from a scheduler or as a service will require that Perl be installed on a local drive. The C:\ drive is often a safe bet (this is generally the default), and this is where we always install Perl.

Figure 2-1. Installing ActivePerl
figs/pdba_0201.gif

We hope you won't encounter any problems getting Perl installed. But if you do, and you can't get the necessary help from the README and INSTALL files or here in this book, go to the Perl information sources listed in Chapter 1.

   


Perl for Oracle DBAs
Perl for Oracle Dbas
ISBN: 0596002106
EAN: 2147483647
Year: 2002
Pages: 137

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net