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.

29 comments:

Rugbymouth said...

Thank you so much, the compile and install went exactly as you described. Awesome reference!

Kapil said...

Thank you very much for such clear set of instruction!

Hagen said...
This comment has been removed by a blog administrator.
Hagen said...

I tried to install perl 5.8.8 and it give me some errors that I cant understand. I think it have to be with some *.h that I dont have , so I'm kinda lost

this what I have:

In file included from unixish.h:106,
from perl.h:2284,
from miniperlmain.c:36:
/usr/include/signal.h:111: error: parse error before "siginfo_t"
/usr/include/signal.h:113: error: parse error before "siginfo_t"
make: *** [miniperlmain.o] Error 1

any comments?

Andrew Watkins said...

Hagen,

Just compiled it on a SPARC with no real problems. Here is the information I used:

# cat /etc/release
Solaris 10 1/06 s10s_u1wos_19a SPARC
# which gcc
/usr/sfw/bin/gcc
# echo $PATH
/usr/sfw/bin:/usr/local/bin:/usr/bin:/bin:/usr/ccs/bin:/usr/sbin:/opt/sfw/bin:.
# echo $LD_LIBRARY_PATH
/usr/sfw/lib:/usr/local/lib:/opt/sfw/lib

Hope this may help.

Andrew

Hagen said...

Tnks so much but I'm on a X86 system, and I think I've solved my problem, It has to be with gcc configuration script from sunfreeware.com

tnks anyway

Patti said...

I have the sunfreeware gcc 3.4.6 installed and I get the below errors when I execute this command:

sh Configure -Dcc='gcc -B/usr/ccs/bin/' \
-Dprefix=/usr/local/perl587 -des

Checking whether your C compiler can cast large floats to int32.
In file included from try.c:7:
/usr/include/signal.h:26:24: sys/signal.h: No such file or directory
In file included from try.c:7:
/usr/include/signal.h:88: error: syntax error before '*' token
Checking whether your C compiler can cast negative float to unsigned.
In file included from try.c:7:
/usr/include/signal.h:26:24: sys/signal.h: No such file or directory
In file included from try.c:7:
/usr/include/signal.h:88: error: syntax error before '*' token
vprintf() found.

Andrew Watkins said...

Patti, I think you are missing files
check /usr/include/sys/signal.h.
It could be you are missing a few packages on you system.

Andrew

Patti said...

Thanks. That took care of it. I just didn't see that file was missing.

Bhumir Jhaveri said...

I am getting base64.o and base64.c error when i try to run make command.
what could be the reason??

waiting for early response!!!

Anonymous said...

I get this message qhen i run the command:
sh Configure -Dcc='gcc -B/usr/ccs/bin/' -Dprefix=/usr/local/perl587 -des

Which of these apply, if any? [solaris_2]
Operating system name? [solaris]
Operating system version? [2.10]
Build Perl for SOCKS? [n]
Use the PerlIO abstraction layer? [y]
Build a threading Perl? [n]
Build Perl for multiplicity? [n]
Use which C compiler? [gcc -B/usr/ccs/bin/]
Checking for GNU cc in disguise and/or its version number...
Now, how can we feed standard input to your C preprocessor...
Directories to use for library searches?
[/usr/local/lib /usr/lib /usr/ccs/lib]
What is the file extension used for shared libraries? [so]
Try to use long doubles if available? [n]
Checking for optional libraries...
What libraries to use? [-lsocket -lnsl -lgdbm -ldb -ldl -lm -lc]
What optimizer/debugger flag should be used? [-O]
Any additional cc flags? [-fno-strict-aliasing -pipe -I/usr/local/include]
Let me guess what the preprocessor flags are...
Any additional ld flags (NOT including libraries)? [ -L/usr/local/lib]
Checking your choice of C compiler and flags for coherency...
I've tried to compile and run the following simple program:


#include stdio.h
int main() { printf("Ok\n"); return(0); }

I used the command:

gcc -B/usr/ccs/bin/ -o try -O -fno-strict-aliasing -pipe -I/usr/local/include -L/usr/local/lib try.c -lsocket -lnsl -lgdbm -ldb -ldl -lm -lc
./try

and I got the following output:

ld: fatal: library -ldb: not found
ld: fatal: File processing errors. No output written to try
collect2: ld returned 1 exit status
I can't compile the test program.
You have a BIG problem. Shall I abort Configure [y]
Ok. Stopping Configure.
bash-3.00# gcc
gcc: no input files
bash-3.00# gcc -B/usr/ccs/bin/
gcc: no input files


I have tried everything but i still have this message.

Thanks

Andrew Watkins said...

I think you are missing libdb which is part of BerkeleyDB (db-4.2.52) from http://sunfreeware.com

On the other hand I would look at Cool Stack 1.2 at http://cooltools.sunsource.net/coolstack/

This is what I use now.

nigel said...

Really useful stuff. Thanks

Payman said...

Thank you Andrew. Your instructions are great. It shows the time you have taken to simplify it for others. much appreciated. God Bless.

chaitanya said...

hi, even I got the same error previously

ld: fatal: library -ldb: not found
ld: fatal: File processing errors. No output written to try
collect2: ld returned 1 exit status
I can't compile the test program.
You have a BIG problem. Shall I abort Configure [y]
Ok. Stopping Configure.
bash-3.00# gcc
gcc: no input files
bash-3.00# gcc -B/usr/ccs/bin/
gcc: no input files

then installed 4.2.52.NC-sol10-sparc-local patch from sunfreeware, now I get this issue

ld: fatal: file /usr/lib/libdb.a: Number of symbolic links encountered during pa th name traversal exceeds MAXSYMLINKS
ld: fatal: File processing errors. No output written to try
collect2: ld returned 1 exit status
I can't compile the test program.
(The supplied flags or libraries might be incorrect.)

You have a BIG problem. Shall I abort Configure [y]
Ok. Stopping Configure.

I couldn't resolve this issue

Jesse C. said...

I have been trying to install the latest version of Perl (5.8.9) on my SPARC system. I went through that portion of the instructions several times and they seem to run except that the target folder and the executable do not seem to be generated.

make test passes and make install places the man pages

The only thing that I have seen that looks odd is:

make: Warning: Both `makefile' and `Makefile' exist

This message shows up several times during the process.

Andrew Watkins said...

Jesse, Just ran steps 1 & 2 with no problems I did run as a normal user after creating /usr/local/perl589 as root
Information (Solaris 10 10/08):
# uname -a
SunOS hermes 5.10 Generic_138888-01 sun4u sparc SUNW,Ultra-4
# which make
/usr/ccs/bin/make
# /usr/sfw/bin/gcc -v
gcc version 3.4.3

root# mkdir /usr/local/perl589
root# chown andrew /usr/local/perl589
andrew% 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

% gzip -dc perl-5.8.9.tar.gz | tar xf -
% cd perl-5.8.9
% sh Configure -Dcc='gcc -B/usr/ccs/bin/' -Dprefix=/usr/local/perl589 -des
% make
% make test
% make install
% /usr/local/perl589/bin/perl -v
This is perl, v5.8.9 built for sun4-solaris

Also, ignore the Make file error, since I get that.

Have you tried downloading the binary from http://www.sunfreeware.com
Andrew

Anonymous said...

Can you please list all packages that needed to be installed from the Sol10 Companion CD in order to run these scripts as they rely on some packages (gcc, etc)
Thanks

Andrew Watkins said...

I did install all the Companion since it is the easy option, but having a closer look, I don't think many /opt/sfw packages is used, since the GCC I use is the /usr/sfw.

Andrew

Anonymous said...

Thanks a lot for this blog.
with your help I could install Perl 5.10 to Solaris + DBI + DBD for Oracle-Perl connection

Gusztav from Hungary

vfdvgf said...

Your Best Choice! wow power leveling and wow gold wow gold

Anonymous said...

Trying to install mod_perl-2.0.4 on Sun Solaris 10 x86 with following error:

bash-3.00# perl Makefile.PL MP_APXS=/usr/local/apache2/bin/apxs

bash-3.00# make
cd "src/modules/perl" && make
gcc -B/usr/ccs/bin/ -I/downloads/Perl Modules/mod_perl-2.0.4/src/modules/perl -I/downloads/Perl Modules/mod_perl-2.0.4/xs -I/usr/local/apache2/include -I/usr/local/apache2/include -I/usr/local/apache2/include -fno-strict-aliasing -pipe -I/usr/local/include -DPERL_USE_SAFE_PUTENV -I/usr/local/perl510/lib/5.10.0/i86pc-solaris/CORE -DMOD_PERL -DMP_COMPAT_1X -DSOLARIS2=10 -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT -D_LARGEFILE64_SOURCE -O -fPIC \
-c mod_perl.c && mv mod_perl.o mod_perl.lo
gcc: Modules/mod_perl-2.0.4/src/modules/perl: No such file or directory
gcc: Modules/mod_perl-2.0.4/xs: No such file or directory
*** Error code 1
make: Fatal error: Command failed for target `mod_perl.lo'
Current working directory /downloads/Perl Modules/mod_perl-2.0.4/src/modules/perl
*** Error code 1
make: Fatal error: Command failed for target `modperl_lib'
bash-3.00#

Any Idea's

Anonymous said...

Anyone leaving instructions on the net should follow your example! Very clear and in particular the environment variables to set. Once I set the Korn shell then I was able to install Perl 5.8.7 "Threaded" and the DBI and DBD::Oracle modules. Thank you very much.

Monosabio@aol.com

Viagra Canada said...

Thanks for giving these tips for the few, but faithful users of Solaris. I will read the other articles of your blog. Nice entry.

somashekhara said...

hi
thanks for ur installation procedure
I have installed it but when i give perl -v still its showing me older 5.6.1 version.
if i set path temporarily it ll show 5.8.7 version...plz help me

Andrew Watkins said...

Don't forget that your PATH has /usr/bin in it and perl is there and your scripts may have /usr/bin/perl on the first line:

# which perl
/usr/bin/perl
# perl -v
This is perl, v5.8.4
Alter PATH see Step (1):
# export PATH=/usr/local/bin:$PATH
# which perl
/usr/local/bin/perl
# perl -v
This is perl, v5.8.0

somashekhara said...

thnks for the reply...
actually i am installing in solaris 9..... after setting path it temporarily refletcs newer version..but once i give exit...it ll not reflect... and in the meanwhile i deleted older version 5.6.1 also.. how to set the path permanntly?

Ramesh Babu said...

Hi,
I've compiled Apache2.2.14, 20 and 22 versions on Solaris10 x86 server with below configuration options. When I tried to run apache with proxy loadbalancer it is throwing core dump as below. Could some one please help why I'm getting core dump error only proxy loadbalancer instances.

Configure options: -
./configure --prefix=/opt/httpd-2.2.22_32bit --enable-proxy --enable-rewrite --enable-mods-shared=all --enable-cache --enable-file-cache --enable-mem-cache --enable-cgid --enable-access --enable-auth --enable-imap --enable-deflate --with-mpm=worker --with-included-apr

Proxy details in httpd.conf: -
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so

RewriteRule ^/(.*) balancer://prd-admin/$1 [P,L]


BalancerMember http://xxx.xxx.xxx.xxx:yyyy
BalancerMember http://xxx.xxx.xxx.xxx:yyyy


Error: -
child pid 10628 exit signal Segmentation fault (11), possible coredump in /opt/httpd-2.2.22_32bit_MPM

Note: - The apache instances are running in httpd.conf doesn't contain proxy loadbalancers.

Many Thanks in advance for your help.

Regards,
Ramesh

Anonymous said...

Thank you for the detailed instruction. While running the step 5, make, I got the following error messages:
■cd "src/modules/perl" && make
■cc -I/usr/local/src/mod_perl-2.0.7/src/modules/perl -I/usr/local/src/mod_perl-2.0.7/xs -I/usr/apache2/include -I/usr/apache2/include -I/usr/sfw/include -I/usr/apache2/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -xarch=v8 -D_TS_ERRNO -I/usr/perl5/5.8.4/lib/sun4-solaris-64int/CORE -DMOD_PERL -DMP_COMPAT_1X -DSOLARIS2=10 -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -xO3 -xspace -xildoff -KPIC \
■-c mod_perl.c && mv mod_perl.o mod_perl.lo
■ld.so.1: gcc: fatal: libintl.so.8: open failed: No such file or directory
■Killed
■*** Error code 137
■make: Fatal error: Command failed for target `mod_perl.lo'
■Current working directory /usr/local/src/mod_perl-2.0.7/src/modules/perl
■*** Error code 1
■make: Fatal error: Command failed for target `modperl_lib'

I have no idea about the error. Could you kindly help check? thank you in advance.

Ray