Tuesday, January 24, 2006

Installing Perl Modules in FreeBSD

I needed the following modules to be installed

Digest::SHA1
Digest::HMAC

Net::DNS
Time::HiRes
HTML::Tagset
HTML::Parser

Pod::Usage
Parse::Syslog
Statistics::Distributions

There are 3 main ways of doing it

1. The old fashioned way (CPAN) - Go to http://www.cpan.org, download the needed module, read the "INSTALL" file and away you go.

2. Using the pkg_add utility - This is the best method because the pkg_add utility AUTOMATICALLY installs any dependencies that may be needed for these Perl modules to be installed. This saves lots of time and hassle.

As root, run the following commands:

pkg_add -r p5-Time-HiRes
pkg_add -r p5-Net-DNS
pkg_add -r p5-Digest-SHA1
pkg_add -r p5-Digest-HMAC
pkg_add -r p5-HTML-Tagset
pkg_add -r p5-HTML-Parser
pkg_add -r p5-Parse-Syslog
pkg_add -r p5-Pod-Parser
pkg_add -r p5-Statistics-Distributions

3. The easy way (The Ports Collection) - The Freebsd ports collection has made a lazy man out of me. They make all this crap so easy.

On my server, I found the needed ports in the following locations:

Time::HiRes - /usr/ports/devel/p5-Time-HiRes
Net::DNS - /usr/ports/dns/p5-Net-DNS
Digest::SHA1 - /usr/ports/security/p5-Digest-SHA1
Digest::HMAC - /usr/ports/security/p5-Digest-HMAC
HTML-Tagset - /usr/ports/www/p5-HTML-Tagset
HTML::Parser - /usr/ports/www/p5-HTML-Parser
Pod::Usage - /usr/ports/textproc/p5-PodParser
Parse::Syslog - /usr/ports/textproc/p5-Parse-Syslog
Statistics::Distributions - /usr/ports/math/p5-Statistics-Distributions

Simply cd into each packages directory as shown above and run: make install && make clean

Note: If you find that the directory "/usr/ports" does not exist, it means you don't have the ports collection. You can get the latest Freebsd ports tree at ftp://ftp.freebsd.org/pub/FreeBSD/ports/ports/ports.tar.gz (anonymous login)

Damn! Now wasn't that easy?

FreeBSD FAQ

I have FreeBSD installed and with it I had couple of issues.

Problem No. 1

When I installed apache using the ports

cd /usr/ports/www/apache21/

make install clean

It had also fetched tcpwrappers which I was not aware of.

When I tried connecting to it locally it wont allow me to connect it says

Connection refused

So I had to add this entry to /etc/hosts.allow

sshd :192.168.0.10: ALLOW

192.168.0.10 is the system from where I am connecting.

Note : By default freeBSD root access through ssh is disabled.

Also make sure your nameserver entries are properly configured in your freebsd.

/etc/resolv.conf

If its able to resolve to external domains.

After adding the above entry I am able to ssh from 192.168.0.10

Problem No. 2

Now its the turn of http... when I try to do a http://192.168.0.10

It says Connection refused ... this was wired since I was using http service for some time now with my freebsd and all was well with it.

The settings in

/usr/local/etc/apache2/httpd.conf

were fine this was Listenning to port 80 on FreeBSD lnc0

/usr/local/etc/rc.d/apache2.sh start

wont start either.

I could see netstat did not show http running.

I tried

/usr/local/sbin/httpd this worked but is not a proper way to start http

After searching forums and IRC, I have added

apache2_enable="YES"

to

/etc/rc.conf

I used apache2 since in rc.d its mentioned

/usr/local/etc/rc.d/apache2.sh


freebsd# /usr/local/etc/rc.d/apache2.sh start
Starting apache2.

Now the http service is working