Sample Linux-Apache-PHP-DB2 installation instructions

Below is detailed customized installation for Linux-DB2 –

1. Suggested PC configuration for medium sized installations

 – P4 or above
– 256 MB or above RAM
– 80GB HD (RAID 5)
– Back up drive

2. CDs for Installations

 You will have to get RH linux  CDs, DB2  UDB CD and source files for the following linux modules –

 – Apache
– SSL
– SSH
– Ming
– LDAP
– PHP
– GD
– ZLIB
– LIBPNG
– LIBADOBE
– LIBJPEG
– IMAP
– LIBMCRYPT
– MCRYPT
– MHASH

 3. Installation instructions

– Put RH Linux CD 1 into the cd rom and then reboot the PC

– The PC reboots and the installation screen for Linux appears. Press Enter

– The installer will now take you to the main install section

– Follow the instructions till you reach partitioning HD

–Creating Partitions

– Select option ‘Let system automatically partition it for you’
– Cross check the partition size with the total HD size

– Next when you reach firewall section, select no firewall option

– Put CD no.2 when its asked for

– Towards the end of the installation, select boot in text mode.

– After the installation, take out the CD and the machine gets rebooted.

4. Setting up the IP address, Gateway and hostname

 a. Setting up IP address

  – Edit the file /etc/sysconfig/network-scripts/ifcfg-eth0, add the following the entries. Put the appropriate entries for   IPADDR, NETMASK, NETWORK, BROADCAST.

   DEVICE=’eth0′
ONBOOT=’yes’
BOOTPROTO=’none’
IPADDR=’xx.xx.xx.xx’
TYPE=’Ethernet’
USERCTL=’no’
NETMASK=’255.255.252.0′
NETWORK=’xx.xx.xx.0′
BROADCAST=’xx.xx.xx.255′

 b. Setting up of hostname and gateway

  – Edit the file /etc/sysconfig/network, add the following entries. Put the appropriate entries for HOSTNAME, GATEWAY.

   NETWORKING=yes
HOSTNAME=’www’
GATEWAY=xx.xx.xx.xx

5. Installing DB2

 – Mount DB2 CD and go to the DB2 install directory.

        – run ./db2setup file

        – if it gives libncurses.so.4, get the file from the net and put it in /usr/lib/ area of the linux server.

        – Select the 2nd and 4th options of the installation screen. i.e. DB2 UDB Enterprise edition and DB2 administration server.

        – On the next screen, select ‘Create db2 instance’

        – On the next screen, set the home directory of db2inst1 as /usr/users/db2inst1, give password as ‘db2inst1’. Do the corresponding entries for db2fenc1 user.

        – On the next screen, select ‘create DB2 administration’ option.

        – Set home directory for db2as user as /usr/users/db2as

        – Do not create db2 warehouse database

        – The installer will now prompt for proceeding further with full installation, say OK.

        – The installation will normally take 5-7 mins according to speed of PC.

6. Setting /etc/profile, /etc/rc.local, ld.so.conf

– Just after installing DB2, login as db2inst1 and test whether db2 is working. Type db2 from the prompt.

– Edit /etc/profile and add the following lines of code towards the end of the file

  if [ “x$DB2_HOME” = “x” ] ; then
DB2_HOME=/usr/IBMdb2/V7.1/
PATH=${PATH}:/${DB2_HOME}/bin
export DB2_HOME PATH
source /usr/users/db2inst1/sqllib/db2profile
fi
if [ “x$JAVA_HOME” = “x” ] ; then
JAVA_HOME=/opt/IBMJava2-131
fi
if ! echo $PATH | /bin/grep -q “$DB2_HOME/bin” ; then
PATH=”$PATH:$DB2_HOME/bin”
fi
if ! echo $PATH | /bin/grep -q “$JAVA_HOME/bin” ; then
PATH=”$PATH:$JAVA_HOME/bin”
fi
export PATH DB2_HOME
export JAVA_HOME

 – Edit /etc/rc.local file and add the following lines

  echo 250 32000 100 256 > /proc/sys/kernel/sem
echo 256 > /proc/sys/kernel/msgmni

 – Edit /etc/ld.so.conf and add the following lines

  /usr/local/lib
/usr/IBMdb2/V7.1/lib

  do ldconfig from the linux prompt after this.

7. Reboot the server and test for db2 working

– Reboot the server, say ‘reboot’ at the prompt

                 – Check for DB2 working by loging in as db2inst1 and root user

8. Installing PHP,Apache and other required modules

The following is a sample shell script which you can use to compile the source files of the required modules. This will be of great help for you. Study the program and find out how you should arrange the directory structure of the installation files. You will just have to directly run this program as $ ./Install.sh from the linux prompt. On successfull run, all the required modules, including PHP and apache will be installed properly.

Code: Install.sh

printf “Installing zlib …\n”
cd zlib
rm -f ../../log/zlib.log
printf “Configure …\n——————–\n” >> ../../log/zlib.log
./configure –prefix=/usr/local >> ../../log/zlib.log 2>&1
printf ”     ………. ”
printf “\nMake …\n——————–\n” >> ../../log/zlib.log
make >> ../../log/zlib.log 2>&1
printf “………. ”
printf “\nMake install …\n——————–\n” >> ../../log/zlib.log
make install >> ../../log/zlib.log 2>&1
printf “……….\n”
cd ..

printf “Installing openssl …\n”
cd openssl
rm -f ../../log/openssl.log
printf “Configure …\n——————–\n” >> ../../log/openssl.log
./config >> ../../log/openssl.log 2>&1
printf ”     ………. ”
printf “\nMake …\n——————–\n”  >> ../../log/openssl.log
make  >> ../../log/openssl.log 2>&1
printf “\nMake test …\n——————–\n” >> ../../log/openssl.log
make test  >> ../../log/openssl.log 2>&1
printf “………. ”
printf “\nMake install…\n——————–\n” >> ../../log/openssl.log
make install  >> ../../log/openssl.log 2>&1
printf “\nMake clean…\n——————–\n” >> ../../log/openssl.log
make clean >> ../../log/openssl.log 2>&1
printf “\nMake deinstall…\n——————–\n” >> ../../log/openssl.log
#make deinstall >> ../../log/openssl.log 2>&1
printf “……….\n”

printf “Installing openssh …\n”
cd openssh
rm -f ../../log/openssh.log
printf “Configure …\n——————–\n” >> ../../log/openssh.log
./configure –with-md5-passwords –with-ssl-dir=/usr/local >> ../../log/openssh.log 2>&1
printf ”     ………. ”
printf “\nMake …\n——————–\n”  >> ../../log/openssh.log
make >> ../../log/openssh.log 2>&1
printf “………. ”
printf “\nMake install…\n——————–\n” >> ../../log/openssh.log
make install >> ../../log/openssh.log 2>&1
printf “\nMake distclean…\n——————–\n” >> ../../log/openssh.log
make distclean >> ../../log/openssh.log 2>&1
printf “……….\n”
cd ..

printf “Installing openldap …\n”
cd openldap
rm -f ../../log/openldap.log
printf “Configure …\n——————–\n” >> ../../log/openldap.log
./configure –enable-phonetic –enable-rlookups –enable-ldap –enable-passwd –enable-shell  >> ../../log/openldap.log 2>&1
printf ”     ………. ”
printf “\nMake depend …\n——————–\n”  >> ../../log/openldap.log
make depend >> ../../log/openldap.log 2>&1
printf “\nMake …\n——————–\n”  >> ../../log/openldap.log
make >> ../../log/openldap.log 2>&1
printf “………. ”
printf “\nMake test…\n——————–\n”  >> ../../log/openldap.log
make test >> ../../log/openldap.log 2>&1
printf “\nMake install…\n——————–\n”  >> ../../log/openldap.log
make install >> ../../log/openldap.log 2>&1
printf “\nMake declean …\n——————–\n”  >> ../../log/openldap.log
make declean >> ../../log/openldap.log 2>&1
printf “……….\n”
cd ..

printf “Installing swf …\n”
cd swf
rm -f ../../log/swf.log
printf “\nMake …\n——————–\n”  >> ../../log/swf.log
make >> ../../log/swf.log 2>&1
printf ”     ………. ”
printf “\nMake static …\n——————–\n”  >> ../../log/swf.log
make static >> ../../log/swf.log 2>&1
printf “\nMake install …\n——————–\n”  >> ../../log/swf.log
make install >> ../../log/swf.log 2>&1
printf “………. ”
printf “\nMake install-static …\n——————–\n”  >> ../../log/swf.log
make install-static >> ../../log/swf.log 2>&1
printf “\nMake clean …\n——————–\n”  >> ../../log/swf.log
make clean >> ../../log/swf.log 2>&1
cp -f swf.h /usr/local/include
cp -f libswf.a /usr/local/lib
printf “……….\n”
cd ..

printf “Installing ming …\n”
cd ming
rm -f ../../log/ming.log
printf “\nMake …\n——————–\n”  >> ../../log/ming.log
make >> ../../log/ming.log 2>&1
printf ”     ………. ”
printf “\nMake install…\n——————–\n”  >> ../../log/ming.log
make install >> ../../log/ming.log 2>&1
printf “………. ”
printf “\nMake clean…\n——————–\n”  >> ../../log/ming.log
make clean >> ../../log/ming.log 2>&1
printf “……….\n”
cd ..

printf “Installing libpng …\n”
cd libpng
rm -f ../../log/libpng.log
printf “\nCopy makefile …\n——————–\n”  >> ../../log/libpng.log
cp scripts/makefile.linux Makefile >> ../../log/libpng.log 2>&1
printf “\nMake …\n——————–\n”  >> ../../log/libpng.log
make >> ../../log/libpng.log 2>&1
printf ”     ………. ”
printf “\nMake install…\n——————–\n”  >> ../../log/libpng.log
make install >> ../../log/libpng.log 2>&1
printf “………. ”
printf “\nMake clean…\n——————–\n”  >> ../../log/libpng.log
make clean >> ../../log/libpng.log 2>&1
printf “……….\n”
cd ..

printf “Installing libjpeg …\n”
cd libjpeg
rm -f ../../log/libjpeg.log
./configure >> ../../log/libjpeg.log 2>&1
printf ”     ………. ”
printf “\nMake …\n——————–\n”  >> ../../log/libjpeg.log
make >> ../../log/libjpeg.log 2>&1
printf “\nMake install …\n——————–\n”  >> ../../log/libjpeg.log
make install >> ../../log/libjpeg.log 2>&1
printf “………. ”
printf “\nMake install-lib …\n——————–\n”  >> ../../log/libjpeg.log
make install-lib >> ../../log/libjpeg.log 2>&1
printf “\nMake install-headers …\n——————–\n”  >> ../../log/libjpeg.log
make install-headers >> ../../log/libjpeg.log 2>&1
printf “\nMake distclean …\n——————–\n”  >> ../../log/libjpeg.log
make distclean >> ../../log/libjpeg.log 2>&1
printf “……….\n”
cd ..

printf “Installing tiff …\n”
cd tiff
rm -rf ../../log/tiff.log
printf “yes” > temp
printf “\nConfigure …\n——————–\n”  >> ../../log/tiff.log
./configure < temp >> ../../log/tiff.log 2>&1
printf ”     ………. ”
printf “\nMake …\n——————–\n”  >> ../../log/tiff.log
make  >> ../../log/tiff.log 2>&1
printf “………. ”
printf “\nMake install …\n——————–\n”  >> ../../log/tiff.log
make install >> ../../log/tiff.log 2>&1
printf “……….\n”
cd ..

printf “Installing freetype …\n”
cd freetype
rm -rf ../../log/freetype.log
printf “\nConfigure …\n——————–\n”  >> ../../log/freetype.log
./configure >>../../log/freetype.log 2>&1
printf ”     ………. ”
printf “\nMake …\n——————–\n” >> ../../log/freetype.log
make  >> ../../log/freetype.log 2>&1
printf “………. ”
printf “\nMake install …\n——————–\n”  >> ../../log/freetype.log
make install >> ../../log/freetype.log 2>&1
printf “\nMake clean …\n——————–\n”  >> ../../log/freetype.log
make clean >> ../../log/freetype.log 2>&1
printf “……….\n”
cd ..

printf “Installing libgd …\n”
cd libgd
rm -rf ../../log/libgd.log
printf “\nConfigure …\n——————–\n”  >> ../../log/libgd.log
./configure >>../../log/libgd.log 2>&1
printf ”     ………. ”
printf “\nMake …\n——————–\n” >> ../../log/libgd.log
make  >> ../../log/libgd.log 2>&1
printf “………. ”
printf “\nMake install …\n——————–\n”  >>  ../../log/libgd.log
make install >>../../log/libgd.log 2>&1
printf “\nMake clean …\n——————–\n”  >>  ../../log/libgd.log
make clean >> ../../log/libgd.log 2>&1
printf “……….\n”
cd ..

printf “Installing mhash …\n”
cd mhash
printf “\nConfigure …\n——————–\n”  >> ../../log/mhash.log
./configure –prefix=/usr/local >>../../log/mhash.log 2>&1
printf ”     ………. ”
printf “\nMake …\n——————–\n”  >> ../../log/mhash.log
make >>../../log/mhash.log 2>&1
printf “\nMake check …\n——————–\n”  >> ../../log/mhash.log
make check >>../../log/mhash.log 2>&1
printf “………. ”
printf “\nMake install…\n——————–\n”  >> ../../log/mhash.log
make install >>../../log/mhash.log 2>&1
printf “\nMake distclean…\n——————–\n”  >> ../../log/mhash.log
make distclean >>../../log/mhash.log 2>&1
ldconfig >>../../log/mhash.log 2>&1
printf “……….\n”
cd ..

printf “Installing libmcrypt …\n”
cd libmcrypt
rm -rf ../../log/libmcrypt.log
printf “\nConfigure …\n——————–\n”  >> ../../log/libmcrypt.log
./configure –prefix=/usr/local –disable-posix-threads >>../../log/libmcrypt.log 2>&1
printf ”     ………. ”
printf “\nMake …\n——————–\n” >> ../../log/libmcrypt.log
make  >>../../log/libmcrypt.log 2>&1
printf “………. ”
printf “\nMake install …\n——————–\n”  >>  ../../log/libmcrypt.log
make install >>../../log/libmcrypt.log 2>&1
printf “\nMake clean …\n——————–\n”  >> ../../log/libmcrypt.log
make clean  >>../../log/libmcrypt.log 2>&1
printf “……….\n”
cd ..

printf “Installing mcrypt …\n”
cd mcrypt
rm -rf ../../log/mcrypt.log
printf “\nConfigure …\n——————–\n”  >> ../../log/mcrypt.log
./configure –prefix=/usr/local –disable-posix-threads >>../../log/mcrypt.log 2>&1
printf ”     ………. ”
printf “\nMake …\n——————–\n” >> ../../log/mcrypt.log
make  >>../../log/mcrypt.log 2>&1
printf “………. ”
printf “\nMake install …\n——————–\n”  >>  ../../log/mcrypt.log
make install >>../../log/mcrypt.log 2>&1
printf “\nMake clean …\n——————–\n”  >> ../../log/mcrypt.log
make clean  >>../../log/mcrypt.log 2>&1
printf “……….\n”
cd ..

printf “Installing libpdf …\n”
cd libpdf
rm -rf ../../log/libpdf.log
printf “\nConfigure …\n——————–\n”  >> ../../log/libpdf.log
./configure >>../../log/libpdf.log 2>&1
printf ”     ………. ”
printf “\nMake …\n——————–\n” >> ../../log/libpdf.log
make  >> ../../log/libpdf.log 2>&1
printf “………. ”
printf “\nMake install …\n——————–\n”  >>  ../../log/libpdf.log
make install >> ../../log/libpdf.log 2>&1
printf “\nMake clean …\n——————–\n”  >>  ../../log/libpdf.log
make clean  >> ../../log/libpdf.log 2>&1
printf “……….\n”
cd ..

printf “Installing imap …\n”
cd imap
rm -rf ../../log/imap.log
printf “\nMake …\n——————–\n”  >> ../../log/imap.log
FLAGS=”-O3″ make slx >> ../../log/imap.log 2>&1
printf ”     ………. ”
printf “\nCopying Files …\n——————–\n”  >> ../../log/imap.log
cp c-client/c-client.a /usr/local/lib/libc-client.a  >> ../../log/imap.log 2>&1
cp c-client/rfc822.h /usr/local/include/  >> ../../log/imap.log 2>&1
cp c-client/mail.h /usr/local/include/  >> ../../log/imap.log 2>&1
cp c-client/linkage.h /usr/local/include/  >> ../../log/imap.log 2>&1
printf “………. ”
printf “\nMake clean…\n——————–\n”  >> ../../log/imap.log
make clean >> ../../log/imap.log 2>&1
printf “\nldconfig …\n——————–\n”  >> ../../log/imap.log
ldconfig >> ../../log/imap.log 2>&1
printf “……….\n”
cd ..

printf “Installing apache preinstall …\n”
cd apache
printf ”     ………. ”
rm -rf ../../log/apachepre.log
printf “………. ”
printf “\nConfigure…\n——————–\n”  >> ../../log/apachepre.log
./configure –prefix=/usr/local/apache –enable-module=unique_id –enable-module=mime_magic –enable-module=rewrite –enable-module=speling –enable-module=auth_db –enable-module=digest –enable-module=headers –enable-module=usertrack –enable-module=proxy –enable-module=info >> ../../log/apachepre.log 2>&1
printf “……….\n”
cd ..
printf “Installing php …\n”
cd php
rm -rf ../../log/php.log
printf “\nConfigure…\n——————–\n”  >> ../../log/php.log
./configure  –with-apache=../apache –with-mod_charset=yes –enable-static –with-openssl –with-ldap –with-gd=/usr/local –with-jpeg-dir=/usr/local –with-gif-dir=/usr/local –with-png-dir=/usr/local –with-freetype-dir=/usr/local –with-ttf –enable-gd-native-ttf –with-zlib=/usr/local –with-mysql –enable-unified-odbc=no –with-dbase=yes –enable-url-fopen-wrapper –with-filepro=yes –enable-track-vars –enable-magic-quotes=yes –enable-bcmath=yes –enable-force-cgi-redirect –enable-discard-path –with-gdbm –with-ndbm –enable-sigchild –enable-calendar –enable-xml –with-swf –with-ibm-db2=/usr/IBMdb2/Vx –with-imap –with-kerberos –with-mhash –with-ming –with-pdflib –with-tiff >> ../../log/php.log 2>&1
printf ”     ………. ”
printf “\nMake …\n——————–\n”  >> ../../log/php.log
make >> ../../log/php.log 2>&1
printf “………. ”
printf “\nMake install …\n——————–\n”  >> ../../log/php.log
make install >> ../../log/php.log 2>&1
printf “\nMake clean …\n——————–\n”  >> ../../log/php.log
make clean >> ../../log/php.log 2>&1
printf “……….\n”
cd ..

printf “Installing apache …”
cd apache
rm -rf ../../log/apache.log
printf “\nConfigure…\n——————–\n”  >> ../../log/apache.log
./config.status –activate-module=src/modules/php4/libphp4.a >> ../../log/apache.log 2>&1
printf ”     ………. ”
printf “\nMake …\n——————–\n”  >> ../../log/apache.log
make >> ../../log/apache.log 2>&1
printf “………. ”
printf “\nMake install …\n——————–\n”  >> ../../log/apache.log
make install >> ../../log/apache.log 2>&1
printf “\nMake clean …\n——————–\n”  >> ../../log/apache.log
make clean >> ../../log/apache.log 2>&1

———–End of code——————————————————

9. Testing if PHP, APache is working

 – Resetting apache path

  Reset apache path in /etc/rc.d/init.d/httpd as

   apachectl=/usr/local/apache/bin/apachectl
httpd=/usr/local/apache/bin/httpd

  – Set ‘ServerName’ parameter in ‘/usr/local/apache/conf/httpd.conf’ as the hostname of the server.

 – Restart apache using..

                       /etc/rc.d/init.d/httpd

– Test apache by typing the IP address on the browser, it should show the apache test page

– Put a sample php file which displays phpinfo() function, in the default apache DocumentRoot and run it. If it displays the PHP parameters, PHP is properly installed.

There you are………….. about to set for Apache-PHP-DB2 development………..