Tải bản đầy đủ

Sams apache phrasebook may 2006 ISBN 0672328364

Apache:PhraseBook:EssentialCodeand
Commands
ByDanielLopez,JesusBlanco
...............................................
Publisher:Sams
PubDate:May25,2006
PrintISBN-10:0-672-32836-4
PrintISBN-13:978-0-672-32836-7
Pages:240

TableofContents|Index

WhatisthenewessentialforApachedevelopers?TheApachePhrasebook.Packedwith
practicalsolutions,or"phrases,"fortasksthattheApachedevelopermuchaccomplish
everyday,thephrasebookfillstheneedforashort,functional,to-the-pointreferencefor
Apache.Thecodecontainedinthephrasebookisflexible,soitcanbeeasilyadaptedto
yourneeds.Today'sproblemislikelytobetomorrow'sproblem,sodon'twasteyourtime
onlengthytutorials.GostraighttopracticalApachetoolsthatprovideimmediately
applicablesolutionsforanysituationwiththeApachePhrasebook.



Apache:PhraseBook:EssentialCodeand
Commands
ByDanielLopez,JesusBlanco
...............................................
Publisher:Sams
PubDate:May25,2006
PrintISBN-10:0-672-32836-4
PrintISBN-13:978-0-672-32836-7
Pages:240

TableofContents|Index









































Copyright
AbouttheAuthors
Acknowledgments
WeWanttoHearfromYou!
ReaderServices
Introduction
Chapter1.ApacheBasics
DiscoveringApache
DeterminingWhetherApacheIsAlreadyInstalled
InstallingApache1.3onLinuxandUnix
InstallingApache2.0onLinuxandUnix
InstallingApacheonWindows
ConfigurationFileBasics
UsingMultipleConfigurationFiles
Starting,Stopping,andRestartingApache
ChangingtheAddressandPortApacheUses
ChangingtheUserApacheRunsAs
SpecifyingaServerName
ProvidinganIconformyWebPage
DiscoveringtheModulesAvailableontheServer
EnablingandDisablingIndividualModules
AddingModulesafterCompilingApacheWithoutRecompiling














































































PublishingContent
Chapter2.Troubleshooting
Help!MyApacheServerDoesNotWork!
TheErrorLog
LoggingtotheSystemLogDaemon
ControllingtheAmountofInformationLogged
TestingtheApacheConfigurationforProblems
TestingApachefromtheCommandLine
CheckingThatApacheIsRunning
AlternateWaysofStoppingApache
UsingApachetoDebugApache
StartupErrors
AccessDeniedErrors
InternalServerErrors
AdditionalErrorLogFiles
RedirectionsDoNotWork
TroubleshootingChecklist
Chapter3.LogsandMonitoring
IntroductiontoLogginginApache
DefaultApacheLogFiles
CreatingLogFormats
CreatingaCustomLogFile
RedirectingLogstoanExternalProgram
LoggingRequestsConditionally
MonitoringWhoIsLinkingtoYourWebsite
MonitoringApachewithmod_status
MonitoringApachewithSNMP
AnalyzingYourLogswithOpen-sourceTools
MonitoringYourLogsinRealTime
LoggingRequeststoaDatabase
RotatingandArchivingLogs
ControllingIPAddressResolution
ProcessingLoggedIPAddresses
RestartingApacheAutomaticallyIfItFails
MergingandSplittingLogFiles
KeepingSeparateLogsforEachVirtualHost
CommonLogEntries
Chapter4.URLMappingandDynamicContent
URLMapping
















































































MappingURLstoFileswithAlias
MappingURLPatternstoFileswithAliasMatch
RedirectingaPagetoAnotherLocation
RedirectingtotheLatestVersionofaFile
RedirectingFailedorUnauthorizedRequests
DefiningContentHandlers
UnderstandingMIMETypes
ConfiguringMIMETypes
BasicsofRunningCGIScripts
MarkingResourcesAsExecutableCGIs
AssociatingScriptswithHTTPMethodsandMIMETypes
TroubleshootingtheExecutionofCGIScripts
ImprovingCGIScriptPerformance
UnderstandingServerSideIncludes
ConfiguringServerSideIncludes
SettingEnvironmentVariables
SettingEnvironmentVariablesDynamically
SpecialEnvironmentVariables
UnderstandingContentNegotiation
ConfiguringContentNegotiation
AssigningDefaultCharsetsandLanguagePriorities
AdvancedURLMappingwithmod_rewrite
Understandingthe"TrailingSlash"Problem
FixingSpellingMistakes
FixingCapitalizationProblems
ValidatingYourPageswithTidy
Chapter5.VirtualHosting
WhatIsVirtualHosting?
WhatIsIP-basedVirtualHosting?
ConfiguringIP-basedVirtualHosting
WhatIsName-basedVirtualHosting?
ConfiguringName-basedVirtualHosting
WhatHappensIfaRequestDoesNotMatchAnyVirtualHost?
ConfiguringaDefaultName-basedVirtualHost
ConfiguringaDefaultIP-basedVirtualHost
MixingName-basedandIP-basedVirtualHosts
DebuggingVirtualHostSetups
UsingSSLwithName-basedVirtualHosts
AlternateVirtualHosting















































































AlternateVirtualHostingModules
Per-directoryConfigurationFiles
ControllingtheScopeofPer-directoryConfigurationFiles
DisablingPer-directoryConfigurationFiles
Chapter6.SecurityandAccessControl
UnderstandingtheNeedforAccessControl
DifferencesBetweenApacheVersions
UnderstandingBasicandDigestAuthentication
IntroducingApacheAccessControl
IntroducingApacheAuthorizationandAuthenticationConfiguration
CreatingaUserDatabase
UsingRequiretoAuthorizeUsersandGroups
HandlingaLargeNumberofUsers
AllowingAccessOnlytoSpecificIPAddresses
DenyingAccesstoSpecificIPAddresses
CombiningAccessControlMethods
CustomizingYourAccessDeniedPage
PuttingUsersinControl
DenyingAccesstoSystemandSensitiveFiles
RestrictingProgramExecution
PreventingAbuse
DisablingDirectoryListings
ChangingtheServer:Header
PreventingHotlinkingtoYourImages
RestrictingSpecificHTTPMethods
RestrictingAccessBasedontheBrowserType
UsingLocationandDirectorySections
AdditionalAuthenticationModules
Apache2.2
KeepingUptoDatewithApacheSecurity
SecurityChecklist
Chapter7.SSL/TLS
WhatIsSSL?
HowDoesSSLWork?
CompilingOpenSSL
EncryptionKeys
CreatingaKeyPair
CreatingaPassword-protectedKeyPair
RemovethePasswordfromaKey
















































































Certificates
CreatingaCertificateSigningRequest
ShowingtheContentsofaCertificateSigningRequest
CreatingaSelf-signedCertificate
CompilingSSLSupportinApache1.3
CompilingSSLSupportinApache2.x
MinimalApacheConfiguration
StartingApachewithSSLSupport
SSLPassPhraseDialog
ImprovingSSLPerformance
ForcingAllContenttoBeServedUsingSSL
SSLandName-basedSSLVirtualHosts
UsingApacheAuthModuleswithSSL
WarningMessagesWhenAccessinganSSL-enabledWebsite
CreatingClientCertificates
AuthenticationUsingClientCertificates
Alternativestomod_ssl
TestingSSL-enabledWebsitesfromtheCommandLine
WorkingAroundBuggySSLImplementations
ComplexAccessControlwithmod_ssl
RelatedChapters
Chapter8.ContentPublishingwithDAV
ContentPublishingandApache
IntroducingWebDAV
AdvantagesofUsingmod_dav
WebDAVandtheHTTPProtocol
Installingmod_davonApache2.0
Installingmod_davonApache1.3
BasicWebDAVConfiguration
SecuringYourWebDAVConfiguration
AccessingDAVResourcesfromMicrosoftOffice
AccessingDAVfromMicrosoftWindows
AccessingDAVResourcesfromFirefox
AccessingDAVfromtheCommandLine
DealingwithBuggyClients
mod_spelingandDAV
DynamicContentandDAV
EnablingPer-userPages
AlternateUserDirectories














































































FixingProblemswithDAVLockDB
Chapter9.PerformanceandScalability
TuningApache
UnderstandingPerformanceandScalability
TuningYourHardware
IncreasingOSLimits
IncreasingOSLimitsonProcesses
IncreasingOSFileDescriptors
ControllingExternalProcesses
ImprovingFileSystemPerformance
HandlingSymbolicLinks
TuningNetworkandStatusSettings
PreventingAbuse
LimitingConnectionsandBandwidth
DealingwithRobots
ReverseProxiesandLoadBalancers
CachingandCompression
Module-specificOptimizations
AlternativestoApache
Chapter10.ApacheProxyandCachingSupport
UnderstandingtheNeedforCachingandProxies
UnderstandingForwardandReverseProxies
DifferencesBetweenApache1.3,2.0,and2.2
Enablingmod_proxySupport
EnablingForwardProxySupport
UsingaReverseProxytoUnifyYourURLSpace
HidingtheBackendServers
PreventingURLsfromBeingReverseProxied
ImprovingPerformance
OffloadingSSLProcessing
PassingProxyInformationinHeaders
ManipulatingHeaders
ImplementingaCachingProxy
CachinginApache2
LoadBalancing
ConnectingtoTomcat
AlternateProxies
TransparentHTTPProxies
Chapter11.MultiProcessingandProtocolModules


























TheEvolutionofApache'sArchitecture
SelectingaMultiProcessingModule
UnderstandingProcess-BasedMPMs
ConfiguringthePreforkMPM
UnderstandingThreadedandHybridMPMs
ConfiguringtheWorkerMPM
UsingAlternateMPMs
UnderstandingApache2Filters
UsingApacheAsanFTPServer
UsingApacheAsaPOP3Server
CompressingContentontheFly
Index


Copyright
ApachePhrasebook
Copyright©2006bySamsPublishing
Allrightsreserved.Nopartofthisbookshallbereproduced,
storedinaretrievalsystem,ortransmittedbyanymeans,
electronic,mechanical,photocopying,recording,orotherwise,
withoutwrittenpermissionfromthepublisher.Nopatent
liabilityisassumedwithrespecttotheuseoftheinformation
containedherein.Althougheveryprecautionhasbeentakenin
thepreparationofthisbook,thepublisherandauthorassume
noresponsibilityforerrorsoromissions.Norisanyliability
assumedfordamagesresultingfromtheuseoftheinformation
containedherein.
LibraryofCongressCatalogCardNumber:2005903948
PrintedintheUnitedStatesofAmerica
FirstPrinting:May2006
090807064321

Trademarks
Alltermsmentionedinthisbookthatareknowntobe
trademarksorservicemarkshavebeenappropriately
capitalized.SamsPublishingcannotattesttotheaccuracyof
thisinformation.Useofaterminthisbookshouldnotbe
regardedasaffectingthevalidityofanytrademarkorservice
mark.

WarningandDisclaimer


Everyefforthasbeenmadetomakethisbookascompleteand
asaccurateaspossible,butnowarrantyorfitnessisimplied.
Theinformationprovidedisonan"asis"basis.Theauthor(s)
andthepublishershallhaveneitherliabilitynorresponsibilityto
anypersonorentitywithrespecttoanylossordamagesarising
fromtheinformationcontainedinthisbook.

BulkSales
SamsPublishingoffersexcellentdiscountsonthisbookwhen
orderedinquantityforbulkpurchasesorspecialsales.For
moreinformation,pleasecontact
U.S.CorporateandGovernmentSales
1-800-382-3419
corpsales@pearsontechgroup.com
ForsalesoutsideoftheU.S.,pleasecontact
InternationalSales
international@pearsoned.com
TheSafari®Enabledicononthecoverofyourfavorite
technologybookmeansthebookisavailablethroughSafari
Bookshelf.Whenyoubuythisbook,yougetfreeaccesstothe
onlineeditionfor45days.SafariBookshelfisanelectronic
referencelibrarythatletsyoueasilysearchthousandsof
technicalbooks,findcodesamples,downloadchapters,and
accesstechnicalinformationwheneverandwhereveryouneed
it.
Togain45-daySafariEnabledaccesstothisbook:
Gotohttp://www.samspublishing.com/safarienabled


Completethebriefregistrationform
EnterthecouponcodeY8FA-HGQG-8HTT-IRGS-G5MT
IfyouhavedifficultyregisteringonSafariBookshelfor
accessingtheonlineedition,pleasee-mailcustomerservice@safaribooksonline.com.
AcquisitionsEditor
ShelleyJohnston
DevelopmentEditor
DamonJordan
ManagingEditor
PatrickKanouse
ProjectEditor
MandieFrank
ProductionEditor
BenBerg
Indexers
AaronBlack
CherylLenser
Proofreaders


CharlotteClapp
LeslieJoseph
TechnicalEditor
AronHsiao
PublishingCoordinator
VanessaEvans
MultimediaDeveloper
DanScherf
BookDesigner
GaryAdair

Dedication
ToEricaandMarisol,foryourloveandsupport.


AbouttheAuthors
DanielLopezisthefounderandCTOofBitRock,atechnology
companyprovidingmultiplatforminstallationandmanagement
toolsforavarietyofcommercialandopensourcesoftware
products.
Previously,hewaspartoftheoriginalengineeringteamat
CovalentTechnologies,Inc.,whichprovidesApachesoftware
supportandservicesfortheenterprise.Heistheauthorof
severalpopularApacheandLinuxguides,themod_monomodule
forintegratingApacheand.NET,andComancheaGUI
configurationtoolforApache.Danielisaregularspeakerat
opensourceconferencessuchasLinuxWorld,ApacheCon,and
theO'ReillyOpenSourceConvention.Heholdsamaster'sof
sciencedegreeintelecommunicationsfromtheEscuela
SuperiordeIngenierosdeSevillaandDanmarksTekniske
Universitet.DanielisamemberoftheApacheSoftware
Foundation.
JesusBlancoisprojectmanagerforBitRock,atechnology
companythatprovidesmultiplatforminstallationand
managementtoolsforavarietyofcommercialandopensource
softwareproducts.BeforejoiningBitRock,Jesus'spositionwith
theSpanishInstituteofForeignCommerceledhimtoprojects
inBrazil,France,Germany,Portugal,andmuchofSoutheast
Asia.JesusisalsoacontributortotheApacheDocumentation
projectandhastranslatedmuchoftheApachedocumentation
intoSpanish.Heholdsabusinessadministrationdegreefrom
UniversityofSevilleandamaster'sincomputersciencefrom
UNED.




Acknowledgments
Firstofall,Iwanttothankmyeditor,ShelleyJohnston.Sheis
livingproofthathumanpatienceknowsnolimits,andthrough
herenthusiasmanddriveshekeptthebookoncourse,despite
ourbusyworkscheduleanddelays.Iwanttothankmycoauthor,Jesus,andbusinesspartner,Erica,forthetimeand
efforttheyspentmakingthisbookhappen.Writingabookwhile
workingfulltimeonasoftwarestartupcanbequitestressfulat
times,soaspecialthanksgoestomygirlfriendandfamily,for
theirsupport.
Finally,Iwanttosay"Hola"andthankyoutomyawesome
teamthatmakesBitRocksuchagreatplacetowork.




WeWanttoHearfromYou!
Asthereaderofthisbook,youareourmostimportantcritic
andcommentator.Wevalueyouropinionandwanttoknow
whatwe'redoingright,whatwecoulddobetter,whatareas
you'dliketoseeuspublishin,andanyotherwordsofwisdom
you'rewillingtopassourway.
Youcanemailorwritemedirectlytoletmeknowwhatyoudid
ordidn'tlikeaboutthisbookaswellaswhatwecandotomake
ourbooksstronger.
PleasenotethatIcannothelpyouwithtechnicalproblems
relatedtothetopicofthisbook,andthatduetothehigh
volumeofmailIreceive,Imightnotbeabletoreplytoevery
message.
Whenyouwrite,pleasebesuretoincludethisbook'stitleand
authoraswellasyournameandphoneoremailaddress.Iwill
carefullyreviewyourcommentsandsharethemwiththeauthor
andeditorswhoworkedonthebook.

E-mail: webdev@samspublishing.com
Mail:






MarkTaber
AssociatePublisher
SamsPublishing
800East96thStreet
Indianapolis,IN46240USA





ReaderServices
Visitourwebsiteandregisterthisbookat
www.samspublishing.com/registerforconvenientaccessto
anyupdates,downloads,orerratathatmightbeavailablefor
thisbook.




Introduction
ApachehasalwaysbeenatthecoreoftheWeb,fromits
modestbeginningsasaforkoftheNCSAservertothelatest
versionthat'spackedwithfeatures.Overtimeithasgrownin
bothcapabilityandcomplexitytothepointthatitcanbe
overwhelminglyintimidatingtonewcomers.Thegoalofthis
bookistohelpyounavigateApache'shundredsofoptions,as
wellasserveasagentleintroductionandhandycheat-sheetfor
commontasks.Justasalanguagephrasebookcanbea
pricelesscompanionwhenvisitingaforeigncountryhelpingyou
orderfoodoraskfordirectionsIhopethisApachePhrasebook
willbeusefultoyouwhenconfiguringyourwebservers.
ApachePhrasebookprovidesguidanceandsnippetssoyoucan
customizeApachetosuityourindividualneeds.Thereismore
toApache,ofcourse,thancanbecoveredinabookthissize.
Whenyouregisterthisbookat
www.samspublishing.com/register,youwillfindmorecontentto
complementitandhighlightthemostcommonlyusedandnotso-common(butstilluseful)featuresoftheserver.


1.ApacheBasics



DiscoveringApache
ThischapterprovidesaquickintroductiontotheApacheweb
server,itsarchitecture,andthedifferencesbetweenmajor
versions(1.3,2.x).Itexplainshowtodownloadandcompile
Apachefromsourceorusingbinarypackages,howtoenableor
disablecommonmodules,thelayoutofserverfiles,andthe
structureandsyntaxoftheserverconfigurationfiles.Italso
covershowtostart/stop/restartApacheandtheminimum
configurationchangesrequiredtogetApacheupandrunning.
ApacheisthemostpopularwebserverontheInternet,with
around68%ofthemarketshare,accordingtoNetcraft
(http://www.netcraft.com).
Apacheis
PortableItrunsonLinux,Windows,MacOSX,andmany
otheroperatingsystems.
FlexibleIthasamodular,extensiblearchitectureandcan
beconfiguredinavarietyofways.
OpenSourceYoucandownloadanduseApacheforfree.
Availabilityofthesourcecodemeansyoucancreatecustom
buildsofApache.
TherearetwomainversionsofApacheinwidespreaduse
today:the1.3seriesandthe2.xseries.
Apache2.0includesanumberofimprovementsandfeatures
overApache1.3;however,itisincompatiblewithallmodules
writtenforApache1.3.Asabasicruleofthumb,useApache
2.xifyou


ArerunningaWindowsoperatingsystem.
Needtoservealotofstaticcontentthatcanbenefitfroma
threadedprocessingmoduleonUnix.
NeedoneofthenewfeaturesonlyavailableinApache2.0.
ArecompletelynewtoApache.
RunApache1.3ifyou
Needtorunin-houseorthird-partymodulesthathavenot
yetbeenportedtoApache2.x.
NeedtorunsoftwaresuchasPHPwithnonthread-safe
extensions(thoughthesamecodewillprobablyrunequally
wellonApache2.0withthepreforkMPM).
ArealreadyfamiliarwithApache1.3andhavenospecific
needtoupgrade.


DeterminingWhetherApacheIsAlready
Installed
rpmqhttpd
rpmqapache
rpmqapache2

IfyouarerunningaLinuxsystem,chancesarethatApacheis
alreadyinstalled.Ifyourdistributionusestherpmpackage
managementsystem,youcanchecktoseewhetherApacheis
installedwiththeprecedingcommands.Thereareseveral
differentcommandsbecausenotalldistributionsusethesame
nameforpackages.
InmostUnix-likesystems,includingMacOSX,youcanalso
directlycheckwhethertheApachebinaryisinstalledwithoneof
httpd-v
/usr/sbin/httpdv

Iffound,itshouldreturnsomethingsimilarto
Serverversion:Apache/2.0.54
Serverbuilt:Apr16200514:25:31

Youcangetanevenmoredetailedresponseusinghttpd-V.
OnWindowssystems,youcancheckwhetherApacheis
installedintheAdd/RemoveProgramssectionoftheControl


Panel.TheinstallationpathisunderC:\ProgramFiles\ApacheGroup.


WhereCanIGetApache?
ApacheisincludedbydefaultinmostLinuxdistributionsandinMacOSX.Youcanalso
downloadbinariesandsourcecodeforavarietyofplatforms,includingWindows,fromthe
officialApachewebsiteathttp://www.apache.org.




InstallingApache1.3onLinuxandUnix
tarxvfzapache_1.3.33.tar.gz
cdapache_1.3.33
./configure--prefix=/usr/local/apache--enableshared=max
make
makeinstall

Youcanusethepackagemanagementtoolsofyouroperating
systemtoinstallpre-builtversionsoftheserver.Thisisoften
preferredbecausetheyintegratewellwiththeexistingfile
systemlayoutandwithothervendor-providedpackages.Itis,
however,importanttoknowhowtobuildyourownversionof
Apachefromsourcecode.Thiswillallowyou,forexample,to
buildaservercustomizedtoyourneedsaswellastoquickly
applysecuritypatchesastheyarereleased.
Thefirststepistovisitthehttp://httpd.apache.orgwebsiteand
downloadtheappropriatesourcetarball.Whenreferringto1.3specificfunctionality,therestofthebookassumesyouinstalled
Apache1.3.33.Thatisthemostrecentversioninthe1.3series
atthetimeofthiswriting.Thesourcetarballwillbenamed
apache_1.3.33.tar.gz.
Youcannowuncompress,configure,compile,andinstall
Apachewiththecommandsintheprecedinglisting.
Theoption--prefixindicatesthepathunderwhichtheserver
willbeinstalledand--enable-shared=maxactivatesloadablemodule
support.Loadablemodulesupportisnecessarytoextendor
customizethefunctionalitylateronwithouthavingtorecompile
theserver.


Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay

×