Build Apache 2.2.X on AIX 5.3 Platforms

Build Apache 2.2.X on AIX 5.3 Platforms Part I: Basics

http://olex.openlogic.com/wazi/2008/how-to-build-apache-22x-on-aix-53-platforms/

PartII:CommonIssues

http://olex.openlogic.com/wazi/2008/how-to-build-apache-22x-on-aix-53-platforms-part-ii-some-common-errors-and-pitfalls/

BuildApache2.2.XonAIX5.3PlatformsPartI:Basics

WhiletherearemanybinaryversionsofApacheavailablefortheAIXplatform,manypeoplewishtobuilditthemselvessotheycanaddmodulesorcustomlocationstotheApacheWebserver.Shouldyouneedthatflexibility,thistutorialwillguideyou.

ThisisnotanAIXadministrationguide,andanyadministrationtaskssuggestedbythisguidewillneedtobeperformedasa“root”user.Ifyou’reunsureofwhetherornotyouarea“root”user,thenyoushouldstopnow,andfindsomeonewhoknowsforsure.

This tutorial will also assume that we’re building Apache with GCC (GNU Compiler Collection). The steps outlined here may work with other compilers, but have only been tested with GCC.

BeforeYouStart

InordertoproperlypreparethesystemandtheApachebuildconfiguration,weneedtomakeachecklistofwhereyouwantApacheandwhatuseyouwishtomakeofit.

WherewillyouinstallApache?InordertocompileApacheyou’llneed~250MBoffreediskspaceinthefollowingareas:

BuildDirectory–thisiswhereyou’llbuildthecode.Itcanbeanywhereonthefilesystem.Althoughmanypeoplechoosetodothisintheirhomedirectory,werecommendthatyoucreateaspecificdirectory.Somethinglike/buildintherootdirectory,orinaplacewhereyouhavefreespace.

PrefixDirectory–thisiswhereyouwantApachetobeinstalledwhenyou’redone.Bydefault,Apacheinstallsinthe/usrpartition.

TmpDirectory-It’salwaysagoodideatohavesomefreespacein/tmpduringbuilds.

You’llneedthefollowingtools:

ApacheSourceCode:DownloadApacheversion2.2.8.

GCC4.0:GNUCcompilerversion4forAIX5.3.You’llfindithere.

libgcc4.0:thelibraryforGCCforAIX5.3.Goheretogetit.

You’llalsoneedtoinstalllibm.afromtheAIX5.3installationdisk1.Werecommendusing“smittyinstallp”toaccomplishthisinstall.

UncompresstheApachesourcecodeintoatemporarylocation.Weusuallycreatea/hold/Apache-2.2.8directory,butanydirectorywhereyouhavespaceisfine.

Changedirectoryto/hold/Apache-2.2.8(cd/hold/Apache-2.2.8)

Runtheconfigurecommandwiththeprefixoption.(./configure--prefix=/usr/local/apache).ThiscommandevaluatesyoursystemforitsreadinesstobuildApache.You’llnoticethatsomethingswillbefound,andotherswillnotbefound.Aslongastheconfigurecompleteswithouterrors,youmaycontinuethebuildprocess.

Note: Installing the RPMs (Red Hat Package Managers) for GCC should be done as the root user.

Meat&Potatoes

BuildingApache

Firstyou’llwanttouncompresstheApachesourcecodeintoatemporarylocation.Weusuallycreatea/hold/Apache-2.2.8directory,butanydirectorywhereyouhavespaceisfine.

Thistutorialwillassumethatdirectoryis/hold/Apache-2.2.8andwillassumethattheanswertoquestion1inthePrerequisitessectionaboveis/usr/local/apache.

MaketheApacheproject.(make)ThemakecommandreadstheMakefilethatwascreatedintheconfigurationstep.Thiswillrunforapproximately15minutes.Youmayseesomewarnings,butagain,aswiththeconfigurationstep,ifitcompleteswithouterrors,itisfine.

DeploytheApacheProject.(makeinstall)Oncemore,thisshouldbeaccomplishedasthe‘root’user.

Testtheproject.Changedirectoryto/usr/local/apache/bin.RuntheApachestart-upscript.(./apachectlstart)YoumaybewarnedthatApachecan’tdeterminetheserver’sname,butnoworries–that’stobeexpected,aswehavenotconfiguredApache.Theserverwillstillstartup.

InawebbrowsergotoURLhttp://localhost.

FinishingUp

Youshouldseethepageload,anditwillreport“ItWorks!”

BuildApache2.2.XonAIX5.3PlatformsPartI:Basics

Purpose

BuildingtheApacheWebserveronAIXisgenerallyastraightforwardenterpriseinwhichyou:obtainthecode,runafewsimplecommands(configure,make,andmakeinstall)andthenstopbyyourboss’scubetoaskifshe’sgotanythingshe’dlikeyoutotakeoffherplate.

Youdon’tknowusverywellyet,sowe’llbefrank:wesay“straightforward”withtonguefirmlyplantedincheek.AquickGooglesearchonthetopicwillreturnaplethoraofissuesusersencounterwhilebuildingthecodeiftheytryanythingbeyondstraightvanilla.Inotherwords,ifyouneedaninstallwithanyadditionalmodulesorcapabilities,expectsomeissues.

We’vealreadycoveredthevanillainstallation,inthefirstinstallmentoftheBuildingApacheonAIX.Thissecondpartofthetutorialtakesyoubeyondthosebasics.Beforeattemptinganyofthesework-arounds,werecommendthatyouhavemetalltherequirementsfora“basic”build.

BeforeYouStart

Followthesetupfromthefirstinstallmentofthisguide,BuildingApache2.2.XonAIX5.3platforms.

Meat&Potatoes

CommonProblems

Neglectingtocleanbetweenfailedbuilds(orbuildswithnumerous,particularerrors)

Duringcompilationphaseofthebuild,ifanyerrorsareencountered,thesubsequentbuild

mustbeprecededbyamakeclean.AsJoeBidenwouldsay“Letmerepeatthat”,makeclean.

Itisimportantthatyourbuildrunsfromstarttofinishwithouterrorsandthatthereis

notanyartifactsfrompreviousbuildattemptsgivingyoufalsepositiveorfalsenegativeresults.

EnvironmentIssues

Themostfrequentissueswithabuildareonesthatareencounteredbecausethebuildenvironment

isnotsetupcorrectly.Incorrectgccversion,gcclibraryversion,andnotaddingthe

mathlibrary(libm.a)arethemostcommon.Setupoftheseenvironmentelementsarecoveredin

thefirstinstallmentofthisguide.

ConfigurationOptions

ThelatestversionsofApacheWebserverhaveover160configurationoptionsandflags,makingformillionspotentialcombinations.TheseoptionscontrolexactlyhowtheWebserverisgoingtobuildand,moreimportantly,howitisgoingtorun.OnAIX,thereareseveraloptionsthatwehavefoundareeitherrequired,orparticularlybeneficialtocompletethebuild.

--prefix=PATH

Settingthisoptionisrequired.PATHistheexactpathwheretheWebserverwillbeinstalledandrunfrompostcompilation.

--with-included-apr

aprandapr-utilarebundledwiththeApacheWebserversourcereleases,andwillbeusedwithoutanyproblemsinalmostallcircumstances.However,ifaprorapr-utilversions1.0or1.1,areinstalledonyoursystem(asisthecaseifyouareusingAIX5.3),youmusteitherupgradeyourapr/apr-utilinstallationsto1.2andforcetheuseofthebundledlibraries,orhavehttpduseseparatebuilds.

Tousethebundledapr/apr-utilsources,specifythe--with-included-aproptionaddedinversion2.2.3ofApacheWebserver.

--enable-ssl=shared

IfyouchoosetoaddsslcapabilitiestoyourWebserver,youmustenablethisoption.ThisalsomeansthatyoumusthaveOpenSSLinstalledonyoursystem.OnAIXsystemsatypicalinstallwilllitterOpenSSLelementsacrossyourfilesystem,andthiswillcauseissuesasyoucompile.Forinstance,wehavefoundcompleteorportionsofOpenSSLinstalledinthefollowingdirectories:/usr,/usr/bin,/opt/freeware/bin,/usr/include,/usr/linux.Mostoften,thecorrectOpenSSLtouseisthelibrariesfoundin/usr.Tospecifyusingthisone,youmustsetthefollowingoptions:

--with-ssl=/usrThistellstheconfigurationsteptobindtolibrariesfoundinandunder/usr.

--enable-mods-shared=sslThistellsthesystemtocreatethesslmoduleasasharedobject.

Otherimportantconfigurationoptionsinclude:

--enable-so:Thisconfiguresapacheforlaterinstallationofsharedobjects(modules).Apachehttpdcanbebuilteitherwithstatic,built-inmodules,orbebuiltsothatmodulescanbestoredoutsideofthehttpdbinaryfile,andmaybecompiledandaddedatalatertime.HavingtheabilitytoaddmodulesafterthemainbuildisaccomplishedusingtheApacheExtentionTool(apxs).Thisdynamicbuildisenabledbythe–enable-sooption.ThemodulesthatarebuiltasextentionstothemainbinaryarecalledDynamicSharedObjects(DSO).

Finally,hereareafewoptionalmodulesyoumayincludeduringyourconfiguration:

ProxyModules

--enable-proxy

--enable-proxy-ajp

--enable-proxy-balancer

ConfiguringProxy

ForwardProxy

ProxyRequestsOn

ProxyViaOn

<Proxy*>

Orderdeny,allow

Denyfromall

Allowfrominternal.example.com

</Proxy>

ReverseProxy

ProxyRequestsOff

<Proxy*>

Orderdeny,allow

Allowfromall

</Proxy>

ProxyPass/pathhttp://domainname.com/thing

ProxyPassReverse/pathhttp://domainname.com/thing

ProxyAccess

<Proxy*>

OrderDeny,Allow

Denyfromall

Allowfrom192.168.0

</Proxy>

HelperModules

--enable-module=rewrite

--enable-module=log_referer

CommonErrorMessages

Opensslcompilationerror.

Sampleerror:/usr/include/openssl/pq_compat.h:1:3:error:invalidpreprocessingdirective#IBM_PROLOG_BEGIN_TAG

OnAIX,itisnotuncommontoencountererrorsduringcompilationifsslisenabled.Thisisbecause

IBM’sOpenSSLpackagecontainsanumberofincludefilesin/usr/include/opensslwhereaspecial“IBMProlog”includelinehasbeenadded,makingtheheaderfilesincompatiblewithgcc.

Thefixistoeditpq_compat.h,andcommentoutanylineswithIBM_PROLOG_BEGIN_TAG,aswellasanyassociatedlineswiththePrologincludetag.

Linkererrors

Sampleerror:0711-317ERROR:Undefinedsymbol:.BIO_clear_flags

OnAIX,onceyouhavesatisfiedthegccrequirementstobuildApachetwolinkerswillexist

onyoursystem.Linkererrors,liketheoneseenabove,arearesultofthepathingtolibrariesbeing

differentforthecompilerandthelinker,andcanberesolvedbysettingenvironmentflags.

Now,onallUNIXsystemsthereisalibrarypaththatistobeusedduringlinkphase,andruntime,

andonallUNIXsystemsthispathissetviatheLD_LIBRARY_PATHvariable.AllUnixsystems,thatis,exceptAIX.Forthisreason,weusuallysetthepathusingboththestandardandtheAIXvariableasasafetyprecaution.ThenativeAIXlinkershoulduseLIBPATH,whileLD_LIBRARY_PATHwillbeusedbytheGnulinker.

Examplelibrarypathsetuplookslikethis:

setLIBPATH=/usr/lib:/lib

setLD_LIBRARY_PATH=/usr/lib:/lib

exportLIBPATHLD_LIBRARY_PATH

Finishing Up

Augmentingthebasicbuildwithadditionalmoduleswilladdcomplexitytothebuildprocess,butbyfollowingthistutorialandproperlysettingupyourenvironment,mosterrorscanbeavoided.Ofcourse,eachsystemcanhaveotherlibrariesandpackagesinstalledthatcancauseadditionalerrormessages,orwarnings.WhilewehavebuiltApacheonAIXmanytimes,onmanydifferentsystems,thisguidedoesnotclaimto,andcan’tpossibly,anticipateeverysituation.Shouldyouencounterothererrors,pleaseemailthemtous,andwe’llincludetheminafuturerevision.

We wish you good luck, and happy compiling.

相关推荐