Tuesday, November 22, 2005

Installing Perl & Apache on Solaris 10

One of the first things you will want to setup on your new Solaris/OpenSolaris operating system is a web server, even though Solaris now comes with Perl and Apache installed by default, it is still worth installing your own version. New versions of Perl and Apache will always be ahead of the Solaris version, plus you will never damage the pre-installed version.

The procedure has been test on:
  • Solaris 10 3/05 SPARC & X86
  • Fully Patched
  • Installed Solaris Software Companion (/opt/sfw)
The following steps will install:
  • perl 5.8.7
  • basic perl modules used by apache
  • Apache 1.3.34 (Version 1 is still widely used)

Step 1) Setup environment vaiables (Using csh):
# setenv PATH \
    /usr/sfw/bin:/usr/local/bin:/usr/bin:/bin
# setenv PATH \
    ${PATH}:/usr/ccs/bin:/usr/sbin:/opt/sfw/bin:.
# setenv LD_LIBRARY_PATH \
    /usr/sfw/lib:/usr/local/lib:/opt/sfw/lib
Step 2) Configure and install perl (Install location will be /usr/local/perl587)
# gtar xfz perl-5.8.7.tar.gz
# cd perl-5.8.7
# rm -f config.sh Policy.sh
# sh Configure -Dcc='gcc -B/usr/ccs/bin/' \
    -Dprefix=/usr/local/perl587 -des
# make
# make test
# make install
# cd ..
# cp /usr/local/perl587/bin/perl /usr/local/bin

Step 3) Check perl has been install and is in your path.
# rehash
# which perl
/usr/local/bin/perl
# perl -V
Summary of my perl5 (revision 5 version 8 subversion 7) configuration:
Platform:
osname=solaris, osvers=2.10, archname=sun4-solaris
... a lot more stuff....
Step 4) Install some basic perl modules (down load from: http://search.cpan.org/)
# gtar xfz HTML-Tagset-3.04.tar.gz
# cd HTML-Tagset-3.04
# perl Makefile.PL
# make
# make test
# make install
# cd ..

# gtar xfz HTML-Parser-3.46.tar.gz
# cd HTML-Parser-3.46
# perl Makefile.PL
# make
# make test
# make install
# cd ..

# gtar xfz URI-1.35.tar.gz
# cd URI-1.35
# perl Makefile.PL
# make
# make test
# make install
# cd ..

# gtar xfz Compress-Zlib-1.41.tar.gz
# cd Compress-Zlib-1.41
# perl Makefile.PL
# make
# make test
# make install
# cd ..

# gtar xfz libwww-perl-5.803.tar.gz
# cd libwww-perl-5.803
# perl Makefile.PL -n
# make
# make test
# make install
# cd ..
Step 5) Set up mod_perl (Need to extract apache files first, since it updates them):
# gtar xfz apache_1.3.34.tar.gz
# gtar xfz mod_perl-1.29.tar.gz
# cd mod_perl-1.29
# perl Makefile.PL \
    APACHE_SRC=../apache_1.3.34/src \
    DO_HTTPD=1 USE_APACI=1 \
    PREP_HTTPD=1 EVERYTHING=1
# make
# make install
Step 6) Previous step did not compile apache. I prefer it that way:
# ./configure --prefix=/usr/local/Apache/1334 \
    --enable-module=info \
    --enable-module=most --enable-shared=max \
    --enable-module=status \
    --enable-module=so \
    --activate-module=src/modules/perl/libperl.a

# make
# make install
Step 7) We will pause here, since if you try to start the apache server you will get an error if this is on a SPARC platform.
# /usr/local/Apache/1334/bin/apachectl start

Syntax error on line 210 of /usr/local/Apache/1334/conf/httpd.conf:

Cannot load /usr/local/Apache/1334/libexec/mod_negotiation.so into server: ld.so.1: httpd: fatal: relocation error: file /usr/local/Apache/1334/libexec/mod_negotiation.so: symbol __floatdisf: referenced symbol not found
/usr/local/Apache/1334/bin/apachectl start: httpd could not be started

Step 8) SKIP to "step 9" if you are on a x86 platform.
# cd src/modules/proxy
# ld -G -o mod_proxy.so mod_proxy.lo \
    `gcc -print-libgcc-file-name`
# cd ../standard
# ld -G -o mod_negotiation.so mod_negotiation.lo \
    `gcc -print-libgcc-file-name`
# cd ../../..
# make
# make install
Step 9) Test that it all works
# /usr/local/Apache/1334/bin/apachectl start
http://localhost:8080
You will need to read other documention about configurations changes you can make to apache, but now you have a working version to use.

Hope it will helped some people and if there are any errors or commenst please be in contact.