Using Apache HTTP Server on Microsoft Windows – Apache HTTP Server Version 2.4

Using Apache HTTP Server on Microsoft Windows

available Languages : en | francium | knockout
This document explains how to install, configure and run Apache 2.4 under Microsoft Windows. If you have questions after reviewing the documentation ( and any event and error logs ), you should consult the peer-supported users ‘ mailing list .
This document assumes that you are installing a binary distribution of Apache. If you want to compile Apache yourself ( possibly to help with development or tracking down bugs ), see Compiling Apache for Microsoft Windows .

Operating System Requirements

The primary Windows chopine for running Apache 2.4 is window 2000 or late. Always obtain and install the current avail compact to avoid operate on system bugs.

Apache HTTP Server versions later than 2.2 will not run on any operating system earlier than Windows 2000 .

Downloading Apache for Windows

The Apache HTTP Server Project itself does not provide binary star releases of software, merely source code. person committers may provide binary star packages as a public toilet, but it is not a turn deliverable .
If you can not compile the Apache HTTP Server yourself, you can obtain a binary star software from numerous binary star distributions available on the Internet .
popular options for deploying Apache httpd, and, optionally, PHP and MySQL, on Microsoft Windows, include :

  • ApacheHaus
  • Apache Lounge
  • Bitnami WAMP Stack
  • WampServer

Customizing Apache for Windows

Apache is configured by the files in the conf subdirectory. These are the lapp files used to configure the Unix version, but there are a few unlike directives for Apache on Windows. See the directing index for all the available directives .
The main differences in Apache for Windows are :

  • Because Apache for Windows is multithreaded, it does not use a offprint action for each request, as Apache can on Unix. alternatively there are normally only two Apache processes running : a parent summons, and a child which handles the requests. Within the child process each request is handled by a separate thread .
    The action management directives are besides different :
    MaxConnectionsPerChild : Like the Unix directive, this controls how many connections a one child process will serve before exiting. however, unlike on Unix, a refilling summons is not instantaneously available. Use the default MaxConnectionsPerChild 0, unless instructed to change the behavior to overcome a memory leak in third party modules or in-process applications .
    Warning: The server configuration
    file is reread when a new child process is started. If you have
    modified httpd.conf, the new child may not start or
    you may receive unexpected results.

    ThreadsPerChild : This directing is raw. It tells the server how many threads it should use. This is the maximal number of connections the waiter can handle at once, sol be sure to set this number high enough for your site if you get a draw of hits. The recommend default is ThreadsPerChild 150, but this must be adjusted to reflect the greatest anticipate total of coincident connections to accept .
  • The directives that accept filename as arguments must use Windows filenames rather of Unix ones. however, because Apache may interpret backslashes as an “ escape character ” sequence, you should systematically use forward slashes in path names, not backslashes .
  • While filenames are generally case-insensitive on Windows, URLs are still treated internally as case-sensitive before they are mapped to the filesystem. For example, the , Alias, and ProxyPass directives all use case-sensitive arguments. For this rationality, it is particularly authoritative to use the directing when attempting to limit access to content in the filesystem, since this directing applies to any contentedness in a directory, careless of how it is accessed. If you wish to assure that merely small letter is used in URLs, you can use something like :
    RewriteEngine On
    RewriteMap lowercase int:tolower
    RewriteCond "%{REQUEST_URI}" "[A-Z]"
    RewriteRule "(.*)" "${lowercase:$1}" [R,L]
  • When running, Apache needs write access alone to the logarithm directory and any configured hoard directory tree. Due to the emergence of case insensitive and short 8.3 format names, Apache must validate all path names given. This means that each directory which Apache evaluates, from the drive root up to the directory leaf, must have read, list and traverse directory permissions. If Apache2.4 is installed at C : \Program Files, then the root directory, Program Files and Apache2.4 must all be visible to Apache .
  • Apache for Windows contains the ability to load modules at runtime, without recompiling the waiter. If Apache is compiled normally, it will install a total of optional modules in the \Apache2.4\modules directory. To activate these or other modules, the LoadModule directive must be used. For example, to activate the status module, use the follow ( in addition to the status-activating directives in access.conf ) :
    LoadModule status_module "modules/"

    information on creating loadable modules is besides available .

  • Apache can besides load ISAPI ( Internet Server Application Programming Interface ) extensions such as those used by Microsoft IIS and early Windows servers. More data is available. note that Apache cannot cargo ISAPI Filters, and ISAPI Handlers with some Microsoft feature extensions will not work .
  • When running CGI scripts, the method acting Apache uses to find the interpreter for the script is configurable using the ScriptInterpreterSource directive .
  • Since it is frequently difficult to manage files with names like .htaccess in Windows, you may find it useful to change the list of this per-directory configuration file using the AccessFilename directing .
  • Any errors during Apache startup are logged into the Windows event log when running on Windows NT. This mechanism acts as a stand-in for those situations where Apache is not however prepared to use the error.log file. You can review the Windows Application Event Log by using the Event Viewer, e.g. Start – Settings – Control Panel – administrative Tools – event Viewer .

Running Apache as a Service

Apache comes with a utility called the Apache Service Monitor. With it you can see and manage the state of all installed Apache services on any machine on your network. To be able to manage an Apache service with the monitor, you have to first install the service ( either automatically via the installation or manually ) .
You can install Apache as a Windows NT service as follows from the command motivate at the Apache bin subdirectory :

httpd.exe -k install
If you need to specify the name of the service you want to install, use the following command. You have to do this if you have several different servicing installations of Apache on your computer. If you specify a mention during the install, you have to besides specify it during any other -k operation .

httpd.exe -k install -n "MyServiceName"
If you need to have specifically named configuration files for different services, you must use this :

httpd.exe -k install -n "MyServiceName" -f "c:\files\my.conf"
If you use the foremost instruction without any special parameters except -k install, the service will be called Apache2.4 and the shape will be assumed to be conf\httpd.conf .
Removing an Apache overhaul is easy. fair use :

httpd.exe -k uninstall
The specific Apache service to be uninstalled can be specified by using :

httpd.exe -k uninstall -n "MyServiceName"
Normal starting, restarting and shutting down of an Apache serve is normally done via the Apache Service Monitor, by using commands like NET START Apache2.4 and NET STOP
or via normal Windows service management. Before starting Apache as a serve by any means, you should test the service ‘s configuration file by using :

httpd.exe -n "MyServiceName" -t
You can control an Apache service by its command line switches, besides. To start an install Apache servicing you ‘ll use this :

httpd.exe -k start -n "MyServiceName"
To stop an Apache serve via the instruction line switches, use this :

httpd.exe -k stop -n "MyServiceName"

httpd.exe -k shutdown -n "MyServiceName"
You can besides restart a run avail and effect it to reread its shape file by using :

httpd.exe -k restart -n "MyServiceName"
By default option, all Apache services are registered to run as the system user ( the LocalSystem account ). The LocalSystem account has no privileges to your network via any Windows-secured mechanism, including the charge system, named pipes, DCOM, or plug RPC. It has, however, wide-eyed privileges locally .
Never grant any network privileges to
the LocalSystem account! If you need Apache to be able
to access network resources, create a separate account for Apache as
noted below.

It is recommended that users create a freestanding account for running Apache service ( second ). If you have to access net resources via Apache, this is required .

  1. Create a normal domain user account, and be sure to
    memorize its password.
  2. Grant the newly-created user a privilege of Log on
    as a service
    and Act as part of the operating
    . On Windows NT 4.0 these privileges are granted via
    User Manager for Domains, but on Windows 2000 and XP you probably
    want to use Group Policy for propagating these settings. You can
    also manually set these via the Local Security Policy MMC snap-in.
  3. Confirm that the created account is a member of the Users
  4. Grant the account read and execute (RX) rights to all document
    and script folders (htdocs and cgi-bin
    for example).
  5. Grant the account change (RWXD) rights to the
    Apache logs directory.
  6. Grant the account read and execute (RX) rights to the
    httpd.exe binary executable.

It is normally a good rehearse to grant the exploiter the Apache service runs as read and carry through ( RX ) entree to the solid Apache2.4 directory, except the logs subdirectory, where the drug user has to have at least change ( RWXD ) rights.

If you allow the account to log in as a drug user and as a service, then you can log on with that account and test that the account has the privileges to execute the scripts, read the web pages, and that you can start Apache in a console table window. If this works, and you have followed the steps above, Apache should execute as a service with no problems .
Error code 2186 is a good indication that you need to review the “ Log On As ” configuration for the service, since Apache can not access a compulsory network resource. besides, pay close attention to the privileges of the user Apache is configured to run equally .
When starting Apache as a overhaul you may encounter an mistake message from the Windows Service Control Manager. For model, if you try to start Apache by using the Services applet in the Windows Control Panel, you may get the following message :

Could not start the Apache2.4 service on \\COMPUTER
Error 1067; The process terminated unexpectedly.
You will get this generic mistake if there is any trouble with starting the Apache servicing. In order to see what is very causing the problem you should follow the instructions for Running Apache for Windows from the Command Prompt .
If you are having problems with the service, it is suggested you follow the instructions below to try starting httpd.exe from a cabinet window, and function out the errors before struggling to start it as a service again .

Running Apache as a Console Application

Running Apache as a service is normally the recommend way to use it, but it is sometimes easier to work from the control line, specially during initial configuration and testing .
To run Apache from the command line as a comfort application, use the comply command :

Apache will execute, and will remain running until it is stopped by pressing Control-C .
You can besides run Apache via the shortcut Start Apache in Console placed to Start Menu --> Programs --> Apache HTTP Server
2.4.xx --> Control Apache Server
during the initiation. This will open a console window and start Apache inside it. If you do n’t have Apache installed as a service, the window will remain visible until you stop Apache by pressing Control-C in the cabinet window where Apache is running in. The server will exit in a few seconds. however, if you do have Apache installed as a serve, the shortcut starts the serve. If the Apache service is running already, the shortcut does n’t do anything .
If Apache is running as a service, you can tell it to stop by opening another console table window and accede :

httpd.exe -k shutdown
Running as a service should be preferred over running in a cabinet window because this lets Apache end any current operations and clean up graciously .
But if the server is running in a console windowpane, you can only stop it by pressing Control-C in the lapp window .
You can besides tell Apache to restart. This forces it to reread the shape file. Any operations in progress are allowed to complete without pause. To restart Apache, either press Control-Break in the console window you used for starting Apache, or record

httpd.exe -k restart
if the server is running as a service .
note for people familiar with the Unix adaptation of Apache : these commands provide a Windows equivalent to kill -TERM
and kill -USR1 pid. The command line option used, -k, was chosen as a reminder of the kill command used on Unix .
If the Apache console window closes immediately or by chance after startup, open the Command Prompt from the Start Menu — > Programs. Change to the booklet to which you installed Apache, type the command httpd.exe, and read the error message. then change to the logs booklet, and review the error.log file for configuration mistakes. Assuming httpd was installed into C:\Program Files\Apache Software Foundation\Apache2.4\, you can do the adopt :

cd "\Program Files\Apache Software Foundation\Apache2.4\bin"
then delay for Apache to stop, or press Control-C. then enter the following :

cd ..\logs
more < error.log
When working with Apache it is important to know how it will find the shape file. You can specify a shape file on the control trace in two ways :

  • -f specifies an absolute or proportional path to a particular shape file :

    httpd.exe -f "c:\my server files\anotherconfig.conf"

    httpd.exe -f files\anotherconfig.conf
  • -n specifies the install Apache service whose configuration file is to be used :

    httpd.exe -n "MyServiceName"

In both of these cases, the proper ServerRoot should be set in the shape file .
If you do n't specify a shape file with -f or -n, Apache will use the file name compiled into the waiter, such as conf\httpd.conf. This built-in path is proportional to the initiation directory. You can verify the compiled file appoint from a value labelled as SERVER_CONFIG_FILE when invoking Apache with the -V switch, like this :

httpd.exe -V
Apache will then try to determine its ServerRoot by trying the stick to, in this order :

  1. A ServerRoot directive
    via the -C command line switch.
  2. The -d switch on the command line.
  3. Current working directory.
  4. A registry entry which was created if you did a binary
  5. The server root compiled into the server. This is
    by default, you can verify it by using
    httpd.exe -V
    and looking for a value labelled as

If you did not do a binary install, Apache will in some scenarios complain about the missing register samara. This admonition can be ignored if the server was differently able to find its configuration file .
The value of this keystone is the ServerRoot directory which contains the conf subdirectory. When Apache starts it reads the httpd.conf file from that directory. If this file contains a ServerRoot directive which contains a unlike directory from the one obtained from the register key above, Apache will forget the register key and use the directory from the shape file. If you copy the Apache directory or shape files to a new location it is critical that you update the ServerRoot directing in the httpd.conf file to reflect the new localization .

Testing the Installation

After starting Apache ( either in a comfort window or as a serve ) it will be listening on port 80 ( unless you changed the Listen directive in the shape files or installed Apache entirely for the current user ). To connect to the waiter and access the default page, launch a browser and accede this url :

Apache should respond with a welcome page and you should see `` It Works ! ''. If nothing happens or you get an error, search in the error.log file in the logs subdirectory. If your horde is not connected to the internet, or if you have good problems with your DNS ( Domain Name Service ) configuration, you may have to use this url :
If you happen to be running Apache on an alternate port, you need to explicitly put that in the url :
once your basic facility is working, you should configure it properly by editing the files in the conf subdirectory. Again, if you change the configuration of the Windows NT service for Apache, first undertake to start it from the command cable to make certain that the service starts with no errors .
Because Apache cannot share the like port with another TCP/IP application, you may need to stop, uninstall or reconfigure sealed early services before running Apache. These conflicting services include other WWW servers, some firewall implementations, and even some customer applications ( such as Skype ) which will use port 80 to attempt to bypass firewall issues .

Configuring Access to Network Resources

access to files over the network can be specified using two mechanisms provided by Windows :

Mapped drive letters
e.g., Alias "/images/" "Z:/"
UNC paths
e.g., Alias "/images/" "//imagehost/www/images/"

Mapped drive letters allow the administrator to maintain the function to a specific machine and path outside of the Apache httpd shape. however, these mappings are associated only with interactional sessions and are not directly available to Apache httpd when it is started as a servicing. Use only UNC paths for
network resources in httpd.conf
thus that the resources can be accessed systematically careless of how Apache httpd is started. ( Arcane and error prone procedures may work around the limitation on map drive letters, but this is not recommended. )

Example DocumentRoot with UNC path

DocumentRoot "//dochost/www/html/"

Example DocumentRoot with IP address in UNC path

DocumentRoot "//"

Example Alias and corresponding Directory with UNC path

Alias "/images/" "//imagehost/www/images/"


When running Apache httpd as a service, you must create a separate account in ordering to access network resources, as described above .

Windows Tuning

  • If more than a few twelve piped loggers are used on an operate system exemplify, scaling up the `` desktop stack '' is often necessity. For more detailed data, refer to the pipe log documentation .
beginning :
Category : Tech

About admin

I am the owner of the website, my purpose is to bring all the most useful information to users.

Check Also


Manage participants in a zoom meeting webinar

Call the people who attend the meet as follows Alternate host host Who scheduled the …

Leave a Reply

Your email address will not be published.