PHP for Apache2 on Solaris 10

por | 30 enero, 2007

http://meljr.com/~meljr/PHPSolaris10.html

Version 1.02 January 23, 2006

by: Mel Lester Jr. ([email protected])

  1. Log into the global zone as root and ensure that /opt/csw/bin and /usr/sfw/bin are in $PATH
    global# echo $PATH
    /opt/csw/bin:/usr/sfw/bin:/usr/sbin:/usr/bin:/usr/openwin/bin:/usr/dt/bin:/usr/ccs/bin
    
    
    
    
    
  2. Install pkg-get from BlastWave and test by using pkg-get to install the gnu autoconf, automake and gsed packages.
    global# pkg-get -i autoconf
    ...
    global# which autoconf && autoconf --version | head -2
    /opt/csw/bin/autoconf
    autoconf (GNU Autoconf) 2.59
    Written by David J. MacKenzie and Akim Demaille.
    
    global# pkg-get -i automake
    ...
    global# which automake && automake --version | head -2
    /opt/csw/bin/automake
    automake (GNU automake) 1.8.3
    Written by Tom Tromey <[email protected]>.
    
    global# pkg-get -i gsed
    ...
    global# which gsed && gsed --version | head -2
    /opt/csw/bin/gsed
    GNU sed version 4.1.4
    Copyright (C) 2003 Free Software Foundation, Inc.
    
  3. Verify availability of other Open Source Software Required to install PHP.
    global# which gcc && gcc --version | head -2
    /usr/sfw/bin/gcc
    gcc (GCC) 3.4.3 (csl-sol210-3_4-branch+sol_rpath)
    Copyright (C) 2004 Free Software Foundation, Inc.
    
    global# which gmake && gmake --version | head -2
    /usr/sfw/bin/gmake
    GNU Make 3.80
    Copyright (C) 2002  Free Software Foundation, Inc.
    
    global# which flex && flex --version | head -2
    /usr/sfw/bin/flex
    flex version 2.5.4
    
    global# which bison && bison --version | head -2
    /usr/sfw/bin/bison
    bison (GNU Bison) 1.875
    Written by Robert Corbett and Richard Stallman.
    
    global#  which gm4 && gm4 --version | head -2
    /opt/csw/bin/gm4
    GNU M4 1.4.3
    Written by Rene' Seindal.
    
    global# which perl && perl -v | head -2
    /opt/csw/bin/perl
    
    This is perl, v5.8.7 built for sun4-solaris-thread-multi
    
    global# which gunzip && gunzip -V | head -2
    /usr/bin/gunzip
    gunzip 1.3.3-patch.1
    (2002-03-08)
    
    global# which gtar && gtar --version | head -2
    /usr/sfw/bin/gtar
    tar (GNU tar) 1.14
    Copyright (C) 2004 Free Software Foundation, Inc.
        
  4. Test the Open Source tools by builing libxml2 from source:

    Download the latest version from: xmlsoft.org

         global#gunzip -cd libxml2-2.6.23.tar.gz | gtar xvpf -
         global#cd libxml2-2.6.23
         global#./configure
         ...
         global#gmake
         ...
         global#gmake install
         ...
        
  5. If the file /etc/apache2/httpd.conf doesn’t exist:
          global# cp /etc/apache2/httpd.conf-example /etc/apache2/httpd.conf
         

    Edit /etc/apache2/httpd.conf

    • Set ServerName if necessary (default is 127.0.0.1)
    • Set ServerAdmin to a valid email address
  6. Download and Compile the latest production version of PHP.
         global# pwd
         /build
         global# gunzip -cd  php-5.1.2.tar.gz | gtar xvpf -
          ...
         global# cd  php-5.1.2
         global# ./configure --with-apxs2=/usr/apache2/bin/apxs \
         --with-mysql=/usr/sfw --enable-dbase \
         --with-libxml-dir=/usr/local \
         --with-config-file-path=/etc/apache2
         ...
         global# gmake   
         ...
         global# gmake install   
         Installing PHP SAPI module:       apache2handler
         /var/apache2/build/instdso.sh SH_LIBTOOL='/var/apache2/build/libtool' libphp5.la /usr/apache2/libexec
         /var/apache2/build/libtool --mode=install cp libphp5.la /usr/apache2/libexec/
         cp .libs/libphp5.so /usr/apache2/libexec/libphp5.so
         chmod +x /usr/apache2/libexec/libphp5.so
         cp .libs/libphp5.lai /usr/apache2/libexec/libphp5.la
         libtool: install: warning: remember to run `libtool --finish /build/php-5.1.2/libs'
         chmod 755 /usr/apache2/libexec/libphp5.so
         [activating module `php5' in /etc/apache2/httpd.conf]
         Installing PHP CLI binary:        /usr/local/bin/
         Installing PHP CLI man page:      /usr/local/man/man1/
         Installing build environment:     /usr/local/lib/php/build/
         Installing header files:          /usr/local/include/php/
         Installing helper programs:       /usr/local/bin/
           program: phpize
           program: php-config
         Installing man pages:             /usr/local/man/man1/
           page: phpize.1
           page: php-config.1
         Installing PEAR environment:      /usr/local/lib/php/
         [PEAR] Archive_Tar    - installed: 1.3.1
         [PEAR] Console_Getopt - installed: 1.2
         pear/PEAR can optionally use package "pear/XML_RPC" (version >= 1.4.0)
         [PEAR] PEAR           - installed: 1.4.6
         Wrote PEAR system config file at: /usr/local/etc/pear.conf
         You may want to add: /usr/local/lib/php to your php.ini include_path
         Installing PDO headers:          /usr/local/include/php/ext/pdo/
        
  7. Copy the file, php.ini-dist from /build/php-5.1.2 in Global Zone to /etc/apache2/php.ini in the Zone where you want Apache2 to load the PHP module.
         global# cp php.ini-dist /zones/zone0/root/etc/apache2/php.ini
        
  8. Log in as root to the zone where Apache2 and the PHP module will run.
         almanac# zlogin zone0
         [Connected to zone 'zone0' pts/4]
         Last login: Thu Jan 19 18:05:50 on pts/5
         Sun Microsystems Inc.   SunOS 5.10      Generic January 2005
         web# cd /etc/apache2
        
  9. Edit the configuration files
    • Edit the php.ini file to set PHP options.
    • Edit the httpd.conf file to load the PHP module.

      The path on the right hand side of the LoadModule statement must point to the path of the PHP module on your system. The gmake install from above may have already added this for you, but be sure to check.

             LoadModule php5_module libexec/libphp5.so
            

      Have Apache2 parse the .php extension as PHP.

            AddType application/x-httpd-php .php
            
  10. Start Apache2 and Test.
         web# svcadm enable apache2
         web# svcs | grep -i apache2
         online         18:07:10 svc:/network/http:apache2