Mac OS X Snow Leopard & Informix IDS 11.5 + PHP5

  • 1,677 views
Uploaded on

The undersigned, as thousands of others who work in IT, Apple has made a vow to his consecration as inseparable companion work, I am referring especially to Mac OS X. My MacBook Pro and before that my …

The undersigned, as thousands of others who work in IT, Apple has made a vow to his consecration as inseparable companion work, I am referring especially to Mac OS X. My MacBook Pro and before that my PowerBook G4 and I will stop here, have been and are still with me, not only for writing documentation, read and send email, but above all when it comes to creating software.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,677
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
13
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Mac  OS  X  Snow  Leopard:  IBM  Informix  IDS  11.5  +  PHP  5.3     1.1 Introduction   Since  IBM  has  extended  support  for  Informix  Dynamic  Server  (IDS)  also   Mac  OS  X  by  defining  a  winning  combination  of  the  two,  IBM  has  made  the   happiness  of  thousands  of  developers  and  DBAs  no  longer  have  to  work  on  a   remote  server  IDS.   In  this  article  we  will  see  how  to  install  and  configure  IBM  Informix  IDS   simple  steps  on  our  Mac  OS  X  11.5  Snow  Leopard.  The  special  shows  at  the  end   of  the  article  is  the  installation  of  the  informix  module  on  PHP  5.3,  note  that  PHP   5.3  is  part  of  Mac  OS  X  Snow  Leopard.     1.2  Installing  Informix  IDS  11.5   From   the   IBM   website   should   download   the   version   of   IBM   Informix   IDS   11.5   For   Mac   OS   X,   including   the   Developer   version   of   Informix   (To   download   registration   is   required   at   the   portal   IBM).   This   software   is   distributed   as   a   DMG   file   (iif.11.50.FC5DE.macosx64.dmg)   the   size   of   about   138MByte,   within   it   is   available  the  package  installer.  The  installation  process  is  very  simple,  there  are   no   special   instructions   to   follow   except   for   the   installation   directory   is   advisable   to   choose   the   directory   /opt/IBM/informix   directory   instead   of   /Application   proposed  by  the  installer.      Through   the   aid   of   the   figures   shown   below,   we   will   see   how   is   the   installation  process.   Figura  1  Installer  IDS  Informix  11.5                   Copyright  ©  2009  –  Antonio  Musarra  –  http://musarra.wordpress.com    
  • 2.   Figura  2  Running  the  installation  script           Figura  3  Request  the  administrator  password.           Figura  4  Installer  IDS  Informix  11.50             Copyright  ©  2009  –  Antonio  Musarra  –  http://musarra.wordpress.com    
  • 3.   Figura  5  Installation  directory  to  be  changed  in  /opt/IBM/informix           Figura  6  IDS  components  that  will  be  installed           Figura  7  Separation  of  roles.  Leave  the  default                 Copyright  ©  2009  –  Antonio  Musarra  –  http://musarra.wordpress.com    
  • 4.     Figura  8  Creating  a  demo  IDS  instance.  Leave  the  default           Figura  9  IDS  Installation  Summary             Figura  10  Completed  installation  notes             Copyright  ©  2009  –  Antonio  Musarra  –  http://musarra.wordpress.com    
  • 5.   Figura  11  Finish  Installation           The   installation   process,   in   addition   to   one   copy   of   the   software   in   the   directory   listed,   is   responsible   for   building   on   our   Mac   OS   X   user   informix,   it   will   be  used  to  perform  operations  normally  assigned  to  the  role  of  DBA.   In   the   next   section   we   will   see   the   configuration   of   the   operating   environment  and  initialization  of  Informix.       1.2 Configure   The  configuration  process  could  be  divided  into  two  phases:     • Configuration  execution  environment;     • Configuring  Informix.   The   preparation   of   the   operating   environment   requires   setting   some   environment  variables  listed  below:   • INFORMIXDIR  =>  Directory  Installation  Informix;   • INFORMIXSERVER  =>  The  name  given  to  the  instance  Informix;   • INFORMIXSQLHOSTS  =>  File  di  configurazione  SQL  HOSTS;   • ONCONFIG  =>  Configuration  file  SQL  HOSTS;   • DYLD_LIBRARY_PATH  =>  Path  Informix  Libs;   • TERMCAP  =>  Configuration  terminals  files;   • DB_LOCALE  =>  Set  the  Locale  for  DB;   • CLIENT_LOCALE  =>  Set  the  locale  for  the  client.   You   can   set   the   Informix   environment   variables   directly   within   the   informix  user  profile  file  (see  Listing  1).   To   configure   Informix   we   should   make   changes   to   the   standard   configuration,  there  are  two  configuration  files  on  which  to  act,  both  defined  by   two  environment  variables:  ONCONFIG  and  INFORMIXSQLHOSTS.   Copyright  ©  2009  –  Antonio  Musarra  –  http://musarra.wordpress.com    
  • 6. For  the  file  defined  by  ONCONFIG  is  advisable  to  amend  sections  that  cover:   • Root  Dbspace  Configuration  Parameters;   • System  Configuration  Parameters;   • Network  Configuration  Parameters   Proceeding  with  the  order  mentioned  above  is  going  to  change  and  /  or  add   the  configurations  listed  below  (see  Listing  2).     Listato  2  Changing  the  standard  configuration  of  Informix.     ################################################################### # Root Dbspace Configuration Parameters ################################################################### ROOTPATH $INFORMIXDIR/dbs/amusarra_ifx.rootdbs MIRRORPATH $INFORMIXDIR/dbs/amusarra_ifx.root_mirror ################################################################### # System Configuration Parameters ################################################################### DBSERVERNAME amusarra_ifx DBSERVERALIASES shirus,amusarra_shm ################################################################### # Network Configuration Parameters ################################################################### NETTYPE soctcp,1,30,NET     I  preferred  to  place  the  files  in  the  root  dbspace  dbs  instead  of  tmp  and  give   them  the  name  of  Informix  as  a  suffix.   In  the  standard  configuration  is  the  only  protocol  configured  ipcshm,  in  our   configuration  was  added  to  the  protocol  soctcp.  I  suggest  the  reading  of  official   documentation  on  Informix  NETTYPE  Configuration  Parameter.     Listato  3  Changing  configuration  SQL  Hosts     # IANA (www.iana.org) assigned port number/service names for Informix: # sqlexec 9088/tcp # sqlexec-ssl 9089/tcp #demo_on onipcshm on_hostname on_servername #demo_se seipcpip se_hostname sqlexec amusarra_ifx onsoctcp amusarra-mobile.local sqlexec shirus onsoctcp amusarra-mobile.local sqlexec-admin amusarra_shm onipcshm amusarra-mobile.local amusarra-mobile       Listing   3   shows   the   configuration   file   sqlhosts   appropriately   modified   according   to   our   needs   (for   more   information   refer   to   the   official   documentation   about  The  Informix  IDS  sqlhosts  File).  The  IANA  has  defined  TCP  ports  specific  to   the  services  Informix,  these  must  be  added  to  the  configuration  files  of  network   services  (see  Listing  4).   Copyright  ©  2009  –  Antonio  Musarra  –  http://musarra.wordpress.com    
  • 7.   Listato  4  Adding  TCP  ports  for  network  services  Informix  (/etc/services).     sqlexec-admin 9087/tcp # IBM Informix SQL Interface - Admin Port sqlexec 9088/tcp # IBM Informix SQL Interface sqlexec-ssl 9089/tcp # IBM Informix SQL Interface - Encrypted       1.3 Preparation  and  Initializing  Informix   Before  proceeding  with  the  process  of  initializing  Informix,  you  must  create   the  file  "empty"  of  the  root  dbspace  by  giving  them  permission  to  read  and  write   only  for  the  user  informix.  As  user  informix,  we  proceed  as  shown  in  Listing  5.     Listato  5  Creating  directory  and  file  "empty"  root  dbspace   amusarra-mobile:~ informix$ mkdir $INFORMIXDIR/dbs amusarra-mobile:~ informix$ touch $INFORMIXDIR/dbs/amusarra_ifx.rootdbs amusarra-mobile:~ informix$ touch $INFORMIXDIR/dbs/amusarra_ifx.rootdbs_mirror amusarra-mobile:~ informix$ chmod 660 $INFORMIXDIR/dbs/amusarra_ifx.rootdbs amusarra-mobile:~ informix$ chmod 660 /opt/IBM/informix/dbs/amusarra_ifx.rootdbs_mirror   Remember   that   the   INFORMIXDIR   environment   variable   refers   to   the   installation  directory  of  IBM  Informix  IDS,  in  our  case  the  variable  INFORMIXDIR   is:  /opt/IBM/Informix.  The  conditions  to  initialize  our  instance  we  are  all,  then   proceed  with  the  initialization  by  running  the  command:   amusarra-mobile:~ informix$ oninit -y -i –v OnInit   is   the   command   responsible   for   initializing   the   dbspaces   and   the   shared  memory  while  leaving  online  informix  instance.  The  option  (-­‐v)  command   allows   you   to   see   OnInit   output   details   of   transactions   executed   during   the   initialization  process  (see  Listing  6).                     Copyright  ©  2009  –  Antonio  Musarra  –  http://musarra.wordpress.com    
  • 8. Listato  6  Part  of  the  command  output  OnInit     Checking group membership to determine server run mode...succeeded Reading configuration file '/opt/IBM/informix/etc/onconfig.std'...succeeded Creating /INFORMIXTMP/.infxdirs...succeeded Checking config parameters...succeeded Allocating and attaching to shared memory...succeeded Creating resident pool 14708 kbytes...succeeded Allocating 200016 kbytes for buffer pool of 4K page size...succeeded Creating infos file "/opt/IBM/informix/etc/.infos.amusarra_ifx"...succeeded Linking conf file "/opt/IBM/informix/etc/.conf.amusarra_ifx"...succeeded Initializing rhead structure...succeeded Writing to infos file...succeeded Initialization of Encryption...succeeded Initializing ASF...succeeded Forking 1 'soctcp' listener threads...succeeded Forking 1 'soctcp' listener threads...succeeded Forking 1 'ipcshm' listener threads...succeeded Starting tracing...succeeded Initializing 8 flushers...succeeded Initializing log/checkpoint information...succeeded Initializing dbspaces...succeeded Opening primary chunks...succeeded Opening mirror chunks...succeeded Validating chunks...succeeded Creating database partition...succeeded     To  verify  that  went  the  right  way,  with  the  database  in  an  on-­‐line,  execute   the  command:   amusarra-mobile:~ informix$ onstat – The  output  should  be  similar  to:     IBM Informix Dynamic Server Version 11.50.FC5DE -- On-Line -- Up 00:00:25 -- 250928 Kbytes   1.4 Creating  Stores  Demo  database   Our  Informix  instance  is  online,  we  will  then  create  at  least  a  data  base  on   which   to   perform   all   our   tests.   IBM   Informix   IDS   includes   a   set   of   demo   schemas   complete   data,   we   will   use   the   db   Stores   Demo.   To   create   the   schema   and   load   data  (always  as  user  informix)  execute  the  command:   amusarra-mobile:~ informix$ dbaccessdemo To  verify  that  the  schema  and  data  have  been  created  successfully  executed   a   connection   to   the   database   stores_demo   and   a   select   query   on   the   Customer   table,  we  proceed  by  running  the  command:   amusarra-mobile:~ informix$ echo "SELECT * FROM CUSTOMER;" | dbaccess stores_demo - Output   the   command   will   return   the   records   in   the   customer   table   in   the   database  stores_demo  (see  Listing  7).         Copyright  ©  2009  –  Antonio  Musarra  –  http://musarra.wordpress.com    
  • 9. Listato  7  Output  of  the  query  on  the  Customer  table     Database selected. …. customer_num 128 fname Frank lname Lessor company Phoenix University address1 Athletic Department address2 1817 N. Thomas Road city Phoenix state AZ zipcode 85008 phone 602-533-1817 28 row(s) retrieved. Database closed.       Now   that   we   have   the   Informix   instance   on-­‐line   and   the   data   base   stores_demo,  the  next  step  is  to  install  the  Informix  module  for  PHP  5.3,  that  way   we   can   have   access   to   Informix   using   the   scripting   language   world's   most   popular  .     1.5 PHP  &  Informix   PHP   and   MySQL   or   PHP   and   PostgreSQL   are   common   to   many   pairs   of   opposite   pairs   PHP   and   Informix   almost   unknown,   it   might   be   the   nature   and   scope  of  commercial  use  of  Informix  to  make  the  couple  less  known.   Since  version  5.2  of  the  PHP  Informix  module  is  no  longer  available  because   abandoned   in   favor   of   the   Informix   PDO   Module.   In   the   rest   of   the   article   we   will   see   how   to   compile   the   "old"   module   for   Informix   makes   working   on   version   5.3   of  PHP.     1.5.1 Building  and  installing  the  module  Informix    Informix   module   is   not   available   on   version   5.3   of   PHP   installed   on   our   Mac  OS  X,  you  must  then  download  the  source  code  of  the  module  directly  from   the  site  http://pecl.php.net/package/informix.  The  tar.gz  archive  of  the  module   is   not   available,   no   matter,   checks   out   the   source   of   the   module   directly   from   the   SVN  repository  using  the  command:   amusarra-mobile:~ informix$ svn co http://svn.php.net/repository/pecl/informix/trunk php_ext_informix In   this   way   we   get   the   source   Informix   module   into   the   directory   ~/php_ext_informix.   In   Listing   8   shows   the   result   obtained   by   the   operation   performed  on  the  checkout  SVN  repository.       Copyright  ©  2009  –  Antonio  Musarra  –  http://musarra.wordpress.com    
  • 10. Listato  8  Operating  checkout  form  Informix.     amusarra-mobile:~ informix$ svn co http://svn.php.net/repository/pecl/informix/trunk php_ext_informix A php_ext_informix/config.w32 A php_ext_informix/config.m4 A php_ext_informix/php_informix.h A php_ext_informix/Makefile.frag A php_ext_informix/ifx.dsp A php_ext_informix/ifx.ec A php_ext_informix/CREDITS A php_ext_informix/php_informix_includes.h U php_ext_informix Checked out revision 290780.     We  move  into  the  directory  ~/php_ext_informix  and  proceed  with  the  build   of  the  module.   amusarra-mobile:php_ext_informix informix$ phpize amusarra-mobile:php_ext_informix informix$ ./configure Before   continuing   with   the   make   of   the   Informix   Module,   you   must   edit   the   Makefile   to   ensure   that   the   module   is   linked   with   Informix   library   checkapi.o,   otherwise  the  use  of  the  module  will  produce  the  error:     undefined symbol: ifx_checkAPI. Inside  the  Makefile  must  add  the  directive  INFORMIX_SHARED_LIBADD  use   the  library  Informix  checkapi.o:   /opt/IBM/informix/lib/esql/checkapi.o Then  proceed  with  compiling  and  installing  the  module  Informix.  The  user   informix  must  be  defined  as  sudores  or  you  must  run  the  installation  as  root.   amusarra-mobile:php_ext_informix informix$ make amusarra-mobile:php_ext_informix informix$ sudo make install The   module   will   be   installed   in   /   usr/lib/php/extensions/no-­‐debug-­‐non-­‐ zts-­‐20090626  /.  To  verify  the  correct  link  to  the  library  Informix  checkapi.o  just   use  the  command  nm  coupled  with  the  command  grep.  The  output  should  return   the  entry  point  ifx_chekAPI.   amusarra-mobile:php_ext_informix informix$ nm /usr/lib/php/extensions/no-debug- non-zts-20090626/informix.so | grep checkAPI 000000000000a0a0 T _ifx_checkAPI           Copyright  ©  2009  –  Antonio  Musarra  –  http://musarra.wordpress.com    
  • 11. 1.5.2 Activating  and  test  module  Informix   To   activate   the   module   just   installed,   you   must   edit   (as   root)   the   configuration   file   php.ini   (located   in   /etc)   and   add   the   extensions   section   directive:   extension=informix.so You  can  verify  that  the  module  Informix  is  active  by  running  the  command:   amusarra-mobile:php_ext_informix informix$ php -i|grep Informix Informix support => enabled The   command   responded   by   confirming   the   activation   of   the   module   Informix,   you   can   still   use   the   php-­‐m   command   to   verify   that   the   module   is   active.   At  this  time  the  Informix  module  is  operational  only  when  used  from  PHP   CLI   is   not   available   under   Apache   because   he   does   not   see   the   Informix   environment  variables  needed  for  the  proper  functioning  of  the  module.  The  log   file   of   Apache   (see   Listing   9)   is   evident   as   the   Informix   module   is   not   loaded   because  of  the  failure  to  load  Informix  libraries  required  by  the  module.  Variable   DYLD_LIBRARY_PATH   (which   indicates   the   location   of   libraries   Informix)   must   be  visible  to  the  Apache  process.     Listato  9  Extract  from  the  log  files  of  Apache,  Informix  obvious  error  loading  module     PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no- debug-non-zts-20090626/informix.so' - dlopen(/usr/lib/php/extensions/no-debug-non-zts- 20090626/informix.so, 9): Library not loaded: isqls09b.dylibn Referenced from: /usr/lib/php/extensions/no-debug-non-zts-20090626/informix.son Reason: image not found in Unknown on line 0     In  Mac  OS  X  10.4  (Tiger)  Apple  introduced  a  new  system  that  controls  basic   services  this  system  is  called  launchd.  The  Apache  service  is  therefore  governed   by   launchd   for   security   reasons   reset   the   environment   variables   to   the   bare   minimum,   which   is   why   the   module   failed   to   load   Informix,   Informix   environment   variables   are   not   visible   to   the   Apache   process.   Launchd   configuration,  or  rather  of  the  process  to  be  managed  is  by  means  of  a  plist  file   type,  while  the  file  /  etc  /  launchd.conf  contains  directives  (eg  commands  to  set   environment   variables)   for   launchd.   Our   goal   is   therefore   to   make   visible   the   Informix   environment   variables   serving   Apache,   the   configuration   file   /etc/launchd.conf  add  the  directives  shown  in  Listing  10.             Copyright  ©  2009  –  Antonio  Musarra  –  http://musarra.wordpress.com    
  • 12. Listato  10  Launchd  config  file  for  the  set  of  environment  variables  Informix   setenv INFORMIXDIR /opt/IBM/informix setenv ONCONFIG onconfig.std setenv INFORMIXSERVER amusarra_ifx setenv INFORMIXSQLHOSTS /opt/IBM/informix/etc/sqlhosts setenv DYLD_LIBRARY_PATH /opt/IBM/informix/lib:/opt/IBM/informix/lib/esql:/opt/IBM/informix/lib:/opt/IBM/inform ix/lib/cli setenv CLIENT_LOCALE en_US.819   We   have   ensured   that   the   processes   controlled   by   launchd   can   access   the   Informix  environment  variables.   At   this   point,   you   need   to   restart   the   Apache   service   with   the   usual   command  apachectl  (or  System  Preferences)  and  make  sure  the  Informix  module   is  properly  loaded,  you  can  verify  this  with  a  simple  PHP  script  that  has  inside  a   call  to  phpinfo  (),  in  Figure  1,  the  extract  of  section  Informix.       Figura  1  Sample  phpinfo  with  evidence  of  the  configuration  module  Informix.           In   one   of   the   previous   sections   we   have   loaded   the   database   on   our   Stores_Demo   Informix   instance,   at   the   conclusion   of   this   article   we   will   make   a   simple  PHP  script  (see  Listing  11)  that  shows  in  tabular  form,  records  that  exist   on  the  Orders  table.       Copyright  ©  2009  –  Antonio  Musarra  –  http://musarra.wordpress.com    
  • 13. Listato  11  PHP  script  for  the  selection  of  records  from  the  Orders  table     <?php $conn_id = ifx_connect ("stores_demo@amusarra_ifx", "informix", "password"); $res_id = ifx_query("select * from orders", $conn_id); if (! $res_id) { printf("Can't select orders : %sn<br />%s<br />n", ifx_error(),ifx_errormsg()); ifx_close($conn_id); die; } ifx_htmltbl_result($res_id, "border="1""); ifx_free_result($res_id); ifx_close($conn_id); ?>       Figura  2  Result  script  PHP  Listing  11           Copyright  ©  2009  –  Antonio  Musarra  –  http://musarra.wordpress.com