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 consequence and mistake logs ), you should consult the peer-supported users ‘ mailing list .
This document assumes that you are installing a binary star 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 platform for running Apache 2.4 is window 2000 or late. Always obtain and install the current serve pack to avoid operate system bugs.

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

Downloading Apache for Windows

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

  • ApacheHaus
  • Apache Lounge
  • Bitnami WAMP Stack
  • WampServer
  • XAMPP

Customizing Apache for Windows

Apache is configured by the files in the conf subdirectory. These are the same files used to configure the Unix interpretation, but there are a few unlike directives for Apache on Windows. See the directive 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 separate procedure for each request, as Apache can on Unix. alternatively there are normally alone two Apache processes running : a parent process, and a child which handles the requests. Within the child process each request is handled by a discriminate string .
    The process management directives are besides unlike :
    MaxConnectionsPerChild : Like the Unix directive, this controls how many connections a unmarried child action will serve before exiting. however, unlike on Unix, a replacement process is not instantaneously available. Use the default MaxConnectionsPerChild 0, unless instructed to change the behavior to overcome a memory leak in third base 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 directive is new. It tells the server how many threads it should use. This is the maximal total of connections the server can handle at once, so be certain to set this number gamey enough for your web site if you get a fortune of hits. The commend default is ThreadsPerChild 150, but this must be adjusted to reflect the greatest anticipate count 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 hush treated internally as case-sensitive before they are mapped to the filesystem. For case, the , Alias, and ProxyPass directives all use case-sensitive arguments. For this reason, it is peculiarly significant to use the directing when attempting to limit access to content in the filesystem, since this directing applies to any content in a directory, careless of how it is accessed. If you wish to assure that only lowercase 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 publish access alone to the log directory and any configure hoard directory tree. Due to the issue of case insensitive and abruptly 8.3 format names, Apache must validate all path names given. This means that each directory which Apache evaluates, from the drive etymon up to the directory flick, must have read, list and transom 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 server. If Apache is compiled normally, it will install a issue of optional modules in the \Apache2.4\modules directory. To activate these or other modules, the LoadModule directive must be used. For exemplar, to activate the status module, use the follow ( in addition to the status-activating directives in access.conf ) :
    LoadModule status_module "modules/mod_status.so"

    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 other Windows servers. More information is available. note that Apache cannot load ISAPI Filters, and ISAPI Handlers with some Microsoft sport extensions will not work .
  • When running CGI scripts, the method Apache uses to find the spokesperson for the script is configurable using the ScriptInterpreterSource directive .
  • Since it is often unmanageable to manage files with names like .htaccess in Windows, you may find it utilitarian to change the name of this per-directory shape file using the AccessFilename directive .
  • Any errors during Apache startup are logged into the Windows consequence log when running on Windows NT. This mechanism acts as a stand-in for those situations where Apache is not even prepared to use the error.log charge. You can review the Windows Application Event Log by using the Event Viewer, e.g. Start – Settings – Control Panel – administrative Tools – consequence Viewer .

Running Apache as a Service

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

httpd.exe -k install
If you need to specify the diagnose of the avail you want to install, use the following instruction. You have to do this if you have several different service installations of Apache on your computer. If you specify a appoint 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 shape files for different services, you must use this :

httpd.exe -k install -n "MyServiceName" -f "c:\files\my.conf"
If you use the first base command 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 service is easy. just 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 polish of an Apache serve is normally done via the Apache Service Monitor, by using commands like NET START Apache2.4 and NET STOP
Apache2.4
or via normal Windows avail management. Before starting Apache as a servicing 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, excessively. To start an install Apache service you ‘ll use this :

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

httpd.exe -k stop -n "MyServiceName"
or

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

httpd.exe -k restart -n "MyServiceName"
By default, all Apache services are registered to run as the system drug user ( the LocalSystem account ). The LocalSystem explanation has no privileges to your network via any Windows-secured mechanism, including the file system, named pipes, DCOM, or guarantee 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 break account for running Apache service ( south ). If you have to access network 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
    system
    . 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
    group.
  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 practice to grant the exploiter the Apache service runs as read and execute ( RX ) access to the whole Apache2.4 directory, except the logs subdirectory, where the exploiter has to have at least change ( RWXD ) rights.

If you allow the history to log in as a drug user and as a service, then you can log on with that score 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 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 serve, since Apache can not access a necessitate net resource. besides, pay close attention to the privileges of the drug user Apache is configured to run vitamin a .
When starting Apache as a servicing you may encounter an error message from the Windows Service Control Manager. For exemplar, 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 error if there is any trouble with starting the Apache service. In order to see what is truly 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 console window, and bring 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 commend way to use it, but it is sometimes easier to work from the command line, specially during initial configuration and examination .
To run Apache from the instruction line as a comfort application, use the play along command :

httpd.exe
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 overhaul, the shortcut starts the service. If the Apache serve 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 window and entrance :

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

httpd.exe -k restart
if the server is running as a service .
notice for people companion with the Unix version of Apache : these commands provide a Windows equivalent to kill -TERM
pid
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 folder to which you installed Apache, type the command httpd.exe, and read the erroneousness message. then change to the logs folder, 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 follow :

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

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

  • -f specifies an absolute or relative way to a especial configuration file :

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

    httpd.exe -f files\anotherconfig.conf
  • -n specifies the install Apache overhaul 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 configuration file with -f or -n, Apache will use the file name compiled into the server, such as conf\httpd.conf. This built-in path is relative to the initiation directory. You can verify the compiled file name 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 follow, in this ordering :

  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
    installation.
  5. The server root compiled into the server. This is
    /apache
    by default, you can verify it by using
    httpd.exe -V
    and looking for a value labelled as
    HTTPD_ROOT.

If you did not do a binary install, Apache will in some scenarios complain about the missing register winder. This warning can be ignored if the server was otherwise able to find its shape file .
The value of this key 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 different directory from the one obtained from the register samara 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 vital that you update the ServerRoot directive in the httpd.conf file to reflect the new location .

Testing the Installation

After starting Apache ( either in a console table window or as a service ) it will be listening on port 80 ( unless you changed the Listen directive in the configuration files or installed Apache merely for the current exploiter ). To connect to the waiter and entree the default page, launch a browser and record this url :

http://localhost/
Apache should respond with a welcome page and you should see `` It Works ! ''. If nothing happens or you get an error, look in the error.log file in the logs subdirectory. If your host is not connected to the net, or if you have unplayful problems with your DNS ( Domain Name Service ) shape, you may have to use this url :

http://127.0.0.1/
If you happen to be running Apache on an alternate port, you need to explicitly put that in the url :

http://127.0.0.1:8080/
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 try to start it from the command line to make sure that the servicing starts with no errors .
Because Apache cannot share the like port with another TCP/IP application, you may need to stop, uninstall or reconfigure certain early services before running Apache. These conflicting services include other WWW servers, some firewall implementations, and even some node 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 map to a specific machine and path outside of the Apache httpd configuration. however, these mappings are associated entirely with interactional sessions and are not directly available to Apache httpd when it is started as a service. Use only UNC paths for
network resources in httpd.conf
so that the resources can be accessed systematically careless of how Apache httpd is started. ( Arcane and erroneousness prone procedures may work around the restriction 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 "//192.168.1.50/docs/"

Example Alias and corresponding Directory with UNC path

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


#...

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

Windows Tuning

  • If more than a few twelve piped loggers are used on an operational system example, scaling up the `` desktop pile '' is often necessary. For more detail information, refer to the shoot log software documentation .
informant : https://thefartiste.com
Category : Tech

About admin

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

Check Also

articlewriting1

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.