Fearthepenguin.net

Diary of a Lazy SysAdmin

Skip to: Content | Sidebar | Footer

Packaging Apache for Solaris 10

## NOTE: These instructions are fairly dated. They should give you a rough idea of how to compile based on what your needs are. For instance, I’m fairly certain this process won’t work properly if you require mod_perl. Unfortunately compiling Apache and mod_perl [or anything else in Solaris really] is such a pain in the @ss, I’ve never gotten it to work reliably and consistently. Which is why we’ve been largely migrating all of our servers to Linux so it’s not likely this document will be updated.

Packaging
Apache for Solaris 10 Sparc

This will give a step through of how I compiled and
packaged Apache for Solaris 10 Sparc. Comments will show what needs to
be different to package Apache for the AMD64 environment. The
assumption is made that all the Solaris packages and libraries required
are already installed [ie. gcc, gmake, etc], otherwise the compile will
fail.

Keep in mind that the end result is a fully 64-bit version of Apache. I’ve recently had problems trying to get a 32-bit version working properly, specifically involving issues with openssl. I’ll post some more info once I manage to get it working.

The package will be called MYapache, will include Apache 2.2.9 +
OpenSSL, and will use Solaris’s SMF functionality to handle the service.

Decide where you are going to install Apache. In our case we use
/opt/apache
. Make sure /opt/apache
either doesn’t exist, or is empty. Otherwise any files that already
exist in there will be included in the package.

Creating
the Software:

  • Create a build environment.
    mkdir -p /admin/src/builds/apache
    mkdir -p /admin/src/work/apache
  • Make sure the appropriate environment variables are set

CC="gcc -m64"
MAKE="gmake"
CFLAGS="-O2"
LDFLAGS="-s -L/usr/lib/sparcv9 -R/usr/sfw/lib/sparcv9 -R/usr/lib/sparcv9 -R/usr/sfw/lib/sparcv9

  • NOTE: For AMD64 – LDFLAGS=”-s -R/usr/sfw/lib/amd64″/sparcv9″
  • Download the source for both apache and openssl. I just
    download it straight to /admin/src/builds/apache
  • Unpack

gunzip httpd-2.2.9.tar.gz && tar xf httpd-2.2.9.tar
gunzip openssl-0.9.8h.tar.gz && tar xf openssl-0.9.8h.tar

  • Configure and compile openssl

cd /admin/src/builds/apache/openssl-0.9.h
./Configure solaris64-sparcv9-gcc --prefix=/opt/apache

  • NOTE for AMD64 use: ./Configure solaris64-x86_64-gcc --prefix=/opt/apache

gmake
op shell gmake install

  • We use ‘op’ instead of sudo. The point is, become root,
    then run gmake install
  • Configure and install apachecd /admin/src/builds/apache/httpd-2.2.9
    ./configure --prefix=/opt/apache --enable-modules=all --enable-ssl --enable-so --with-ssl=/opt/apache
    gmake
    op shell gmake install
  • Now we need the SMF manifest.
      • Once the software is installed, you need to create a table
        of contents to be used for the package creation tool.
      • At the TOP of the prototype file, add the following
        entries:
      • At the BOTTOM of the prototype file, add the following
        entries:
      • Now we need to create the other files, all in /admin/src/work/apache/.
      • pkginfo
        should contain the following, edited for your requirements

mkdir -p /opt/apache/conf/smf
cd /opt/apache/conf/smf
vi /opt/apache/conf/README

# You can use this README
if you like: RIGHT Click and Click “Save As”
vi /opt/apache/conf/apache.xml
# You can
use this apache.xml if you
like. You need to use wget, or  Right-click and Save the file
chmod 444 /opt/apache/conf/apache.xml

Creating the package configuration files :
This part of the process should all be done as root.

cd /opt
find apache -print > /tmp/files
cat /tmp/files | pkgproto > /admin/src/work/apache/prototype

Now we need to add some entries into the prototype file. Also, make sure
the ownership and file perms listed in the prototype file are correct
for your needs.

i pkginfo
i postinstall
i preremove

d none apache/conf/smf 0755 root root
f none apache/conf/smf/apache.xml 0444 root sys
f none apache/conf/smf/README 0444 root root
d none /var/svc/manifest/application/apache 0755 root sys
s none /var/svc/manifest/application/apache/apache.xml=/opt/apache/conf/smf/apache.xml

PKG=MYapache
NAME=Apache 2.2.x (sol10)
ARCH=sparc
VERSION=2.2.9
CATEGORY=system
BASEDIR=/opt

    • preremoveDownload this preremove script (Right Click – Save As)
      • Install this script in /admin/src/work/apache
      • Name it “preremove”

      Creating the Package

      Now that the configuration files are ready, you can create the package.
      The package will be created as a directory in /tmp. Then we’ll need to
      convert the packing dir into a .pkg file.

      cd /opt
      pkgmk -o -r /opt -d /tmp -f /admin/src/work/apache/prototype
      cd /tmp
      pkgtrans -s /tmp /tmp/MYapache.pkg MYapache

      • #Substitute the name of your package for MYapache above

Once you test that the package works as expected, you can clean up
mv /tmp/MYapache.pkg /admin/src/packages/complete/SPARC/

#or /admin/src/packages/complete/AMD64

rm -rf /tmp/MYapache

Yay! You’re done!

Comments

Comment from Prem
Time January 20, 2009 at 10:52 am

This is a great article and almost close to what I needed. I am trying to do the same with Sun compiler , could you please give me the right PATH that needs to be set and the various tools i need to install before starting to compile.

Comment from ender
Time January 23, 2009 at 3:24 pm

I don’t really know what you need to get it to compile with Sun’s compiler. I assume you’d have to download and install Sun Studio [free for the latest two versions] from Sun’s website. The PATH will depend completely on where you install Sun Studio.

Sorry I can’t be of more help…

Comment from Vim
Time February 3, 2009 at 8:57 am

Could you please post the README and apache.xml file.

Comment from ender
Time April 14, 2009 at 2:48 pm

Sorry for the delay. I finally dug up the README and apache.xml file and fixed the links. Enjoy…

Write a comment