Perl Modules on FreeBSD 7

Prerequisites:

FreeBSD (Base + Autoconf, Automake, Bash and GCC)
MySQL (If you install DBD::mysql)

Overview:
 Optional - Setup "Direct connection to CPAN" using CPAN Shell
 Step #1   - Install DBI
 Step #2   - Install DBD::mysql
 Step #3
   - Install SNMP_Session
 Step #4
   - Install Net::SNMP
 Step #5
   - Install CGI.pm
 Step #6   - Install SNMP::Info
 Step #7   - Install HTML::HeadParser
 Step #8   - Install URI.pm
 Step #9   - Install libwww
 Step #10 - Install BSD::Resource
 Step #11
- Install additional modules that Ernie advises!

Optional

Setup "Direct connection to CPAN" using CPAN Shell

Home: 

 http://www.cpan.org

# Note: If you are behind a proxy server read this

# Prerequisite: Perl CPAN Shell
 


#
 Launch the CPAN shell anytime
/usr/bin/perl -MCPAN -e shell

#
 Install HTTP::Date
install HTTP::Date

# Install DBI (via CPAN Shell now or at Step #1 coming up in the very next section)
install DBI

# After installation, exit CPAN shell
exit



#
 CPAN shell commands to know - just FYI
?           <-- Display Help Menu
reload cpan <-- Reloads CPAN interface
i /DBD/     <-- Searches for any module with "DBD" in the name
install DBI <-- Installs module "DBI"

 

Step #1 - You can safely skip this DBI step if you installed DBI via the CPAN shell above

Install DBI

Home:

 http://dbi.perl.org

# Change to your desired "source" storage directory
cd /usr/src

# Download

fetch http://search.cpan.org/CPAN/authors/id/T/TI/TIMB/DBI-1.59.tar.gz

# Unzip and Untar
tar xvf DBI-?.??.tar.gz


# Configure
cd DBI-?.??
perl Makefile.PL

#
 Compile
make

#
 Install
make install


Step #2 - Install DBD::mysql from source as shown below, not from the CPAN shell

Install DBD::mysql

Home:

 http://search.cpan.org/dist/DBD-mysql/lib/DBD/mysql.pm

#NOTE: This module requires that you have already installed MySQL Server into /opt/mysql

# Change to your desired "source" storage directory
cd /usr/src

# Download

fetch http://search.cpan.org/CPAN/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.008.tar.gz

# Unzip and Untar
tar xvf DBD-mysql-?.???.tar.gz

# Configure
cd DBD-mysql-?.???
perl Makefile.PL --mysql_config=/usr/local/bin/mysql_config --ssl

#
 Compile
make

#
 Install
make install

 


Step #3

SNMP_Session

Home:

 http://www.switch.ch/misc/leinen/snmp/perl/

# Change to your desired "source" storage directory
cd /usr/src

# Download

fetch http://www.switch.ch/misc/leinen/snmp/perl/dist/SNMP_Session-1.12.tar.gz

# Unzip and Untar
tar xvf SNMP_Session-?.??.tar.gz


# Configure
cd SNMP_Session-?.??
perl Makefile.PL

#
 Compile
make

#
 Install
make install


Step #4

Net::SNMP

Home:

 http://search.cpan.org/~dtown/Net-SNMP/lib/Net/SNMP.pm

# Change to your desired "source" storage directory
cd /usr/src

# Download

fetch http://search.cpan.org/CPAN/authors/id/D/DT/DTOWN/Net-SNMP-5.2.0.tar.gz

# Unzip and Untar
tar xvf
Net-SNMP-?.?.?.tar.gz

# Configure
cd Net-SNMP-?.?.?
perl Makefile.PL

#
 Compile
make

#
 Install
make install


Step #5

CGI.pm

Home:

 http://search.cpan.org/~lds/CGI.pm/CGI.pm

# Launch the CPAN shell anytime
/usr/bin/perl -MCPAN -e shell

#
 Install FCGI
install FCGI

# After installation, exit CPAN shell
exit

# Change to your desired "source" storage directory
cd /usr/src

# Download

fetch http://search.cpan.org/CPAN/authors/id/L/LD/LDS/CGI.pm-3.42.tar.gz

# Unzip and Untar

tar xvf CGI.pm-?.??.tar.gz


# Configure
cd CGI.pm-?.??
perl Makefile.PL

#
 Compile
make

#
 Install
make install


Step #6

SNMP::Info

Home:

 http://snmp-info.sourceforge.net

# Change to your desired "source" storage directory
cd /usr/src


# Download

fetch http://easynews.dl.sourceforge.net/sourceforge/snmp-info/SNMP-Info-2.00.tar.gz

# Unzip and Untar
tar xvf SNMP-Info-?.??.tar.gz


# Configure
cd SNMP-Info-?.??
perl Makefile.PL

#
 Compile
make

#
 Install
make install


Step #7

HTML::HeadParser

Home:

 http://search.cpan.org/dist/HTML-Parser/lib/HTML/HeadParser.pm

# Change to your desired "source" storage directory
cd /usr/src

# Download

fetch http://search.cpan.org/CPAN/authors/id/G/GA/GAAS/HTML-Parser-3.56.tar.gz

# Unzip and Untar
tar xvf HTML-Parser-?.??.tar.gz


# Configure
cd HTML-Parser-?.??
perl Makefile.PL

#
 Compile
make

#
 Install
make install


Step #8

URI.pm

Home:

 http://search.cpan.org/~gaas/URI/URI.pm

# Change to your desired "source" storage directory
cd /usr/src

# Download

fetch http://search.cpan.org/CPAN/authors/id/G/GA/GAAS/URI-1.37.tar.gz

# Unzip and Untar

tar xvf URI-?.??.tar.gz


# Configure
cd URI-?.??
perl Makefile.PL

#
 Compile
make

#
 Install
make install


Step #9

libwww-perl

Home:

http://search.cpan.org/dist/libwww-perl/

# Change to your desired "source" storage directory
cd /usr/src

# Download

fetch http://search.cpan.org/CPAN/authors/id/G/GA/GAAS/libwww-perl-5.817.tar.gz

# Unzip and Untar
tar xvf libwww-perl-?.???.tar.gz


# Configure
cd libwww-perl-?.???
perl Makefile.PL

#
 Compile
make

#
 Install
make install


Step #10

BSD::Resource

Home:

 http://search.cpan.org/~jhi/BSD-Resource/Resource.pm

# Change to your desired "source" storage directory
cd /usr/src

# Download

fetch http://search.cpan.org/CPAN/authors/id/J/JH/JHI/BSD-Resource-1.2901.tar.gz


# Unzip and Untar

tar xvf BSD-Resource-?.*.tar.gz


# Configure
cd BSD-Resource-?.*
perl Makefile.PL

#
 Compile
make

#
 Install
make install


Step #11

Additional PERL Modules via CPAN Shell

Note:

Over time I find modules that are useful and that I include by default now to avoid pain later!

# Launch the CPAN shell and add more modules!
/usr/bin/perl -MCPAN -e shell
install Digest::MD5
install Digest::SHA1
install Net::Telnet
install Time::HiRes
install Net::Server
install Unicode::Map
install Jcode
install Spreadsheet::WriteExcel
install OLE::Storage_Lite
force install Proc::ProcessTable
install IO::Scalar
install Spreadsheet::ParseExcel
exit


Step #12

require "cgi-lib.pl";

Home:

 http://cgi-lib.berkeley.edu

# Change to the FreeBSD Ports directory for cgi-lib.pl
cd /usr/ports/www/cgi-lib.pl

# Install
make install

 

# Below is an example CGI that uses PERL that you can use later after you have Apache installed
# A basic html page with form fields that submits to a pl script that reads the values passed to it

# Example web page simple.html (that calls simple.pl)
vi /usr/local/www/data/simple.html

# Example PERL CGI Script simple.pl
vi /usr/local/www/cgi-bin/simple.pl

# File Permissions
chmod a+x /usr/local/www/cgi-bin/simple.pl
chown www:www /usr/local/www/data/simple.html
chown www:www /usr/local/www/cgi-bin/simple.pl

# Edit Apache config to allow cgi and pl files to execute by editing, un-commenting and adding 3 things
vi /usr/local/etc/apache22/httpd.conf
Options FollowSymLinks ExecCGI
ScriptAlias /cgi-bin/ "
/usr/local/www/cgi-bin/"
AddHandler cgi-script .cgi .pl

# Restart Apache
/usr/local/sbin/apachectl -k restart

# Test out the script
http://YourServer/simple.html

# Clean up
cd /usr/ports/www/cgi-lib.pl
make clean