SlideShare una empresa de Scribd logo
1 de 23
DavidA. Bernhardt
IBM Technical SalesSpecialist
October2, 2015
1 | P a g e
Adding Informix support to an existing PHP
development environment
Beingan IBMer andhavingusedLinux,Apache,MySql andPHP(LAMP) fairlyextensivelyoverthe last
decade or so,I decidedthe otherdaythat I wantedtodo some PHPdevelopmentusingInformixinstead
of MySql. I lookedtothe Internetforinstructionsonhow toenable InformixwithmycurrentLAMP
developmentenvironmentandwasa bitsurprisedthatI didn’tsee instructionsonhow toplugInformix
intoan existingPHPenvironment. BeingaproblemsolverIwasdeterminedtofigure thisout. Itonly
occurredto me afterI solvedthisparticularpuzzle thatotherfolksmayhave the same questionand
wouldlike toknowhowtogo about addingInformix totheircurrentPHPenvironmenttoo. This
documentwill describe the stepsneededforaddingInformixtoyourPHPenvironment.
Prerequisites
There are a few thingsyouneedtogetstartedwiththis. ObviouslyyouneedaLAMP,WAMP (Windows,
Apache,MySql,andPHP),or otherApache and PHPdevelopmentsystem. Youwill alsoneedthe
PDO_Informix PECLpackage and,of course,an Informix database instance toworkwith. I’ll gothrough
the stepsI performedforsettingupmyPHP/Informixdevelopmentsystemfromscratchto illustrate
howto make thiswork. You’ll justneedtodeterminewheretostartin thisprocessif youalreadyhave
parts of thisin place.
Getting Started
I builtmydevelopmentsystemusingRedHatEnterprise Linux 5 64-biton a virtual machine using
VMWare Workstation10. AlthoughIuseda virtual machine,Icouldhave createda new hard drive
partition,installedLinuxinthatpartition,andmodifiedmycomputertoallow dual-bootintoLinux as
well. You can also buildthisenvironmentusingWindows. Theyonlydifferencewillbe the install
methodsforthe products. It reallydoesn’tmatterhow youhostthe operatingsystem. RedHatisa
specificvendorimplementationof Linux sothese instructionsshouldhelpyouwithotherversionsof
Linux as well.
Once I had my Linux desktopupandrunning,Ithenneededafew othersoftware packagestohelpme
move forwardwithbuildingmyenvironment. MostLinux versionscome withApache butitmaynot be
installedaspartof the base operatingsystemconfiguration. Mysystemdidnothave Apache installed
so I had to start fromthere.
I like quickandeasyas longas it islegal andcomplete. Giventhis,Ichose touse XAMPPto helpme with
the installationof the Apache webserveralongwithPHP,Perl,andMySql (eventhoughIdon’tneedthis
component). XAMPPisapreconfigured,opensource PHPdevelopmentenvironmentthatprovidesa
verynice install forall the components. Of course,youcanget eachcomponentindividuallyandinstall
themseparatelyif youwish(andI’ve done thatmanytimesinthe past),butI wantedtoget thisdone
quicklysoI chose the XAMPProute for easyinstallation.
DavidA. Bernhardt
IBM Technical SalesSpecialist
October2, 2015
2 | P a g e
To get startedwithXAMPP, logintoyourLinux systemasroot, opena browserandnavigate to
http://www.xampp.org. Onthe mainpage (at leastas of thiswriting),there isanoptiontodownload
XAMPPfor Windows,XAMPPforLinux,andXAMPPforOS X. Clickonthe linktodownloadXAMPPfor
Linux andyour browsershouldautomaticallystartdownloadingthe install package. If,forsome reason,
the Linux browsercan’topenthe XAMPP.orgmainpage (redirectstoapachefriends.org),thenthe
XAMPPpackage can alsobe obtainedfromSourceForge.net(whichiswhatIhad to do). For the Linux
package,itis namedsomethinglike xampp-linux-x64-5.6.11-1-installer.runorsomethingsimilar(the
numbersmaybe different –noworries). My downloadplacedthe fileonmyLinux desktop,however,it
may be placedina differentlocationonyoursystemdependingonthe downloadlocationsettingsfor
your browser.
The firstchallenge Iencounterediswhattodowiththisdownloadedfile. Since the .runextensionon
the file isnota commonlyknownextension,Linux reallydoesn’tknow whattodowithit. Beingold
school,I openeda terminal window toinvestigate thisfurther. Itturnsout the downloadedfileisan
executable butitdoesn’tdownloadwiththe correctfile permissions toexecuteit. If youaren’tfamiliar
withLinux file permissions,justfollowthesestepsanddon’tgetconcernedoverit. Fromthe terminal
window,Ichangeddirectorytomydownloadlocation(/root/Desktop) andlistedthe filetolookatthe
currentpermissions. Itshouldlooksomethinglikethe following:
Figure 1 - examining XAMPP file permissions
The permissionsforthe file are indicatedinthe first10 characters of the file listing. Inthiscase,the
ownerof the file (root) hasreadand write permissions,the groupmembers(root) have read
permissions,andeveryone else hasreadpermissions. Inorderto execute thisfileasaninstall program
we needtoadjustthese permissions. The image below showsyouhow tomake thisan executablefile:
DavidA. Bernhardt
IBM Technical SalesSpecialist
October2, 2015
3 | P a g e
Figure 2 - changing XAMPP*.run file permissions
Don’tworry if youdon’tknowexactlywhathappenswiththe ‘chmod’command. Youcan see the
permissionshave changedonthe file anditcan now be run as an executable program. Atthispointwe
wantto run the program. The followingfigureshowshow torunit:
Figure 3 - XAMPP installation
DavidA. Bernhardt
IBM Technical SalesSpecialist
October2, 2015
4 | P a g e
Followthe installationwizardpromptsto install XAMPPonyoursystem. If youchose the defaults,the
install programwill installthe productsinthe /opt/lamppdirectory(onLinux)orinC:xampp(on
Windows). Aspartof the installationprocess,XAMPPwill startthe Apache webserver. However,the
install scriptdoesnotmodifythe systemstartupscriptssothatApache (andthe otherprograms) will
restartwhenthe systemisshutdown. Itisveryeasyto start/stop/restartXAMPPonLinux. Opena
terminal andchange directoryto/opt/lampp (orthe install directoryif youchose somethingdifferent
duringthe initial install). The directorywill looksomethinglike the following:
Figure 4 - /opt/lampp directory listing
The greenfilenamesinthe directorylistingare executables. TostartApache and MySql,justtype
‘/opt/lampp/lamppstart’onthe commandline. To stopApache and MySql,justtype
‘/opt/lampp/lamppstop’onthe commandline. There are otheroptionstoowhichcan be listedby
typing/opt/lampp/lamppwithoutanyparameters. The commandwill displaythe availableoptions.
As a final checkforthe installation,openawebbrowserandopen http://localhost. Youshouldsee the
followingif XAMPPwasinstalledcorrectly andeverythingisrunningcorrectly.
DavidA. Bernhardt
IBM Technical SalesSpecialist
October2, 2015
5 | P a g e
Figure 5 - XAMPP start page
Once you have XAMPPinstalled,youwill now be able todevelopPHPapplications. The directorywhere
all the webpagesfor yourlocal serverare foundis/opt/lampp/htdocs –alsoknownasthe
DocumentRootdirectoryforyourwebserver. Ialwaystestmyinstallationtoensure PHPisrunningand
workingcorrectlybycreatinga simple test.phpfileinthe /op/lampp/htdocsdirectory. Myfile usually
lookslike the following(Ishowthe file openwithvi):
Figure 6 - test.php
Once you create and save the file,openyourwebbrowserto http://localhost/test.php andyoushould
see the followingoutput(justthe topisshown).Thisinformationwill be veryuseful aswe workon
installingthe Informix databasemodules.
DavidA. Bernhardt
IBM Technical SalesSpecialist
October2, 2015
6 | P a g e
Figure 7 - output of test.php (phpinfo)
Nowthat we have a workingweb server(Apache) andPHPwe canmove on to gettingInformix setupto
workwithit.
Download and Install Informix
If you alreadyhave a workingApache andPHPenvironment,installingthe Informix engine orClient
Software DevelopmentKit (CSDK) maybe the correctstartingpointforyour particularsituation. With
my developmentbuild,IdecidedIwantedthe Informix database enginetorunlocallyonmy
developmentserver. Havingthe Informix database enginelocallyinstalledisconvenientfordeveloping
Informix basedapplicationssince Ihave control of database objects(databases,tables,views,indexes,
storedprocedures,etc…) andcan make changesto anyof these objectsquicklyduringthe development
lifecycle. If youare workingwithanexistingInformix database locatedonadifferentserver,the only
componentyouwill needisthe Informix ClientSoftware DevelopmentKit.
Informix isafull-featured,enterprise capable database productandcomesinseveral different bundles
or packages. For my simple developmentenvironmentIuse the Informix Innovator-CEditionsince itis
free todownloadfromIBM. AnyapplicationsIdevelopthataccessInformix Innovator-CEdition will
workwithany of the otherInformix editionswithoutanymodificationsorchanges,sousing Innovator-C
Editionfora developmentenvironmentisagreat wayto get started. Justto be complete,Ishouldpoint
out that the Informix DeveloperEditionisalsoafree productand will workfordevelopmentpurposesas
well.
In additiontoinstallingthe Informix database engine,youwillalsowanttoinstall the Informix Client
Software DevelopmentKit. The CSDKhasthe librariesneededforPHPtorun the PDO_Informix plug-in.
We’ll deal withthe CSDKandhowto set that upafterwe getthe Informix database installed. Imention
the CSDK aheadof time because youmightas well downloaditwhile youare onthe IBMwebsite to
downloadthe Informix databaseengine.
Informix software downloadsare available from the IBMInformix website athttp://www-
01.ibm.com/software/data/informix/download.html. Youwill see linkstoboththe Developerand
DavidA. Bernhardt
IBM Technical SalesSpecialist
October2, 2015
7 | P a g e
Innovator-Ceditions(no-charge database)aswell as90-daytrialsfor boththe Informix Enterprise
EditionandInformix AdvancedEnterpriseEdition. Below the Informix databasessection,youwillalso
see a linkforthe Informix ClientSoftware DevelopmentKit(CSDK). Downloadboththe database and
the CSDK to yourXAMPP server. You shouldhave twocompressedarchive fileswhenthe downloadis
complete. AsImentionedbefore,mysystemplacesdownloadedfilesonmydesktopandthe image
belowshowsyouwhatthe downloadedpackageslooklike.
Figure 8 - Informix software packages (on the desktop)
Both the Informix database andthe CSDKare downloadedasarchive filesintape archive (tar) format. In
orderto access the filesinthe archive we needtoextractthem. Since Idon’twant all the Informix files
placedonmy desktop,Icreate a folder,copythe archive to the folder,andextractthe files. The stepsI
take to do that are illustratedinFigure 9:
DavidA. Bernhardt
IBM Technical SalesSpecialist
October2, 2015
8 | P a g e
Figure 9 - extracting and starting the Informix database install
Once the filesare extractedyouwill see the ids_install (IDSstandsforInformix DynamicServer)
commandin the directorylisting. Since the currentdirectoryisnotinmy currentsystempath,I start the
install usingthe command“./ids_install–i gui”whichwill invokethe graphical userinterface (thereisa
console andsilentinstalloptiontoobutIwon’tcoverthat here). Follow the promptsinthe GUI to
complete the install. Also,allowthe installscripttocreate yourInformix instance foryousoyouwill
have a workingdatabase serverwhenthe install iscomplete. Also,the GUIwill promptyoutoopena
terminal window toaccessthe database whencomplete. Repond‘yes’toopenthisterminal soyoucan
verifythe installation. IinstalledmyInformix databasetothe /opt/informix directory. Iwill use this
locationthroughoutthe remainderof thisdocument. Make note of the passwordyoucreate forthe
Informix usersince youwill needthatlater.
Once the database installationiscomplete,repeatthe processforthe CSDKarchive file. Use the
‘installclientsdk’commandinsteadof the ‘ids_install’command. Followthe GUIpromptsto complete
the installation. Note:some distributionsof the Informixengine come withthe CSDKincluded inthe
package. If the CSDKinstallationdiscoversanexistingCSDKalreadyinstalled,youcanabort or cancel
the install since youalreadyhave all the componentsyouneedforInformix.
The last stepinthe Informix installation isverifyingthe installationof the database. If youopenedthe
terminal window duringthe Informixengine install (ids_install process),the correctenvironment
variableshave beensetwithinthe terminal toenable accesstoInformix. Checkthe installationby
typing‘onstat–‘ at the terminal windowcommandprompt. Youroutputshouldlooklike the following:
DavidA. Bernhardt
IBM Technical SalesSpecialist
October2, 2015
9 | P a g e
Figure 10 - verify the Informix installation
As the image shows,InformixDynamicServer(myversion - 12.10) iscurrentlyonline. Thismeans
Informix isrunningandsharedmemoryisinitializedforthe database instance. We are now ready for
the nextstepof the process.
PHP and Informix – PDO_Informix module
There are a fewpre-requisitesforaddingPDO_Informixtothe PHPconfiguration. First,yoursystem
needstohave a compiler– usuallyGCCor CC – installed. Forthe RedHatserverI usedformy server,the
compilerwasinstalledaspartof the initial operatingsystem. Manyversionsof Linux will have the
compilerautomaticallyinstalledaspartof the operatingsysteminstall,however,youshouldcheckyour
Linux servertobe sure.
Anothercritical componenttoinstallingPDO_Informix isthe PHPDevelopmentcomponents. If you
installedXAMPP(orLAMPPonLinux),thenthisPHPextensionwasinstalledaspartof the package. If
youinstalledPHPusinganothermethod,youwill have tocheckyourPHPinstall tosee if thisextension
was included. Specifically,we will needthe command‘phpize’tocreate the pdo_informix.solibrary. If
youare uncertain,doa quickfilesystemcheckforthe ‘phpize’command. Iuse the command‘find/ -
name phpize –print’froma terminal tolocate the file. If youcan’tfindthe commandyou will needto
downloadthe PHPDevelopmentpackage fromthe Internetandinstall itaccordingtothe instructions.
One itemto mentionissome PHPinstallationsincludePEARandPECL. If you have PEARand PECL
installed,youcaninstall PDO_Informix using‘peclinstallpdo_informix’fromaterminal. If there are any
missingdependencies,the commandwillinformyouwhatismissing. Iwon’tgo intoPEARand PECL
install since those applicationsare well documentedonthe Internet.
So,for the RedHat server,Ididnot have PEARor PECL available soinstallingthe PDO_Informix extension
takesa bit of work. The firstitemonour lististo downloadthe PDO_InformixPECLpackage fromthe
PECL repositoryonthe Internet. Usingyourfavorite searchengine, simplysearchforPECL
PDO_Informix. Asof thiswriting,the PDO_Informix package islocatedat
DavidA. Bernhardt
IBM Technical SalesSpecialist
October2, 2015
10 | P a g e
https://pecl.php.net/package/PDO_INFORMIX withacurrentversionof 1.3.1. Downloadthe
PDO_INFORMIX-1.3.1.tgzbyclickingonthe linkinthe download sectionof the page.
Since the PDO_Informix package isanextensionof PHP,the correctplace to place the filesinthe
package is inthe PHP extensionsdirectory. FormyLAMPP install,the directorywhere PHPextensions
are storedis/opt/lampp/include/php/extsothatis where Iextractedthe PDO_Informix archiveI
downloadedfromthe PECLrepository. If youare unsure of where the extensionstoyourPHPserver
are locatedjustlookforany of the installedpackages(GDisa goodone since itisthe extensionthat
allowsthe servertoworkwithimagesandit isextremelycommoninPHPinstalls). Use the find
commandto locate one of the installedextensionsanditwill show youwhere toplace the
PDO_Informix extractedfiles. Figure 11 showsyouhow to find,move andextractthe PDO_Informix
package in the PHPextensionsdirectory.
Figure 11 - finding the extension directory and unpacking PDO_Informix
As youcan see,the package containsfilesthatrequire youtocompile the programwithaC compiler.
Thisisn’toverlydifficult. However,thereisacritical stepto compilinganythingforInformix thatmany
of the instructionsonthe Internetoverlook. Inorderto compile PDO_Informix,the compilerneedsto
knowwhere the appropriate Informix librariesare located. Also,PHPneedstoknow somethingabout
the Informix environmentinordertoworkwiththe installeddatabase engine. Thisisall accomplished
throughenvironmentvariables. So,let’sgetthose setup.
Whenyou installedInformix (probablyinthe /opt/Informixdirectory),the install programcreatedsome
sample shell scriptsthatsetthe appropriate environmentvariables. Figure 12showsthe directory
listingof /opt/Informix,the shell scriptsthatwere created (withabox aroundthem),anddisplaysthe
environmentvariablesthatare set(forthe K-Shell script):
DavidA. Bernhardt
IBM Technical SalesSpecialist
October2, 2015
11 | P a g e
Figure 12 - scripts for setting Informix environment variables
Since I use the BASH shell,Ihave tosetthe environmentvariablesexactlyasshownabove (if youare
usingthe C-Shell youwoulduse the ol_informix1210.cshfile). Asageneral rule,Ieitheraddthese
globally (mostLinux systemuse /etc/profile forsettingglobal environmentvariables) soall userswill
have themsetautomatically(if itisa sharedserverandmultiple people are usingit) orI addthe
INFORMIXDIR,INFORMIXSERVER,ONCONFIG,INFORMIXSQLHOSTS,GL_USEGLU, and PATH environment
variable settingsshownabove tomylocal .bash_profilesothatmy local account will automaticallyset
these whenIlogin. Inthiscase, I editedthe .bash_profile in$HOME (formy rootaccount) andalso
editedthe .bash_profileforthe Informix useraccount. Withthese environmentvariablesset,youcan
type any of the Informix command(onstat,oninit, onmode, onspaces,ontape,etc…) directlyfroma
terminal commandline andtheywill work,regardlessof yourcurrentdirectory.
There isone more extremelyimportantenvironmentvariable thatisrequiredforcompilinganything
Informix related (oranyotherClibraryadditionsforthatmatter). Thisenvironmentvariableisthe
LD_LIBRARY_PATH. If you checkthe http://localhost/test.php webpage,youwillfindthisenvironment
variable inthatlisting,however,therewon’tbe anythingInformixrelatedassociatedwithit. We need
to fix thisif PHPis goingto be able to use Informix. So,the challengeis –where dowe set this
environmentvariablesothatPHP can use it? Well,since PHPisrunningwithinthe Apache webserver,
we have to setthe environmentforthe webservertoinclude thisvariable. If youusedXAMPP(LAMPP)
to install the Apache webserverwithPHP,the startupscriptswill lookforanyadditionalenvironment
variablesinthe /opt/lampp/bin/envvarsfile. If youare notsure where additional environmentvariables
can be setfor yourApache/PHPstartup,youcan examine the startupscriptstofindit. Figure 13 shows
the part of the apachectl shell script(locatedin/opt/lampp/bin) thatloadsadditional environment
variables. Ifoundthe apachectl shell scriptbyexaminingthe lamppstartupscript(/opt/lampp/lampp)
and findingthe commandtostart the Apache webserver.
DavidA. Bernhardt
IBM Technical SalesSpecialist
October2, 2015
12 | P a g e
Figure 13 - apachectl shell script environment variables section
Since the apachectl scriptisspecificallylookingforthe envvarsfile inthe /opt/lampp/bindirectory,all
we needtodo is addthe necessaryenvironmentvariablestothisfile. Figure 14showsthe contentsof
the envvarsfile. Ialsoensure the INFORMIXDIRenvironmentvariable issetforApache/PHP since many
of the entriesinthe LD_LIBRARY_PATHreferto it.
DavidA. Bernhardt
IBM Technical SalesSpecialist
October2, 2015
13 | P a g e
Figure 14 - contents of the /opt/lampp/bin/envvars file
In orderfor these changestotake effect,youwill needtorestartthe Apache webserver. Use the
command‘/opt/lampp/bin/apachectl restart’torestartApache. AftersuccessfullyrestartingApache,
the outputof http://localhost/test.php will show the changestothe LD_LIBRARY_PATH(figure 15).
Figure 15 - LD_LIBRARY_PATHafter restart
DavidA. Bernhardt
IBM Technical SalesSpecialist
October2, 2015
14 | P a g e
Nowthat we knowhowto setthe LD_LIBRARY_PATH variable,itwouldbe goodtoknow whatto include
inthe LD_LIBRARY_PATH to ensure everythingworkscorrectly. InFigure 14, part of the
LD_LIBRARY_PATH includescomponentsof the OpenAdminTool (OAT) whichinstallsitsownweb
serveras part of the install process. If youare usingOAT,youwill wantto keep these directoriesinthe
LD_LIBRARY_PATH. For our installation,we onlyneedtoinclude the followingaspart of the
LD_LIBRARY_PATH (rememberwe setthe $INFORMIXDIRenvironmentvariable to/opt/Informix):
$INFORMIXDIR/lib
$INFORMIXDIR/lib/cli
$INFORMIXDIR/lib/esql
$INFORMIXDIR/incl
$INFORMIXDIR/incl/cli
$INFORMIXDIR/incl/esql
/lib(if notalreadyset)
/usr/lib(if notalreadyset)
/usr/local/lib(if notalreadyset)
Followthe syntax inFigure 14 to setthe LD_LIBRARY_PATH for yourserverenvironment.
Nowthat we have setall the environmentvariables,we canfinallymove ontocompilingthe PHP
PDO_Informix extension. Openaterminal windowandchange the directorytothe locationwhere you
unpackedthe PDO_INFORMIX-1.3.1.tgzfile. Execute the followingcommands:
If your phpize commandislocatedina differentdirectorythan/opt/lampp/bin,thensubstitute that
directoryinyourpath. The outputof the phpize commandwill looksimilartoFigure 16:
Figure 16 - output of phpize command
The ./configure commandwill produce several pagesof informationasitchecksto ensure necessary
componentsare available. Whenthe commandcompletesyou’llsee anoutputsimilartoFigure 17 and
you’ll see config.status:creating config.h:
exportPATH=/opt/lampp/bin:$PATH
phpize
./configure
make
DavidA. Bernhardt
IBM Technical SalesSpecialist
October2, 2015
15 | P a g e
Figure 17 - end of configure command output
The last commandinthe sequence isthe make command. ThiscommandtellsLinux to“make”or
compile all the applicablefilesintoasharedlibrarythatcan be usedby PHP. Just like the configure
command,make producesseveral pagesof informationasthe compilationtakesplace. The final output
will looksimilartoFigure 18:
Figure 18 - make command output (last page)
As youcan see inFigure 18 (nearthe top),the compiledlibraryfilesare placedinthe
/opt/lampp/include/php/ext/pdo_informix/modulesdirectory. If we lookat the directorylistingyouwill
see the resultsinFigure 19:
DavidA. Bernhardt
IBM Technical SalesSpecialist
October2, 2015
16 | P a g e
Figure 19 - pdo_informix.so shared library
The file we needtoallowPHPto connectto Informix database isthe pdo_informix.solibraryfile. The
final stepswe needtotake are puttingthisfile inthe extensionsdirectoryandenablingthe extension
withinPHP.
Enabling the PHP Extension
Goingback to http://localhost/test.php webpage,we canfindthe directorywhere PHPlooksforall the
currentextensions. Thisdirectoryislistedasthe extension_direnvironmentvariable. Whenyoufindit
inon the webpage (see Figure 20),take note of the directory – we will needitforinstallingthe
pdo_informix.sosharedlibrary.
Figure 20 - PHP extension_dir location
For my installation,Isimplycopythe pdo_informix.sofilefromitscurrentlocation
(/opt/lampp/include/php/ext/pdo_informix/modules)tothe PHPextensiondirectory
(/opt/lampp/lib/php/extensions/no-debug-non-zts-20131226) using:
cd /opt/lampp/include/php/ext/pdo_informix/modules
cp pdo_informix.so /opt/lampp/lib/php/extensions/no-debug-non-zts-20131226
DavidA. Bernhardt
IBM Technical SalesSpecialist
October2, 2015
17 | P a g e
Next,we needtomodifythe PHPsettingsinphp.ini toenable the extension. Todetermine where the
currentphp.ini file islocated,we canagainlookat the http://localhost/test.php webpage. The current
configurationfileislistedinthe topof the phpinfo() output(seeFigure 21).
Figure 21 - current php.ini file location
From a terminal window,we canuse ‘vi’toeditthe php.ini file oryoucanuse a texteditorof your
choice. You will notice thatthe php.ini file isquite lengthyanditisorganizedintosections. Youwill
needtofindthe DynamicExtensionssectionandenterthe following2linestothe file:
Your entrieswill looksomethinglike Figure22 (below):
extension=”pdo_informix.so”
extension=”pdo_dblib.so”
DavidA. Bernhardt
IBM Technical SalesSpecialist
October2, 2015
18 | P a g e
Figure 22 – adding extensions to the php.ini file
Once you have completed the editsandsavedthe file,youwill needtorestartthe Apache webserver
againto allowPHPto loadthe dynamicextension. Simplyissue arestartcommandas described
previously.
If everythinghasworkedproperly,the new pdo_informix dynamicextensionwill be enabledandthe
phpinfo() outputwill show the extensionloadedandavailable(Figure23):
DavidA. Bernhardt
IBM Technical SalesSpecialist
October2, 2015
19 | P a g e
Figure 23 - pdo_informix installed, loaded, and enabled
DavidA. Bernhardt
IBM Technical SalesSpecialist
October2, 2015
20 | P a g e
Of course,itisalwaysgoodpractice totest yourwork andwe do thisby creatinga simple PHPpage that
accessesourInformix database server. Ensure thatthe Informix serverisrunningusingonstat(you
shouldsee itonline) andthensave the followingcode inaphpfile under/opt/lampp/htdocs:
Of course,there isalwayssomethingelseyouneedtodoto getcopied code to workon your specific
server. Inthiscase, youneedtofindthe service numberforthe Informix database engineandchange
<Informix password>tothe actual Informix user’spassword. Tofindthe service numberforyour
Informix database engine simplytype the followingatthe commandline:
<html>
<head>
<title>Informix PDOTest</title>
</head>
<body>
<?php
try {
$db = new
PDO("informix:host=localhost;service=<Service>;database=sysmaster;server=ol_informix1210;proto
col=onsoctcp;EnableScrollableCursors=1;","informix","<Informix password>");
print"ConnectionEstablished!nn";
$stmt = $db->query("select* fromsystables");
print("<table><tr><th>Table Name</th><th>Owner</th><th>PartNumber</th><th>Table
ID</th></tr>");
foreach($stmtas $row){
print("<tr><td>".$row[0]."</td><td>".$row[1]."</td><td>".$row[2]."</td><td>".$row[3]."</td></tr>
");
}
print("</table>");
} catch (PDOException$e)
{
print("Error!:" .$e->getMessage() ."<br/>");
die();
}
?>
</body>
</html>
DavidA. Bernhardt
IBM Technical SalesSpecialist
October2, 2015
21 | P a g e
You shouldsee somethingsimilartothe following(Figure 24):
Figure 24 - finding the Informix database server port number
For my Informix server,the servicenumberis30503. Yours will probablybe different. Justmake sure
youchange <Service>tothe actual numberforyour server. If youdon’tget anyresultsfromrunning
thiscommand,thenyourDBA probablyuseda non-standardservice name forthe Informix install. You
can modifythe commandto justlookforInformix (cat/etc/services|grepInformix) andsee if thatgives
youresults. If not,ask your Informix DBA forthe port numberforyour Informix engine.
Now,forthe momentof truth. Openthe php file (Inamedmine test_ifx.php) inawebbrowsertosee if
youcan connectto Informix,queryadatabase,andreturnresults. If successful,youroutputwill look
like the following:
cat /etc/services|grep ol_informix
DavidA. Bernhardt
IBM Technical SalesSpecialist
October2, 2015
22 | P a g e
Figure 25 - successful output from test_ifx.php
Conclusion
AddingInformix databasesupporttoyourexistingPHPenvironmentisfairlystraightforwardonce
you’ve identifiedall the necessarycomponentsandinstalledthem. Aswithmostserversandsystems,
there are variationsinarchitecture anddirectorystructure whichmayrequire youtoalterthese
instructions. Withalittle researchandusingavailableresourcessuchasIBMDeveloperworks,you’ll be
able to adjustforthese differencesandgetthe mostoutof yourInformix PHPenvironment.
DavidA. Bernhardt
IBM Technical SalesSpecialist
October2, 2015
23 | P a g e
Appendix A – List of Figures
Figure 1 - examining XAMPPfile permissions........................................................................................2
Figure 2 - changing XAMPP*.run file permissions..................................................................................3
Figure 3 - XAMPP installation...............................................................................................................3
Figure 4 - /opt/lampp directorylisting..................................................................................................4
Figure 5 - XAMPP start page................................................................................................................5
Figure 6 - test.php ..............................................................................................................................5
Figure 7 - output of test.php (phpinfo).................................................................................................6
Figure 8 - Informix software packages (on the desktop) ........................................................................7
Figure 9 - extracting and starting the Informix database install..............................................................8
Figure 10 - verify the Informix installation............................................................................................9
Figure 11 - finding the extension directory and unpacking PDO_Informix.............................................10
Figure 12 - scripts for setting Informix environment variables .............................................................11
Figure 13 - apachectl shell script environment variables section..........................................................12
Figure 14 - contents of the /opt/lampp/bin/envvars file......................................................................13
Figure 15 - LD_LIBRARY_PATH after restart........................................................................................13
Figure 16 - output of phpize command ..............................................................................................14
Figure 17 - end of configure command output....................................................................................15
Figure 18 - make command output (last page)....................................................................................15
Figure 19 - pdo_informix.so shared library.........................................................................................16
Figure 20 - PHP extension_dirlocation...............................................................................................16
Figure 21 - current php.ini file location...............................................................................................17
Figure 22 – adding extensions to the php.ini file.................................................................................18
Figure 23 - pdo_informix installed, loaded, andenabled .....................................................................19
Figure 24 - finding the Informix database server port number.............................................................21
Figure 25 - successful outputfrom test_ifx.php..................................................................................22

Más contenido relacionado

La actualidad más candente

pfSense Installation Slide
pfSense Installation SlidepfSense Installation Slide
pfSense Installation SlideSopon Tumchota
 
Tibet 5.0 / CouchDB
Tibet 5.0 / CouchDBTibet 5.0 / CouchDB
Tibet 5.0 / CouchDBbedney
 
Lamp technology
Lamp technologyLamp technology
Lamp technology2tharan21
 
Using aphace-as-proxy-server
Using aphace-as-proxy-serverUsing aphace-as-proxy-server
Using aphace-as-proxy-serverHARRY CHAN PUTRA
 
Lazy Techs Knowledgebase ..
Lazy Techs   Knowledgebase ..Lazy Techs   Knowledgebase ..
Lazy Techs Knowledgebase ..Cody
 

La actualidad más candente (7)

pfSense Installation Slide
pfSense Installation SlidepfSense Installation Slide
pfSense Installation Slide
 
Tibet 5.0 / CouchDB
Tibet 5.0 / CouchDBTibet 5.0 / CouchDB
Tibet 5.0 / CouchDB
 
Lamp technology
Lamp technologyLamp technology
Lamp technology
 
News from PEAR
News from PEARNews from PEAR
News from PEAR
 
Using aphace-as-proxy-server
Using aphace-as-proxy-serverUsing aphace-as-proxy-server
Using aphace-as-proxy-server
 
Its3 Drupal
Its3 DrupalIts3 Drupal
Its3 Drupal
 
Lazy Techs Knowledgebase ..
Lazy Techs   Knowledgebase ..Lazy Techs   Knowledgebase ..
Lazy Techs Knowledgebase ..
 

Destacado

Flameproof High Range Bellow type Pressure Switches FC series
Flameproof High Range Bellow type Pressure Switches FC seriesFlameproof High Range Bellow type Pressure Switches FC series
Flameproof High Range Bellow type Pressure Switches FC seriesNK Instruments Pvt. Ltd.
 
Final research and planning
Final research and planningFinal research and planning
Final research and planningJack Street
 
11 things i wish i had learned final presentation
11 things i wish i had learned final presentation11 things i wish i had learned final presentation
11 things i wish i had learned final presentationbehnbrian
 
Flameproof Highproof Low Range DP Switch FC Series
Flameproof Highproof Low Range DP Switch FC SeriesFlameproof Highproof Low Range DP Switch FC Series
Flameproof Highproof Low Range DP Switch FC SeriesNK Instruments Pvt. Ltd.
 
SKF圆锥滚子轴承参数-Taper Roller Bearings Parameter
SKF圆锥滚子轴承参数-Taper Roller Bearings ParameterSKF圆锥滚子轴承参数-Taper Roller Bearings Parameter
SKF圆锥滚子轴承参数-Taper Roller Bearings ParameterCHIK BEARING
 
Needle roller bearings parameter from Chik bearing
Needle roller bearings parameter from Chik bearingNeedle roller bearings parameter from Chik bearing
Needle roller bearings parameter from Chik bearingCHIK BEARING
 
Flameproof Low Range DP Switches FC series
Flameproof Low Range DP Switches FC seriesFlameproof Low Range DP Switches FC series
Flameproof Low Range DP Switches FC seriesNK Instruments Pvt. Ltd.
 
PROPAGANDA SERVIÇOS PSICOLÓGICOS PARA EMPRESAS
PROPAGANDA SERVIÇOS PSICOLÓGICOS PARA EMPRESASPROPAGANDA SERVIÇOS PSICOLÓGICOS PARA EMPRESAS
PROPAGANDA SERVIÇOS PSICOLÓGICOS PARA EMPRESASJamyly da S. Rodrigues
 
A definitive guide to the brexit negotiations, By Sadaf Alidad
A definitive guide to the brexit negotiations, By Sadaf AlidadA definitive guide to the brexit negotiations, By Sadaf Alidad
A definitive guide to the brexit negotiations, By Sadaf AlidadSadaf Alidad
 
certificates new
certificates newcertificates new
certificates newRian Bothma
 

Destacado (20)

Flameproof High Range Bellow type Pressure Switches FC series
Flameproof High Range Bellow type Pressure Switches FC seriesFlameproof High Range Bellow type Pressure Switches FC series
Flameproof High Range Bellow type Pressure Switches FC series
 
Final research and planning
Final research and planningFinal research and planning
Final research and planning
 
T type Three Valve Manifold (3VQ)
T type Three Valve Manifold (3VQ)T type Three Valve Manifold (3VQ)
T type Three Valve Manifold (3VQ)
 
Quziás no sabias que
Quziás no sabias queQuziás no sabias que
Quziás no sabias que
 
11 things i wish i had learned final presentation
11 things i wish i had learned final presentation11 things i wish i had learned final presentation
11 things i wish i had learned final presentation
 
H type Five Valve Manifold (5VH)
H type Five Valve Manifold (5VH)H type Five Valve Manifold (5VH)
H type Five Valve Manifold (5VH)
 
Flameproof Highproof Low Range DP Switch FC Series
Flameproof Highproof Low Range DP Switch FC SeriesFlameproof Highproof Low Range DP Switch FC Series
Flameproof Highproof Low Range DP Switch FC Series
 
CV Dip 03-11-15
CV Dip 03-11-15CV Dip 03-11-15
CV Dip 03-11-15
 
Ultrasonic Flow Meter ASIONIC 400S
Ultrasonic Flow Meter ASIONIC 400SUltrasonic Flow Meter ASIONIC 400S
Ultrasonic Flow Meter ASIONIC 400S
 
SKF圆锥滚子轴承参数-Taper Roller Bearings Parameter
SKF圆锥滚子轴承参数-Taper Roller Bearings ParameterSKF圆锥滚子轴承参数-Taper Roller Bearings Parameter
SKF圆锥滚子轴承参数-Taper Roller Bearings Parameter
 
Vacuum Switch MD Series
Vacuum Switch MD SeriesVacuum Switch MD Series
Vacuum Switch MD Series
 
yeah
yeahyeah
yeah
 
Needle roller bearings parameter from Chik bearing
Needle roller bearings parameter from Chik bearingNeedle roller bearings parameter from Chik bearing
Needle roller bearings parameter from Chik bearing
 
Flameproof Low Range DP Switches FC series
Flameproof Low Range DP Switches FC seriesFlameproof Low Range DP Switches FC series
Flameproof Low Range DP Switches FC series
 
Vacuum Switch MZ Series
Vacuum Switch MZ SeriesVacuum Switch MZ Series
Vacuum Switch MZ Series
 
Resume-update
Resume-updateResume-update
Resume-update
 
PROPAGANDA SERVIÇOS PSICOLÓGICOS PARA EMPRESAS
PROPAGANDA SERVIÇOS PSICOLÓGICOS PARA EMPRESASPROPAGANDA SERVIÇOS PSICOLÓGICOS PARA EMPRESAS
PROPAGANDA SERVIÇOS PSICOLÓGICOS PARA EMPRESAS
 
A definitive guide to the brexit negotiations, By Sadaf Alidad
A definitive guide to the brexit negotiations, By Sadaf AlidadA definitive guide to the brexit negotiations, By Sadaf Alidad
A definitive guide to the brexit negotiations, By Sadaf Alidad
 
certificates new
certificates newcertificates new
certificates new
 
R type Three Valve Manifold (3VMN)
R type Three Valve Manifold (3VMN)R type Three Valve Manifold (3VMN)
R type Three Valve Manifold (3VMN)
 

Similar a Informix and PHP (20)

Its3 Drupal
Its3 DrupalIts3 Drupal
Its3 Drupal
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
 
Php
PhpPhp
Php
 
Php hypertext Preprocessor
Php hypertext PreprocessorPhp hypertext Preprocessor
Php hypertext Preprocessor
 
Joomla Manual in Compatible with XAMPP
Joomla Manual in Compatible with XAMPPJoomla Manual in Compatible with XAMPP
Joomla Manual in Compatible with XAMPP
 
SubjectsPlus Manual in Compatible with XAMPP
SubjectsPlus Manual in Compatible with XAMPPSubjectsPlus Manual in Compatible with XAMPP
SubjectsPlus Manual in Compatible with XAMPP
 
Php simple
Php simplePhp simple
Php simple
 
WordPress Manual in Compatible with XAMPP
WordPress Manual in Compatible with XAMPPWordPress Manual in Compatible with XAMPP
WordPress Manual in Compatible with XAMPP
 
PHP Presentation
PHP PresentationPHP Presentation
PHP Presentation
 
WordPress Complete Manual in XAMPP
WordPress Complete Manual in XAMPPWordPress Complete Manual in XAMPP
WordPress Complete Manual in XAMPP
 
Wamp & LAMP - Installation and Configuration
Wamp & LAMP - Installation and ConfigurationWamp & LAMP - Installation and Configuration
Wamp & LAMP - Installation and Configuration
 
Frappe framework
Frappe framework Frappe framework
Frappe framework
 
Php mysql-tutorial-en
Php mysql-tutorial-enPhp mysql-tutorial-en
Php mysql-tutorial-en
 
Php ppt
Php pptPhp ppt
Php ppt
 
Php introduction and configuration
Php introduction and configurationPhp introduction and configuration
Php introduction and configuration
 
2013 - Dustin whittle - Escalando PHP en la vida real
2013 - Dustin whittle - Escalando PHP en la vida real2013 - Dustin whittle - Escalando PHP en la vida real
2013 - Dustin whittle - Escalando PHP en la vida real
 
CONTENT MANAGEMENT SYSTEM
CONTENT MANAGEMENT SYSTEMCONTENT MANAGEMENT SYSTEM
CONTENT MANAGEMENT SYSTEM
 
Setting advanced PHP development environment
Setting advanced PHP development environmentSetting advanced PHP development environment
Setting advanced PHP development environment
 
Slide 1 - The University of Mississippi
Slide 1 - The University of MississippiSlide 1 - The University of Mississippi
Slide 1 - The University of Mississippi
 
Week 1
Week 1Week 1
Week 1
 

Informix and PHP

  • 1. DavidA. Bernhardt IBM Technical SalesSpecialist October2, 2015 1 | P a g e Adding Informix support to an existing PHP development environment Beingan IBMer andhavingusedLinux,Apache,MySql andPHP(LAMP) fairlyextensivelyoverthe last decade or so,I decidedthe otherdaythat I wantedtodo some PHPdevelopmentusingInformixinstead of MySql. I lookedtothe Internetforinstructionsonhow toenable InformixwithmycurrentLAMP developmentenvironmentandwasa bitsurprisedthatI didn’tsee instructionsonhow toplugInformix intoan existingPHPenvironment. BeingaproblemsolverIwasdeterminedtofigure thisout. Itonly occurredto me afterI solvedthisparticularpuzzle thatotherfolksmayhave the same questionand wouldlike toknowhowtogo about addingInformix totheircurrentPHPenvironmenttoo. This documentwill describe the stepsneededforaddingInformixtoyourPHPenvironment. Prerequisites There are a few thingsyouneedtogetstartedwiththis. ObviouslyyouneedaLAMP,WAMP (Windows, Apache,MySql,andPHP),or otherApache and PHPdevelopmentsystem. Youwill alsoneedthe PDO_Informix PECLpackage and,of course,an Informix database instance toworkwith. I’ll gothrough the stepsI performedforsettingupmyPHP/Informixdevelopmentsystemfromscratchto illustrate howto make thiswork. You’ll justneedtodeterminewheretostartin thisprocessif youalreadyhave parts of thisin place. Getting Started I builtmydevelopmentsystemusingRedHatEnterprise Linux 5 64-biton a virtual machine using VMWare Workstation10. AlthoughIuseda virtual machine,Icouldhave createda new hard drive partition,installedLinuxinthatpartition,andmodifiedmycomputertoallow dual-bootintoLinux as well. You can also buildthisenvironmentusingWindows. Theyonlydifferencewillbe the install methodsforthe products. It reallydoesn’tmatterhow youhostthe operatingsystem. RedHatisa specificvendorimplementationof Linux sothese instructionsshouldhelpyouwithotherversionsof Linux as well. Once I had my Linux desktopupandrunning,Ithenneededafew othersoftware packagestohelpme move forwardwithbuildingmyenvironment. MostLinux versionscome withApache butitmaynot be installedaspartof the base operatingsystemconfiguration. Mysystemdidnothave Apache installed so I had to start fromthere. I like quickandeasyas longas it islegal andcomplete. Giventhis,Ichose touse XAMPPto helpme with the installationof the Apache webserveralongwithPHP,Perl,andMySql (eventhoughIdon’tneedthis component). XAMPPisapreconfigured,opensource PHPdevelopmentenvironmentthatprovidesa verynice install forall the components. Of course,youcanget eachcomponentindividuallyandinstall themseparatelyif youwish(andI’ve done thatmanytimesinthe past),butI wantedtoget thisdone quicklysoI chose the XAMPProute for easyinstallation.
  • 2. DavidA. Bernhardt IBM Technical SalesSpecialist October2, 2015 2 | P a g e To get startedwithXAMPP, logintoyourLinux systemasroot, opena browserandnavigate to http://www.xampp.org. Onthe mainpage (at leastas of thiswriting),there isanoptiontodownload XAMPPfor Windows,XAMPPforLinux,andXAMPPforOS X. Clickonthe linktodownloadXAMPPfor Linux andyour browsershouldautomaticallystartdownloadingthe install package. If,forsome reason, the Linux browsercan’topenthe XAMPP.orgmainpage (redirectstoapachefriends.org),thenthe XAMPPpackage can alsobe obtainedfromSourceForge.net(whichiswhatIhad to do). For the Linux package,itis namedsomethinglike xampp-linux-x64-5.6.11-1-installer.runorsomethingsimilar(the numbersmaybe different –noworries). My downloadplacedthe fileonmyLinux desktop,however,it may be placedina differentlocationonyoursystemdependingonthe downloadlocationsettingsfor your browser. The firstchallenge Iencounterediswhattodowiththisdownloadedfile. Since the .runextensionon the file isnota commonlyknownextension,Linux reallydoesn’tknow whattodowithit. Beingold school,I openeda terminal window toinvestigate thisfurther. Itturnsout the downloadedfileisan executable butitdoesn’tdownloadwiththe correctfile permissions toexecuteit. If youaren’tfamiliar withLinux file permissions,justfollowthesestepsanddon’tgetconcernedoverit. Fromthe terminal window,Ichangeddirectorytomydownloadlocation(/root/Desktop) andlistedthe filetolookatthe currentpermissions. Itshouldlooksomethinglikethe following: Figure 1 - examining XAMPP file permissions The permissionsforthe file are indicatedinthe first10 characters of the file listing. Inthiscase,the ownerof the file (root) hasreadand write permissions,the groupmembers(root) have read permissions,andeveryone else hasreadpermissions. Inorderto execute thisfileasaninstall program we needtoadjustthese permissions. The image below showsyouhow tomake thisan executablefile:
  • 3. DavidA. Bernhardt IBM Technical SalesSpecialist October2, 2015 3 | P a g e Figure 2 - changing XAMPP*.run file permissions Don’tworry if youdon’tknowexactlywhathappenswiththe ‘chmod’command. Youcan see the permissionshave changedonthe file anditcan now be run as an executable program. Atthispointwe wantto run the program. The followingfigureshowshow torunit: Figure 3 - XAMPP installation
  • 4. DavidA. Bernhardt IBM Technical SalesSpecialist October2, 2015 4 | P a g e Followthe installationwizardpromptsto install XAMPPonyoursystem. If youchose the defaults,the install programwill installthe productsinthe /opt/lamppdirectory(onLinux)orinC:xampp(on Windows). Aspartof the installationprocess,XAMPPwill startthe Apache webserver. However,the install scriptdoesnotmodifythe systemstartupscriptssothatApache (andthe otherprograms) will restartwhenthe systemisshutdown. Itisveryeasyto start/stop/restartXAMPPonLinux. Opena terminal andchange directoryto/opt/lampp (orthe install directoryif youchose somethingdifferent duringthe initial install). The directorywill looksomethinglike the following: Figure 4 - /opt/lampp directory listing The greenfilenamesinthe directorylistingare executables. TostartApache and MySql,justtype ‘/opt/lampp/lamppstart’onthe commandline. To stopApache and MySql,justtype ‘/opt/lampp/lamppstop’onthe commandline. There are otheroptionstoowhichcan be listedby typing/opt/lampp/lamppwithoutanyparameters. The commandwill displaythe availableoptions. As a final checkforthe installation,openawebbrowserandopen http://localhost. Youshouldsee the followingif XAMPPwasinstalledcorrectly andeverythingisrunningcorrectly.
  • 5. DavidA. Bernhardt IBM Technical SalesSpecialist October2, 2015 5 | P a g e Figure 5 - XAMPP start page Once you have XAMPPinstalled,youwill now be able todevelopPHPapplications. The directorywhere all the webpagesfor yourlocal serverare foundis/opt/lampp/htdocs –alsoknownasthe DocumentRootdirectoryforyourwebserver. Ialwaystestmyinstallationtoensure PHPisrunningand workingcorrectlybycreatinga simple test.phpfileinthe /op/lampp/htdocsdirectory. Myfile usually lookslike the following(Ishowthe file openwithvi): Figure 6 - test.php Once you create and save the file,openyourwebbrowserto http://localhost/test.php andyoushould see the followingoutput(justthe topisshown).Thisinformationwill be veryuseful aswe workon installingthe Informix databasemodules.
  • 6. DavidA. Bernhardt IBM Technical SalesSpecialist October2, 2015 6 | P a g e Figure 7 - output of test.php (phpinfo) Nowthat we have a workingweb server(Apache) andPHPwe canmove on to gettingInformix setupto workwithit. Download and Install Informix If you alreadyhave a workingApache andPHPenvironment,installingthe Informix engine orClient Software DevelopmentKit (CSDK) maybe the correctstartingpointforyour particularsituation. With my developmentbuild,IdecidedIwantedthe Informix database enginetorunlocallyonmy developmentserver. Havingthe Informix database enginelocallyinstalledisconvenientfordeveloping Informix basedapplicationssince Ihave control of database objects(databases,tables,views,indexes, storedprocedures,etc…) andcan make changesto anyof these objectsquicklyduringthe development lifecycle. If youare workingwithanexistingInformix database locatedonadifferentserver,the only componentyouwill needisthe Informix ClientSoftware DevelopmentKit. Informix isafull-featured,enterprise capable database productandcomesinseveral different bundles or packages. For my simple developmentenvironmentIuse the Informix Innovator-CEditionsince itis free todownloadfromIBM. AnyapplicationsIdevelopthataccessInformix Innovator-CEdition will workwithany of the otherInformix editionswithoutanymodificationsorchanges,sousing Innovator-C Editionfora developmentenvironmentisagreat wayto get started. Justto be complete,Ishouldpoint out that the Informix DeveloperEditionisalsoafree productand will workfordevelopmentpurposesas well. In additiontoinstallingthe Informix database engine,youwillalsowanttoinstall the Informix Client Software DevelopmentKit. The CSDKhasthe librariesneededforPHPtorun the PDO_Informix plug-in. We’ll deal withthe CSDKandhowto set that upafterwe getthe Informix database installed. Imention the CSDK aheadof time because youmightas well downloaditwhile youare onthe IBMwebsite to downloadthe Informix databaseengine. Informix software downloadsare available from the IBMInformix website athttp://www- 01.ibm.com/software/data/informix/download.html. Youwill see linkstoboththe Developerand
  • 7. DavidA. Bernhardt IBM Technical SalesSpecialist October2, 2015 7 | P a g e Innovator-Ceditions(no-charge database)aswell as90-daytrialsfor boththe Informix Enterprise EditionandInformix AdvancedEnterpriseEdition. Below the Informix databasessection,youwillalso see a linkforthe Informix ClientSoftware DevelopmentKit(CSDK). Downloadboththe database and the CSDK to yourXAMPP server. You shouldhave twocompressedarchive fileswhenthe downloadis complete. AsImentionedbefore,mysystemplacesdownloadedfilesonmydesktopandthe image belowshowsyouwhatthe downloadedpackageslooklike. Figure 8 - Informix software packages (on the desktop) Both the Informix database andthe CSDKare downloadedasarchive filesintape archive (tar) format. In orderto access the filesinthe archive we needtoextractthem. Since Idon’twant all the Informix files placedonmy desktop,Icreate a folder,copythe archive to the folder,andextractthe files. The stepsI take to do that are illustratedinFigure 9:
  • 8. DavidA. Bernhardt IBM Technical SalesSpecialist October2, 2015 8 | P a g e Figure 9 - extracting and starting the Informix database install Once the filesare extractedyouwill see the ids_install (IDSstandsforInformix DynamicServer) commandin the directorylisting. Since the currentdirectoryisnotinmy currentsystempath,I start the install usingthe command“./ids_install–i gui”whichwill invokethe graphical userinterface (thereisa console andsilentinstalloptiontoobutIwon’tcoverthat here). Follow the promptsinthe GUI to complete the install. Also,allowthe installscripttocreate yourInformix instance foryousoyouwill have a workingdatabase serverwhenthe install iscomplete. Also,the GUIwill promptyoutoopena terminal window toaccessthe database whencomplete. Repond‘yes’toopenthisterminal soyoucan verifythe installation. IinstalledmyInformix databasetothe /opt/informix directory. Iwill use this locationthroughoutthe remainderof thisdocument. Make note of the passwordyoucreate forthe Informix usersince youwill needthatlater. Once the database installationiscomplete,repeatthe processforthe CSDKarchive file. Use the ‘installclientsdk’commandinsteadof the ‘ids_install’command. Followthe GUIpromptsto complete the installation. Note:some distributionsof the Informixengine come withthe CSDKincluded inthe package. If the CSDKinstallationdiscoversanexistingCSDKalreadyinstalled,youcanabort or cancel the install since youalreadyhave all the componentsyouneedforInformix. The last stepinthe Informix installation isverifyingthe installationof the database. If youopenedthe terminal window duringthe Informixengine install (ids_install process),the correctenvironment variableshave beensetwithinthe terminal toenable accesstoInformix. Checkthe installationby typing‘onstat–‘ at the terminal windowcommandprompt. Youroutputshouldlooklike the following:
  • 9. DavidA. Bernhardt IBM Technical SalesSpecialist October2, 2015 9 | P a g e Figure 10 - verify the Informix installation As the image shows,InformixDynamicServer(myversion - 12.10) iscurrentlyonline. Thismeans Informix isrunningandsharedmemoryisinitializedforthe database instance. We are now ready for the nextstepof the process. PHP and Informix – PDO_Informix module There are a fewpre-requisitesforaddingPDO_Informixtothe PHPconfiguration. First,yoursystem needstohave a compiler– usuallyGCCor CC – installed. Forthe RedHatserverI usedformy server,the compilerwasinstalledaspartof the initial operatingsystem. Manyversionsof Linux will have the compilerautomaticallyinstalledaspartof the operatingsysteminstall,however,youshouldcheckyour Linux servertobe sure. Anothercritical componenttoinstallingPDO_Informix isthe PHPDevelopmentcomponents. If you installedXAMPP(orLAMPPonLinux),thenthisPHPextensionwasinstalledaspartof the package. If youinstalledPHPusinganothermethod,youwill have tocheckyourPHPinstall tosee if thisextension was included. Specifically,we will needthe command‘phpize’tocreate the pdo_informix.solibrary. If youare uncertain,doa quickfilesystemcheckforthe ‘phpize’command. Iuse the command‘find/ - name phpize –print’froma terminal tolocate the file. If youcan’tfindthe commandyou will needto downloadthe PHPDevelopmentpackage fromthe Internetandinstall itaccordingtothe instructions. One itemto mentionissome PHPinstallationsincludePEARandPECL. If you have PEARand PECL installed,youcaninstall PDO_Informix using‘peclinstallpdo_informix’fromaterminal. If there are any missingdependencies,the commandwillinformyouwhatismissing. Iwon’tgo intoPEARand PECL install since those applicationsare well documentedonthe Internet. So,for the RedHat server,Ididnot have PEARor PECL available soinstallingthe PDO_Informix extension takesa bit of work. The firstitemonour lististo downloadthe PDO_InformixPECLpackage fromthe PECL repositoryonthe Internet. Usingyourfavorite searchengine, simplysearchforPECL PDO_Informix. Asof thiswriting,the PDO_Informix package islocatedat
  • 10. DavidA. Bernhardt IBM Technical SalesSpecialist October2, 2015 10 | P a g e https://pecl.php.net/package/PDO_INFORMIX withacurrentversionof 1.3.1. Downloadthe PDO_INFORMIX-1.3.1.tgzbyclickingonthe linkinthe download sectionof the page. Since the PDO_Informix package isanextensionof PHP,the correctplace to place the filesinthe package is inthe PHP extensionsdirectory. FormyLAMPP install,the directorywhere PHPextensions are storedis/opt/lampp/include/php/extsothatis where Iextractedthe PDO_Informix archiveI downloadedfromthe PECLrepository. If youare unsure of where the extensionstoyourPHPserver are locatedjustlookforany of the installedpackages(GDisa goodone since itisthe extensionthat allowsthe servertoworkwithimagesandit isextremelycommoninPHPinstalls). Use the find commandto locate one of the installedextensionsanditwill show youwhere toplace the PDO_Informix extractedfiles. Figure 11 showsyouhow to find,move andextractthe PDO_Informix package in the PHPextensionsdirectory. Figure 11 - finding the extension directory and unpacking PDO_Informix As youcan see,the package containsfilesthatrequire youtocompile the programwithaC compiler. Thisisn’toverlydifficult. However,thereisacritical stepto compilinganythingforInformix thatmany of the instructionsonthe Internetoverlook. Inorderto compile PDO_Informix,the compilerneedsto knowwhere the appropriate Informix librariesare located. Also,PHPneedstoknow somethingabout the Informix environmentinordertoworkwiththe installeddatabase engine. Thisisall accomplished throughenvironmentvariables. So,let’sgetthose setup. Whenyou installedInformix (probablyinthe /opt/Informixdirectory),the install programcreatedsome sample shell scriptsthatsetthe appropriate environmentvariables. Figure 12showsthe directory listingof /opt/Informix,the shell scriptsthatwere created (withabox aroundthem),anddisplaysthe environmentvariablesthatare set(forthe K-Shell script):
  • 11. DavidA. Bernhardt IBM Technical SalesSpecialist October2, 2015 11 | P a g e Figure 12 - scripts for setting Informix environment variables Since I use the BASH shell,Ihave tosetthe environmentvariablesexactlyasshownabove (if youare usingthe C-Shell youwoulduse the ol_informix1210.cshfile). Asageneral rule,Ieitheraddthese globally (mostLinux systemuse /etc/profile forsettingglobal environmentvariables) soall userswill have themsetautomatically(if itisa sharedserverandmultiple people are usingit) orI addthe INFORMIXDIR,INFORMIXSERVER,ONCONFIG,INFORMIXSQLHOSTS,GL_USEGLU, and PATH environment variable settingsshownabove tomylocal .bash_profilesothatmy local account will automaticallyset these whenIlogin. Inthiscase, I editedthe .bash_profile in$HOME (formy rootaccount) andalso editedthe .bash_profileforthe Informix useraccount. Withthese environmentvariablesset,youcan type any of the Informix command(onstat,oninit, onmode, onspaces,ontape,etc…) directlyfroma terminal commandline andtheywill work,regardlessof yourcurrentdirectory. There isone more extremelyimportantenvironmentvariable thatisrequiredforcompilinganything Informix related (oranyotherClibraryadditionsforthatmatter). Thisenvironmentvariableisthe LD_LIBRARY_PATH. If you checkthe http://localhost/test.php webpage,youwillfindthisenvironment variable inthatlisting,however,therewon’tbe anythingInformixrelatedassociatedwithit. We need to fix thisif PHPis goingto be able to use Informix. So,the challengeis –where dowe set this environmentvariablesothatPHP can use it? Well,since PHPisrunningwithinthe Apache webserver, we have to setthe environmentforthe webservertoinclude thisvariable. If youusedXAMPP(LAMPP) to install the Apache webserverwithPHP,the startupscriptswill lookforanyadditionalenvironment variablesinthe /opt/lampp/bin/envvarsfile. If youare notsure where additional environmentvariables can be setfor yourApache/PHPstartup,youcan examine the startupscriptstofindit. Figure 13 shows the part of the apachectl shell script(locatedin/opt/lampp/bin) thatloadsadditional environment variables. Ifoundthe apachectl shell scriptbyexaminingthe lamppstartupscript(/opt/lampp/lampp) and findingthe commandtostart the Apache webserver.
  • 12. DavidA. Bernhardt IBM Technical SalesSpecialist October2, 2015 12 | P a g e Figure 13 - apachectl shell script environment variables section Since the apachectl scriptisspecificallylookingforthe envvarsfile inthe /opt/lampp/bindirectory,all we needtodo is addthe necessaryenvironmentvariablestothisfile. Figure 14showsthe contentsof the envvarsfile. Ialsoensure the INFORMIXDIRenvironmentvariable issetforApache/PHP since many of the entriesinthe LD_LIBRARY_PATHreferto it.
  • 13. DavidA. Bernhardt IBM Technical SalesSpecialist October2, 2015 13 | P a g e Figure 14 - contents of the /opt/lampp/bin/envvars file In orderfor these changestotake effect,youwill needtorestartthe Apache webserver. Use the command‘/opt/lampp/bin/apachectl restart’torestartApache. AftersuccessfullyrestartingApache, the outputof http://localhost/test.php will show the changestothe LD_LIBRARY_PATH(figure 15). Figure 15 - LD_LIBRARY_PATHafter restart
  • 14. DavidA. Bernhardt IBM Technical SalesSpecialist October2, 2015 14 | P a g e Nowthat we knowhowto setthe LD_LIBRARY_PATH variable,itwouldbe goodtoknow whatto include inthe LD_LIBRARY_PATH to ensure everythingworkscorrectly. InFigure 14, part of the LD_LIBRARY_PATH includescomponentsof the OpenAdminTool (OAT) whichinstallsitsownweb serveras part of the install process. If youare usingOAT,youwill wantto keep these directoriesinthe LD_LIBRARY_PATH. For our installation,we onlyneedtoinclude the followingaspart of the LD_LIBRARY_PATH (rememberwe setthe $INFORMIXDIRenvironmentvariable to/opt/Informix): $INFORMIXDIR/lib $INFORMIXDIR/lib/cli $INFORMIXDIR/lib/esql $INFORMIXDIR/incl $INFORMIXDIR/incl/cli $INFORMIXDIR/incl/esql /lib(if notalreadyset) /usr/lib(if notalreadyset) /usr/local/lib(if notalreadyset) Followthe syntax inFigure 14 to setthe LD_LIBRARY_PATH for yourserverenvironment. Nowthat we have setall the environmentvariables,we canfinallymove ontocompilingthe PHP PDO_Informix extension. Openaterminal windowandchange the directorytothe locationwhere you unpackedthe PDO_INFORMIX-1.3.1.tgzfile. Execute the followingcommands: If your phpize commandislocatedina differentdirectorythan/opt/lampp/bin,thensubstitute that directoryinyourpath. The outputof the phpize commandwill looksimilartoFigure 16: Figure 16 - output of phpize command The ./configure commandwill produce several pagesof informationasitchecksto ensure necessary componentsare available. Whenthe commandcompletesyou’llsee anoutputsimilartoFigure 17 and you’ll see config.status:creating config.h: exportPATH=/opt/lampp/bin:$PATH phpize ./configure make
  • 15. DavidA. Bernhardt IBM Technical SalesSpecialist October2, 2015 15 | P a g e Figure 17 - end of configure command output The last commandinthe sequence isthe make command. ThiscommandtellsLinux to“make”or compile all the applicablefilesintoasharedlibrarythatcan be usedby PHP. Just like the configure command,make producesseveral pagesof informationasthe compilationtakesplace. The final output will looksimilartoFigure 18: Figure 18 - make command output (last page) As youcan see inFigure 18 (nearthe top),the compiledlibraryfilesare placedinthe /opt/lampp/include/php/ext/pdo_informix/modulesdirectory. If we lookat the directorylistingyouwill see the resultsinFigure 19:
  • 16. DavidA. Bernhardt IBM Technical SalesSpecialist October2, 2015 16 | P a g e Figure 19 - pdo_informix.so shared library The file we needtoallowPHPto connectto Informix database isthe pdo_informix.solibraryfile. The final stepswe needtotake are puttingthisfile inthe extensionsdirectoryandenablingthe extension withinPHP. Enabling the PHP Extension Goingback to http://localhost/test.php webpage,we canfindthe directorywhere PHPlooksforall the currentextensions. Thisdirectoryislistedasthe extension_direnvironmentvariable. Whenyoufindit inon the webpage (see Figure 20),take note of the directory – we will needitforinstallingthe pdo_informix.sosharedlibrary. Figure 20 - PHP extension_dir location For my installation,Isimplycopythe pdo_informix.sofilefromitscurrentlocation (/opt/lampp/include/php/ext/pdo_informix/modules)tothe PHPextensiondirectory (/opt/lampp/lib/php/extensions/no-debug-non-zts-20131226) using: cd /opt/lampp/include/php/ext/pdo_informix/modules cp pdo_informix.so /opt/lampp/lib/php/extensions/no-debug-non-zts-20131226
  • 17. DavidA. Bernhardt IBM Technical SalesSpecialist October2, 2015 17 | P a g e Next,we needtomodifythe PHPsettingsinphp.ini toenable the extension. Todetermine where the currentphp.ini file islocated,we canagainlookat the http://localhost/test.php webpage. The current configurationfileislistedinthe topof the phpinfo() output(seeFigure 21). Figure 21 - current php.ini file location From a terminal window,we canuse ‘vi’toeditthe php.ini file oryoucanuse a texteditorof your choice. You will notice thatthe php.ini file isquite lengthyanditisorganizedintosections. Youwill needtofindthe DynamicExtensionssectionandenterthe following2linestothe file: Your entrieswill looksomethinglike Figure22 (below): extension=”pdo_informix.so” extension=”pdo_dblib.so”
  • 18. DavidA. Bernhardt IBM Technical SalesSpecialist October2, 2015 18 | P a g e Figure 22 – adding extensions to the php.ini file Once you have completed the editsandsavedthe file,youwill needtorestartthe Apache webserver againto allowPHPto loadthe dynamicextension. Simplyissue arestartcommandas described previously. If everythinghasworkedproperly,the new pdo_informix dynamicextensionwill be enabledandthe phpinfo() outputwill show the extensionloadedandavailable(Figure23):
  • 19. DavidA. Bernhardt IBM Technical SalesSpecialist October2, 2015 19 | P a g e Figure 23 - pdo_informix installed, loaded, and enabled
  • 20. DavidA. Bernhardt IBM Technical SalesSpecialist October2, 2015 20 | P a g e Of course,itisalwaysgoodpractice totest yourwork andwe do thisby creatinga simple PHPpage that accessesourInformix database server. Ensure thatthe Informix serverisrunningusingonstat(you shouldsee itonline) andthensave the followingcode inaphpfile under/opt/lampp/htdocs: Of course,there isalwayssomethingelseyouneedtodoto getcopied code to workon your specific server. Inthiscase, youneedtofindthe service numberforthe Informix database engineandchange <Informix password>tothe actual Informix user’spassword. Tofindthe service numberforyour Informix database engine simplytype the followingatthe commandline: <html> <head> <title>Informix PDOTest</title> </head> <body> <?php try { $db = new PDO("informix:host=localhost;service=<Service>;database=sysmaster;server=ol_informix1210;proto col=onsoctcp;EnableScrollableCursors=1;","informix","<Informix password>"); print"ConnectionEstablished!nn"; $stmt = $db->query("select* fromsystables"); print("<table><tr><th>Table Name</th><th>Owner</th><th>PartNumber</th><th>Table ID</th></tr>"); foreach($stmtas $row){ print("<tr><td>".$row[0]."</td><td>".$row[1]."</td><td>".$row[2]."</td><td>".$row[3]."</td></tr> "); } print("</table>"); } catch (PDOException$e) { print("Error!:" .$e->getMessage() ."<br/>"); die(); } ?> </body> </html>
  • 21. DavidA. Bernhardt IBM Technical SalesSpecialist October2, 2015 21 | P a g e You shouldsee somethingsimilartothe following(Figure 24): Figure 24 - finding the Informix database server port number For my Informix server,the servicenumberis30503. Yours will probablybe different. Justmake sure youchange <Service>tothe actual numberforyour server. If youdon’tget anyresultsfromrunning thiscommand,thenyourDBA probablyuseda non-standardservice name forthe Informix install. You can modifythe commandto justlookforInformix (cat/etc/services|grepInformix) andsee if thatgives youresults. If not,ask your Informix DBA forthe port numberforyour Informix engine. Now,forthe momentof truth. Openthe php file (Inamedmine test_ifx.php) inawebbrowsertosee if youcan connectto Informix,queryadatabase,andreturnresults. If successful,youroutputwill look like the following: cat /etc/services|grep ol_informix
  • 22. DavidA. Bernhardt IBM Technical SalesSpecialist October2, 2015 22 | P a g e Figure 25 - successful output from test_ifx.php Conclusion AddingInformix databasesupporttoyourexistingPHPenvironmentisfairlystraightforwardonce you’ve identifiedall the necessarycomponentsandinstalledthem. Aswithmostserversandsystems, there are variationsinarchitecture anddirectorystructure whichmayrequire youtoalterthese instructions. Withalittle researchandusingavailableresourcessuchasIBMDeveloperworks,you’ll be able to adjustforthese differencesandgetthe mostoutof yourInformix PHPenvironment.
  • 23. DavidA. Bernhardt IBM Technical SalesSpecialist October2, 2015 23 | P a g e Appendix A – List of Figures Figure 1 - examining XAMPPfile permissions........................................................................................2 Figure 2 - changing XAMPP*.run file permissions..................................................................................3 Figure 3 - XAMPP installation...............................................................................................................3 Figure 4 - /opt/lampp directorylisting..................................................................................................4 Figure 5 - XAMPP start page................................................................................................................5 Figure 6 - test.php ..............................................................................................................................5 Figure 7 - output of test.php (phpinfo).................................................................................................6 Figure 8 - Informix software packages (on the desktop) ........................................................................7 Figure 9 - extracting and starting the Informix database install..............................................................8 Figure 10 - verify the Informix installation............................................................................................9 Figure 11 - finding the extension directory and unpacking PDO_Informix.............................................10 Figure 12 - scripts for setting Informix environment variables .............................................................11 Figure 13 - apachectl shell script environment variables section..........................................................12 Figure 14 - contents of the /opt/lampp/bin/envvars file......................................................................13 Figure 15 - LD_LIBRARY_PATH after restart........................................................................................13 Figure 16 - output of phpize command ..............................................................................................14 Figure 17 - end of configure command output....................................................................................15 Figure 18 - make command output (last page)....................................................................................15 Figure 19 - pdo_informix.so shared library.........................................................................................16 Figure 20 - PHP extension_dirlocation...............................................................................................16 Figure 21 - current php.ini file location...............................................................................................17 Figure 22 – adding extensions to the php.ini file.................................................................................18 Figure 23 - pdo_informix installed, loaded, andenabled .....................................................................19 Figure 24 - finding the Informix database server port number.............................................................21 Figure 25 - successful outputfrom test_ifx.php..................................................................................22