You are on page 1of 2

15/10/2013

Multiple PHP versions set-up Derick Rethans

MultiplePHPversionssetup
London,UK Monday,November7th2011,09:11GMT Formanyofmyprojects(bothhobbyandcommercial)IneedtosupportmanydifferentPHPconfigurations.Notonly justdifferentPHPversions,butalsodebugbuilds,ZTSbuildsand32bitbuilds.Inordertobeabletotestandbuild extensionsagainstallthosedifferentPHPconfigurationsIhaveadoptedasimplemethodthatI'msharingwithyou here. ThemajorpartofitisthatIuseadifferentinstallationprefixforeveryconfigurationofPHPthatImake.Rightnow, l s/ u s r / l o c a l / p h pshows:
5 . 1 d e v 5 . 3 . 2 5 . 3 . 8 d e v 5 . 3 d e v 3 2 b i t 5 . 3 d e v z t s 5 . 4 d e v t r u n k 5 . 2 d e v 5 . 3 . 7 5 . 3 d e v 5 . 3 d e v n o d e b u g 5 . 4 . 0 b e t a 1 5 . 4 d e v z t s

TherearetwotypesofPHPinstallsthatImake:"dev"versionsfromSVNbranches,and"release"versionsbuildfrom SVNtags.FromthelistaboveyouseeIhavetheSVNversionsof5.1,5.2,5.3.8,5.3(invariousforms)and5.4(both normal,andZTS). IhaveascripttocompilePHPwhichwhatevercombinationIwant:version,debug(default)ornondebug,normal (default)orZTSand64bit(default)or32bit.Theconfigureoptionsarenicelyhardcoded:) Thescriptsacceptargumentsinaspecificorder:


v e r s i o n[ " d e b u g " | " n o d e b u g "[ ," n o z t s " | " z t s "[ ," " | " 3 2 b i t "]]]

Forasimple5.3devbuildIrun:
. / b u i l d5 . 3 d e v

ThiscompilesPHP5.3fromSVN,indebugmode,withoutZTSandforthe64bitarchitecture.Somethingmoreexotic variantscouldbe:
. / b u i l d5 . 3 . 8d e b u gz t s . / b u i l d5 . 4 d e vn o d e b u gn o z t s3 2 b i t

EachinvocationofthescriptwillconfigureandbuildPHP,andtheninstallinto / u s r / l o c a l / p h p / { { v a r i a n t } }. ThescriptalsohasahardcodedlocationwherethePHPsourcesare.Inmycase,that'sasparsecheckoutinto / h o m e / d e r i c k / d e v / p h p / p h p s r c. Withthehelpofasmall . b a s h r csnippet:

derickrethans.nl/multiple-php-version-setup.html

1/2

15/10/2013

Multiple PHP versions set-up Derick Rethans

f u n c t i o np e( ){ v e r s i o n = $ 1 s h i f t i f[" $ # "= =" 0 "] ;t h e n e x p o r tP A T H = / u s r / l o c a l / p h p / $ { v e r s i o n } / b i n : / u s r / l o c a l / b i n : / u s r / b i n : / b i n e l s e P A T H = / u s r / l o c a l / p h p / $ { v e r s i o n } / b i n : $ P A T H$ @ f i }

IcannoweasilyswitchbetweenPHPversionsbytypingontheshell:
p e5 . 3 d e v

or:
p e5 . 4 d e v z t s

AndeachversionwillhaveatotallyseparatedenvironmentformetoinstallPEARpackagesandPECLextensionsin, anddomyownextensiondevelopment.Ofcourse,eachseparatedenvironmentalsocomeswithitsown p h p . i n ifile (in / u s r / l o c a l / p h p / { { v a r i a n t } } / l i b / p h p . i n i). Thissetupmakesmylifeawholeloteasier,andIhopeitisusefulforyouaswell.Thanksforlistening!


ThissiteandallofitscontentsareCopyright20022013byDerickRethansAllrightsreservedSyndicationPolicy

derickrethans.nl/multiple-php-version-setup.html

2/2

You might also like