Sie sind auf Seite 1von 8

13/12/2015

UsingApacheHTTPServeronMicrosoftWindowsApacheHTTPServerVersion2.4

ApacheHTTPServerVersion2.4
UsingApacheHTTPServeronMicrosoftWindows
Thisdocumentexplainshowtoinstall,configureandrunApache2.4underMicrosoftWindows.Ifyouhave
questionsafterreviewingthedocumentation(andanyeventanderrorlogs),youshouldconsultthepeer
supportedusers'mailinglist(http://httpd.apache.org/userslist.html).
ThisdocumentassumesthatyouareinstallingabinarydistributionofApache.IfyouwanttocompileApache
yourself(possiblytohelpwithdevelopmentortrackingdownbugs),seeCompilingApacheforMicrosoft
Windows(win_compiling.html).
OperatingSystemRequirements
DownloadingApacheforWindows
CustomizingApacheforWindows
RunningApacheasaService
RunningApacheasaConsoleApplication
TestingtheInstallation
ConfiguringAccesstoNetworkResources
WindowsTuning
Comments

OperatingSystemRequirements
TheprimaryWindowsplatformforrunningApache2.4isWindows2000orlater.Alwaysobtainandinstallthe
currentservicepacktoavoidoperatingsystembugs.
ApacheHTTPServerversionslaterthan2.2willnotrunonanyoperatingsystemearlierthanWindows
2000.

DownloadingApacheforWindows
TheApacheHTTPServerProjectitselfdoesnotprovidebinaryreleasesofsoftware,onlysourcecode.
Individualcommittersmayprovidebinarypackagesasaconvenience,butitisnotareleasedeliverable.
IfyoucannotcompiletheApacheHTTPServeryourself,youcanobtainabinarypackagefromnumerousbinary
distributionsavailableontheInternet.
PopularoptionsfordeployingApachehttpd,and,optionally,PHPandMySQL,onMicrosoftWindows,include:
ApacheHaus
ApacheLounge
BitNamiWAMPStack
WampServer
XAMPP

CustomizingApacheforWindows
Apacheisconfiguredbythefilesintheconfsubdirectory.ThesearethesamefilesusedtoconfiguretheUnix
version,butthereareafewdifferentdirectivesforApacheonWindows.Seethedirectiveindex
(../mod/directives.html)foralltheavailabledirectives.
ThemaindifferencesinApacheforWindowsare:
BecauseApacheforWindowsismultithreaded,itdoesnotuseaseparateprocessforeachrequest,as
http://httpd.apache.org/docs/current/platform/windows.html#down

1/8

13/12/2015

UsingApacheHTTPServeronMicrosoftWindowsApacheHTTPServerVersion2.4

ApachecanonUnix.InsteadthereareusuallyonlytwoApacheprocessesrunning:aparentprocess,and
achildwhichhandlestherequests.Withinthechildprocesseachrequestishandledbyaseparatethread.
Theprocessmanagementdirectivesarealsodifferent:
MaxConnectionsPerChild:LiketheUnixdirective,thiscontrolshowmanyconnectionsasingle
childprocesswillservebeforeexiting.However,unlikeonUnix,areplacementprocessisnotinstantly
available.UsethedefaultMaxConnectionsPerChild0,unlessinstructedtochangethebehaviorto
overcomeamemoryleakinthirdpartymodulesorinprocessapplications.
Warning:Theserverconfigurationfileisrereadwhenanewchildprocessisstarted.Ifyou
havemodifiedhttpd.conf,thenewchildmaynotstartoryoumayreceiveunexpected
results.
ThreadsPerChild:Thisdirectiveisnew.Ittellstheserverhowmanythreadsitshoulduse.Thisis
themaximumnumberofconnectionstheservercanhandleatonce,sobesuretosetthisnumberhigh
enoughforyoursiteifyougetalotofhits.TherecommendeddefaultisThreadsPerChild150,but
thismustbeadjustedtoreflectthegreatestanticipatednumberofsimultaneousconnectionstoaccept.
ThedirectivesthatacceptfilenamesasargumentsmustuseWindowsfilenamesinsteadofUnixones.
However,becauseApachemayinterpretbackslashesasan"escapecharacter"sequence,youshould
consistentlyuseforwardslashesinpathnames,notbackslashes.
WhilefilenamesaregenerallycaseinsensitiveonWindows,URLsarestilltreatedinternallyascase
sensitivebeforetheyaremappedtothefilesystem.Forexample,the<Location>,Alias,and
ProxyPassdirectivesallusecasesensitivearguments.Forthisreason,itisparticularlyimportantto
usethe<Directory>directivewhenattemptingtolimitaccesstocontentinthefilesystem,sincethis
directiveappliestoanycontentinadirectory,regardlessofhowitisaccessed.Ifyouwishtoassurethat
onlylowercaseisusedinURLs,youcanusesomethinglike:
RewriteEngineOn
RewriteMaplowercaseint:tolower
RewriteCond"%{REQUEST_URI}""[AZ]"
RewriteRule"(.*)""${lowercase:$1}"[R,L]
Whenrunning,Apacheneedswriteaccessonlytothelogsdirectoryandanyconfiguredcachedirectory
tree.Duetotheissueofcaseinsensitiveandshort8.3formatnames,Apachemustvalidateallpathnames
given.ThismeansthateachdirectorywhichApacheevaluates,fromthedriverootuptothedirectory
leaf,musthaveread,listandtraversedirectorypermissions.IfApache2.4isinstalledatC:\ProgramFiles,
thentherootdirectory,ProgramFilesandApache2.4mustallbevisibletoApache.
ApacheforWindowscontainstheabilitytoloadmodulesatruntime,withoutrecompilingtheserver.If
Apacheiscompilednormally,itwillinstallanumberofoptionalmodulesinthe
\Apache2.4\modulesdirectory.Toactivatetheseorothermodules,theLoadModuledirective
mustbeused.Forexample,toactivatethestatusmodule,usethefollowing(inadditiontothestatus
activatingdirectivesinaccess.conf):
LoadModulestatus_modulemodules/mod_status.so
Informationoncreatingloadablemodules(../mod/mod_so.html#creating)isalsoavailable.
ApachecanalsoloadISAPI(InternetServerApplicationProgrammingInterface)extensionssuchas
thoseusedbyMicrosoftIISandotherWindowsservers.Moreinformationisavailable
(../mod/mod_isapi.html).NotethatApachecannotloadISAPIFilters,andISAPIHandlerswithsome
Microsoftfeatureextensionswillnotwork.
WhenrunningCGIscripts,themethodApacheusestofindtheinterpreterforthescriptisconfigurable
usingtheScriptInterpreterSourcedirective.
http://httpd.apache.org/docs/current/platform/windows.html#down

2/8

13/12/2015

UsingApacheHTTPServeronMicrosoftWindowsApacheHTTPServerVersion2.4

Sinceitisoftendifficulttomanagefileswithnameslike.htaccessinWindows,youmayfindit
usefultochangethenameofthisperdirectoryconfigurationfileusingtheAccessFilenamedirective.
AnyerrorsduringApachestartupareloggedintotheWindowseventlogwhenrunningonWindowsNT.
ThismechanismactsasabackupforthosesituationswhereApacheisnotyetpreparedtousethe
error.logfile.YoucanreviewtheWindowsApplicationEventLogbyusingtheEventViewer,e.g.
StartSettingsControlPanelAdministrativeToolsEventViewer.

RunningApacheasaService
ApachecomeswithautilitycalledtheApacheServiceMonitor.Withityoucanseeandmanagethestateofall
installedApacheservicesonanymachineonyournetwork.TobeabletomanageanApacheservicewiththe
monitor,youhavetofirstinstalltheservice(eitherautomaticallyviatheinstallationormanually).
YoucaninstallApacheasaWindowsNTserviceasfollowsfromthecommandpromptattheApachebin
subdirectory:
httpd.exekinstall

Ifyouneedtospecifythenameoftheserviceyouwanttoinstall,usethefollowingcommand.Youhavetodo
thisifyouhaveseveraldifferentserviceinstallationsofApacheonyourcomputer.Ifyouspecifyanameduring
theinstall,youhavetoalsospecifyitduringanyotherkoperation.
httpd.exekinstalln"MyServiceName"

Ifyouneedtohavespecificallynamedconfigurationfilesfordifferentservices,youmustusethis:
httpd.exekinstalln"MyServiceName"f"c:\files\my.conf"

Ifyouusethefirstcommandwithoutanyspecialparametersexceptkinstall,theservicewillbecalled
Apache2.4andtheconfigurationwillbeassumedtobeconf\httpd.conf.
RemovinganApacheserviceiseasy.Justuse:
httpd.exekuninstall

ThespecificApacheservicetobeuninstalledcanbespecifiedbyusing:
httpd.exekuninstalln"MyServiceName"

Normalstarting,restartingandshuttingdownofanApacheserviceisusuallydoneviatheApacheService
Monitor,byusingcommandslikeNETSTARTApache2.4andNETSTOPApache2.4orvianormal
Windowsservicemanagement.BeforestartingApacheasaservicebyanymeans,youshouldtesttheservice's
configurationfilebyusing:
httpd.exen"MyServiceName"t

YoucancontrolanApacheservicebyitscommandlineswitches,too.TostartaninstalledApacheservice
you'llusethis:
httpd.exekstartn"MyServiceName"

TostopanApacheserviceviathecommandlineswitches,usethis:
http://httpd.apache.org/docs/current/platform/windows.html#down

3/8

13/12/2015

UsingApacheHTTPServeronMicrosoftWindowsApacheHTTPServerVersion2.4

httpd.exekstopn"MyServiceName"

or
httpd.exekshutdownn"MyServiceName"

Youcanalsorestartarunningserviceandforceittorereaditsconfigurationfilebyusing:
httpd.exekrestartn"MyServiceName"

Bydefault,allApacheservicesareregisteredtorunasthesystemuser(theLocalSystemaccount).The
LocalSystemaccounthasnoprivilegestoyournetworkviaanyWindowssecuredmechanism,includingthe
filesystem,namedpipes,DCOM,orsecureRPC.Ithas,however,wideprivilegeslocally.
NevergrantanynetworkprivilegestotheLocalSystemaccount!IfyouneedApachetobeable
toaccessnetworkresources,createaseparateaccountforApacheasnotedbelow.
ItisrecommendedthatuserscreateaseparateaccountforrunningApacheservice(s).Ifyouhavetoaccess
networkresourcesviaApache,thisisrequired.
1. Createanormaldomainuseraccount,andbesuretomemorizeitspassword.
2. GrantthenewlycreateduseraprivilegeofLogonasaserviceandActaspartofthe
operatingsystem.OnWindowsNT4.0theseprivilegesaregrantedviaUserManagerfor
Domains,butonWindows2000andXPyouprobablywanttouseGroupPolicyforpropagatingthese
settings.YoucanalsomanuallysettheseviatheLocalSecurityPolicyMMCsnapin.
3. ConfirmthatthecreatedaccountisamemberoftheUsersgroup.
4. Granttheaccountreadandexecute(RX)rightstoalldocumentandscriptfolders(htdocsandcgi
binforexample).
5. Granttheaccountchange(RWXD)rightstotheApachelogsdirectory.
6. Granttheaccountreadandexecute(RX)rightstothehttpd.exebinaryexecutable.
ItisusuallyagoodpracticetogranttheusertheApacheservicerunsasreadandexecute(RX)access
tothewholeApache2.4directory,exceptthelogssubdirectory,wheretheuserhastohaveatleast
change(RWXD)rights.
Ifyouallowtheaccounttologinasauserandasaservice,thenyoucanlogonwiththataccountandtestthat
theaccounthastheprivilegestoexecutethescripts,readthewebpages,andthatyoucanstartApacheina
consolewindow.Ifthisworks,andyouhavefollowedthestepsabove,Apacheshouldexecuteasaservicewith
noproblems.
Errorcode2186isagoodindicationthatyouneedtoreviewthe"LogOnAs"configurationforthe
service,sinceApachecannotaccessarequirednetworkresource.Also,paycloseattentiontothe
privilegesoftheuserApacheisconfiguredtorunas.
WhenstartingApacheasaserviceyoumayencounteranerrormessagefromtheWindowsServiceControl
Manager.Forexample,ifyoutrytostartApachebyusingtheServicesappletintheWindowsControlPanel,you
maygetthefollowingmessage:
CouldnotstarttheApache2.4serviceon\\COMPUTER
Error1067Theprocessterminatedunexpectedly.

YouwillgetthisgenericerrorifthereisanyproblemwithstartingtheApacheservice.Inordertoseewhatis
http://httpd.apache.org/docs/current/platform/windows.html#down

4/8

13/12/2015

UsingApacheHTTPServeronMicrosoftWindowsApacheHTTPServerVersion2.4

reallycausingtheproblemyoushouldfollowtheinstructionsforRunningApacheforWindowsfromthe
CommandPrompt.
Ifyouarehavingproblemswiththeservice,itissuggestedyoufollowtheinstructionsbelowtotrystarting
httpd.exefromaconsolewindow,andworkouttheerrorsbeforestrugglingtostartitasaserviceagain.

RunningApacheasaConsoleApplication
RunningApacheasaserviceisusuallytherecommendedwaytouseit,butitissometimeseasiertoworkfrom
thecommandline,especiallyduringinitialconfigurationandtesting.
TorunApachefromthecommandlineasaconsoleapplication,usethefollowingcommand:
httpd.exe

Apachewillexecute,andwillremainrunninguntilitisstoppedbypressingControlC.
YoucanalsorunApacheviatheshortcutStartApacheinConsoleplacedtoStartMenu>Programs
>ApacheHTTPServer2.4.xx>ControlApacheServerduringtheinstallation.This
willopenaconsolewindowandstartApacheinsideit.Ifyoudon'thaveApacheinstalledasaservice,the
windowwillremainvisibleuntilyoustopApachebypressingControlCintheconsolewindowwhereApacheis
runningin.Theserverwillexitinafewseconds.However,ifyoudohaveApacheinstalledasaservice,the
shortcutstartstheservice.IftheApacheserviceisrunningalready,theshortcutdoesn'tdoanything.
IfApacheisrunningasaservice,youcantellittostopbyopeninganotherconsolewindowandentering:
httpd.exekshutdown

RunningasaserviceshouldbepreferredoverrunninginaconsolewindowbecausethisletsApacheendany
currentoperationsandcleanupgracefully.
Butiftheserverisrunninginaconsolewindow,youcanonlystopitbypressingControlCinthesamewindow.
YoucanalsotellApachetorestart.Thisforcesittorereadtheconfigurationfile.Anyoperationsinprogressare
allowedtocompletewithoutinterruption.TorestartApache,eitherpressControlBreakintheconsolewindow
youusedforstartingApache,orenter
httpd.exekrestart

iftheserverisrunningasaservice.
NoteforpeoplefamiliarwiththeUnixversionofApache:thesecommandsprovideaWindows
equivalenttokillTERMpidandkillUSR1pid.Thecommandlineoptionused,k,was
chosenasareminderofthekillcommandusedonUnix.
IftheApacheconsolewindowclosesimmediatelyorunexpectedlyafterstartup,opentheCommandPrompt
fromtheStartMenu>Programs.ChangetothefoldertowhichyouinstalledApache,typethecommand
httpd.exe,andreadtheerrormessage.Thenchangetothelogsfolder,andreviewtheerror.logfilefor
configurationmistakes.AssuminghttpdwasinstalledintoC:\ProgramFiles\ApacheSoftware
Foundation\Apache2.4\,youcandothefollowing:
c:
cd"\ProgramFiles\ApacheSoftwareFoundation\Apache2.4\bin"
httpd.exe

ThenwaitforApachetostop,orpressControlC.Thenenterthefollowing:
http://httpd.apache.org/docs/current/platform/windows.html#down

5/8

13/12/2015

UsingApacheHTTPServeronMicrosoftWindowsApacheHTTPServerVersion2.4

cd..\logs
more<error.log

WhenworkingwithApacheitisimportanttoknowhowitwillfindtheconfigurationfile.Youcanspecifya
configurationfileonthecommandlineintwoways:
fspecifiesanabsoluteorrelativepathtoaparticularconfigurationfile:
httpd.exef"c:\myserverfiles\anotherconfig.conf"

or
httpd.exeffiles\anotherconfig.conf

nspecifiestheinstalledApacheservicewhoseconfigurationfileistobeused:
httpd.exen"MyServiceName"

Inbothofthesecases,theproperServerRootshouldbesetintheconfigurationfile.
Ifyoudon'tspecifyaconfigurationfilewithforn,Apachewillusethefilenamecompiledintotheserver,
suchasconf\httpd.conf.Thisbuiltinpathisrelativetotheinstallationdirectory.Youcanverifythe
compiledfilenamefromavaluelabelledasSERVER_CONFIG_FILEwheninvokingApachewiththeV
switch,likethis:
httpd.exeV

ApachewillthentrytodetermineitsServerRootbytryingthefollowing,inthisorder:
1. AServerRootdirectiveviatheCcommandlineswitch.
2. Thedswitchonthecommandline.
3. Currentworkingdirectory.
4. Aregistryentrywhichwascreatedifyoudidabinaryinstallation.
5. Theserverrootcompiledintotheserver.Thisis/apachebydefault,youcanverifyitbyusing
httpd.exeVandlookingforavaluelabelledasHTTPD_ROOT.
Ifyoudidnotdoabinaryinstall,Apachewillinsomescenarioscomplainaboutthemissingregistrykey.This
warningcanbeignorediftheserverwasotherwiseabletofinditsconfigurationfile.
ThevalueofthiskeyistheServerRootdirectorywhichcontainstheconfsubdirectory.WhenApachestarts
itreadsthehttpd.conffilefromthatdirectory.IfthisfilecontainsaServerRootdirectivewhichcontains
adifferentdirectoryfromtheoneobtainedfromtheregistrykeyabove,Apachewillforgettheregistrykeyand
usethedirectoryfromtheconfigurationfile.IfyoucopytheApachedirectoryorconfigurationfilestoanew
locationitisvitalthatyouupdatetheServerRootdirectiveinthehttpd.conffiletoreflectthenew
location.

TestingtheInstallation
AfterstartingApache(eitherinaconsolewindoworasaservice)itwillbelisteningonport80(unlessyou
changedtheListendirectiveintheconfigurationfilesorinstalledApacheonlyforthecurrentuser).To
connecttotheserverandaccessthedefaultpage,launchabrowserandenterthisURL:
http://localhost/
http://httpd.apache.org/docs/current/platform/windows.html#down

6/8

13/12/2015

UsingApacheHTTPServeronMicrosoftWindowsApacheHTTPServerVersion2.4

Apacheshouldrespondwithawelcomepageandyoushouldsee"ItWorks!".Ifnothinghappensoryougetan
error,lookintheerror.logfileinthelogssubdirectory.Ifyourhostisnotconnectedtothenet,orifyou
haveseriousproblemswithyourDNS(DomainNameService)configuration,youmayhavetousethisURL:
http://127.0.0.1/

IfyouhappentoberunningApacheonanalternateport,youneedtoexplicitlyputthatintheURL:
http://127.0.0.1:8080/

Onceyourbasicinstallationisworking,youshouldconfigureitproperlybyeditingthefilesintheconf
subdirectory.Again,ifyouchangetheconfigurationoftheWindowsNTserviceforApache,firstattemptto
startitfromthecommandlinetomakesurethattheservicestartswithnoerrors.
BecauseApachecannotsharethesameportwithanotherTCP/IPapplication,youmayneedtostop,uninstallor
reconfigurecertainotherservicesbeforerunningApache.TheseconflictingservicesincludeotherWWW
servers,somefirewallimplementations,andevensomeclientapplications(suchasSkype)whichwilluseport
80toattempttobypassfirewallissues.

ConfiguringAccesstoNetworkResources
AccesstofilesoverthenetworkcanbespecifiedusingtwomechanismsprovidedbyWindows:
Mappeddriveletters
e.g.,Alias"/images/""Z:/"
UNCpaths
e.g.,Alias"/images/""//imagehost/www/images/"
Mappeddrivelettersallowtheadministratortomaintainthemappingtoaspecificmachineandpathoutsideof
theApachehttpdconfiguration.However,thesemappingsareassociatedonlywithinteractivesessionsandare
notdirectlyavailabletoApachehttpdwhenitisstartedasaservice.UseonlyUNCpathsfornetwork
resourcesinhttpd.confsothattheresourcescanbeaccessedconsistentlyregardlessofhowApachehttpdis
started.(Arcaneanderrorproneproceduresmayworkaroundtherestrictiononmappeddriveletters,butthisis
notrecommended.)
ExampleDocumentRootwithUNCpath
DocumentRoot"//dochost/www/html/"

ExampleDocumentRootwithIPaddressinUNCpath
DocumentRoot"//192.168.1.50/docs/"

ExampleAliasandcorrespondingDirectorywithUNCpath
Alias"/images/""//imagehost/www/images/"
<Directory"//imagehost/www/images/">
#...
<Directory>

WhenrunningApachehttpdasaservice,youmustcreateaseparateaccountinordertoaccessnetwork
resources,asdescribedabove.

WindowsTuning
http://httpd.apache.org/docs/current/platform/windows.html#down

7/8

13/12/2015

UsingApacheHTTPServeronMicrosoftWindowsApacheHTTPServerVersion2.4

Ifmorethanafewdozenpipedloggersareusedonanoperatingsysteminstance,scalingupthe"desktop
heap"isoftennecessary.Formoredetailedinformation,refertothepipedlogging(../logs.html#piped)
documentation.

Comments
Notice:
ThisisnotaQ&Asection.Commentsplacedhereshouldbepointedtowardssuggestionsonimproving
thedocumentationorserver,andmayberemovedagainbyourmoderatorsiftheyareeitherimplemented
orconsideredinvalid/offtopic.QuestionsonhowtomanagetheApacheHTTPServershouldbedirected
ateitherourIRCchannel,#httpd,onFreenode,orsenttoourmailinglists.
RSSLogin/register
muzaffer16hoursagoRating:0(registeranaccountinordertoratecomments)
hellosir,Iamaphpprogramdeveloper,afewdaysagoIbougthanewcomputerand
win8.1loaded,soIdidnotrunxammp,butnowIfindthissitebutIdonotknowwht
mustIdofirs,couldyoukindlyhelpplease.

Copyright2015TheApacheSoftwareFoundation.
LicensedundertheApacheLicense,Version2.0.

http://httpd.apache.org/docs/current/platform/windows.html#down

8/8

Das könnte Ihnen auch gefallen