|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
|
|
Packit |
90a5c9 |
<meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type" />
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
|
Packit |
90a5c9 |
This file is generated from xml source: DO NOT EDIT
|
|
Packit |
90a5c9 |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
|
Packit |
90a5c9 |
-->
|
|
Packit |
90a5c9 |
<title>Using Apache HTTP Server on Microsoft Windows - Apache HTTP Server Version 2.4</title>
|
|
Packit |
90a5c9 |
<link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
|
|
Packit |
90a5c9 |
<link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
|
|
Packit |
90a5c9 |
<link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" />
|
|
Packit |
90a5c9 |
<script src="../style/scripts/prettify.min.js" type="text/javascript">
|
|
Packit |
90a5c9 |
</script>
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
<link href="../images/favicon.ico" rel="shortcut icon" /></head>
|
|
Packit |
90a5c9 |
<body id="manual-page">
|
|
Packit |
90a5c9 |
Modules | Directives | FAQ | Glossary | Sitemap
|
|
Packit |
90a5c9 |
Apache HTTP Server Version 2.4
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Apache > HTTP Server > Documentation > Version 2.4 > Platform Specific NotesUsing Apache HTTP Server on Microsoft Windows
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Available Languages: en |
|
|
Packit |
90a5c9 |
fr |
|
|
Packit |
90a5c9 |
ko
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
This document explains how to install, configure and run
|
|
Packit |
90a5c9 |
Apache 2.4 under Microsoft Windows. If you have questions after
|
|
Packit |
90a5c9 |
reviewing the documentation (and any event and error logs), you
|
|
Packit |
90a5c9 |
should consult the peer-supported
|
|
Packit |
90a5c9 |
users' mailing
|
|
Packit |
90a5c9 |
list.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
This document assumes that you are installing a binary
|
|
Packit |
90a5c9 |
distribution of Apache. If you want to compile Apache yourself
|
|
Packit |
90a5c9 |
(possibly to help with development or tracking down bugs),
|
|
Packit |
90a5c9 |
see Compiling Apache for Microsoft
|
|
Packit |
90a5c9 |
Windows.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Downloading Apache for Windows
|
|
Packit |
90a5c9 |
Customizing Apache for Windows
|
|
Packit |
90a5c9 |
Running Apache as a Service
|
|
Packit |
90a5c9 |
Running Apache as a Console Application
|
|
Packit |
90a5c9 |
Testing the Installation
|
|
Packit |
90a5c9 |
Configuring Access to Network Resources
|
|
Packit |
90a5c9 |
Windows Tuning
|
|
Packit |
90a5c9 |
See also
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
The primary Windows platform for running Apache 2.4 is Windows
|
|
Packit |
90a5c9 |
2000 or later. Always obtain and
|
|
Packit |
90a5c9 |
install the current service pack to avoid operating system bugs.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Apache HTTP Server versions later than 2.2 will not run on any
|
|
Packit |
90a5c9 |
operating system earlier than Windows 2000.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
The Apache HTTP Server Project itself does not provide binary releases of
|
|
Packit |
90a5c9 |
software, only source code. Individual committers may provide
|
|
Packit |
90a5c9 |
binary packages as a convenience, but it is not a release deliverable.
|
|
Packit |
90a5c9 |
If you cannot compile the Apache HTTP Server
|
|
Packit |
90a5c9 |
yourself, you can obtain a binary package from numerous binary distributions
|
|
Packit |
90a5c9 |
available on the Internet.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Popular options for deploying Apache httpd, and, optionally, PHP
|
|
Packit |
90a5c9 |
and MySQL, on Microsoft Windows, include:
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
ApacheHaus
|
|
Packit |
90a5c9 |
Apache Lounge
|
|
Packit |
90a5c9 |
BitNami WAMP Stack
|
|
Packit |
90a5c9 |
WampServer
|
|
Packit |
90a5c9 |
XAMPP
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Apache is configured by the files in the conf
|
|
Packit |
90a5c9 |
subdirectory. These are the same files used to configure the Unix
|
|
Packit |
90a5c9 |
version, but there are a few different directives for Apache on
|
|
Packit |
90a5c9 |
Windows. See the directive index
|
|
Packit |
90a5c9 |
for all the available directives.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
The main differences in Apache for Windows are:
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Because Apache for Windows is multithreaded, it does not
|
|
Packit |
90a5c9 |
use a separate process for each request, as Apache can on Unix.
|
|
Packit |
90a5c9 |
Instead there are usually only two Apache processes running: a
|
|
Packit |
90a5c9 |
parent process, and a child which handles the requests. Within
|
|
Packit |
90a5c9 |
the child process each request is handled by a separate thread.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
The process management directives are also different:
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
MaxConnectionsPerChild :
|
|
Packit |
90a5c9 |
Like the Unix directive, this controls how many connections a single
|
|
Packit |
90a5c9 |
child process will serve before exiting.
|
|
Packit |
90a5c9 |
However, unlike on Unix, a replacement process is not instantly
|
|
Packit |
90a5c9 |
available. Use the default MaxConnectionsPerChild 0 ,
|
|
Packit |
90a5c9 |
unless instructed to change the behavior to overcome a memory leak
|
|
Packit |
90a5c9 |
in third party modules or in-process applications.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Warning: The server configuration
|
|
Packit |
90a5c9 |
file is reread when a new child process is started. If you have
|
|
Packit |
90a5c9 |
modified httpd.conf , the new child may not start or
|
|
Packit |
90a5c9 |
you may receive unexpected results.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
ThreadsPerChild :
|
|
Packit |
90a5c9 |
This directive is new. It tells the server how many threads it
|
|
Packit |
90a5c9 |
should use. This is the maximum number of connections the server
|
|
Packit |
90a5c9 |
can handle at once, so be sure to set this number high enough for
|
|
Packit |
90a5c9 |
your site if you get a lot of hits. The recommended default is
|
|
Packit |
90a5c9 |
ThreadsPerChild 150 , but this must be adjusted to
|
|
Packit |
90a5c9 |
reflect the greatest anticipated number of simultaneous
|
|
Packit |
90a5c9 |
connections to accept.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
The directives that accept filenames as arguments must use
|
|
Packit |
90a5c9 |
Windows filenames instead of Unix ones. However, because Apache
|
|
Packit |
90a5c9 |
may interpret backslashes as an "escape character" sequence, you
|
|
Packit |
90a5c9 |
should consistently use forward slashes in path names, not
|
|
Packit |
90a5c9 |
backslashes.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
While filenames are generally case-insensitive on
|
|
Packit |
90a5c9 |
Windows, URLs are still treated internally as case-sensitive
|
|
Packit |
90a5c9 |
before they are mapped to the filesystem. For example, the
|
|
Packit |
90a5c9 |
<Location> ,
|
|
Packit |
90a5c9 |
Alias , and ProxyPass directives all use
|
|
Packit |
90a5c9 |
case-sensitive arguments. For this reason, it is particularly
|
|
Packit |
90a5c9 |
important to use the <Directory> directive when attempting
|
|
Packit |
90a5c9 |
to limit access to content in the filesystem, since this
|
|
Packit |
90a5c9 |
directive applies to any content in a directory, regardless of
|
|
Packit |
90a5c9 |
how it is accessed. If you wish to assure that only lowercase
|
|
Packit |
90a5c9 |
is used in URLs, you can use something like:
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
RewriteEngine On
|
|
Packit |
90a5c9 |
RewriteMap lowercase int:tolower
|
|
Packit |
90a5c9 |
RewriteCond "%{REQUEST_URI}" "[A-Z]"
|
|
Packit |
90a5c9 |
RewriteRule "(.*)" "${lowercase:$1}" [R,L]
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
When running, Apache needs write access only to the logs
|
|
Packit |
90a5c9 |
directory and any configured cache directory tree. Due to the
|
|
Packit |
90a5c9 |
issue of case insensitive and short 8.3 format names, Apache must
|
|
Packit |
90a5c9 |
validate all path names given. This means that each directory
|
|
Packit |
90a5c9 |
which Apache evaluates, from the drive root up to the directory
|
|
Packit |
90a5c9 |
leaf, must have read, list and traverse directory permissions.
|
|
Packit |
90a5c9 |
If Apache2.4 is installed at C:\Program Files, then the root
|
|
Packit |
90a5c9 |
directory, Program Files and Apache2.4 must all be visible
|
|
Packit |
90a5c9 |
to Apache.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Apache for Windows contains the ability to load modules at
|
|
Packit |
90a5c9 |
runtime, without recompiling the server. If Apache is compiled
|
|
Packit |
90a5c9 |
normally, it will install a number of optional modules in the
|
|
Packit |
90a5c9 |
\Apache2.4\modules directory. To activate these or
|
|
Packit |
90a5c9 |
other modules, the LoadModule
|
|
Packit |
90a5c9 |
directive must be used. For example, to activate the status
|
|
Packit |
90a5c9 |
module, use the following (in addition to the status-activating
|
|
Packit |
90a5c9 |
directives in access.conf ):
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
LoadModule status_module modules/mod_status.so
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Information on creating
|
|
Packit |
90a5c9 |
loadable modules is also available.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Apache can also load ISAPI (Internet Server Application
|
|
Packit |
90a5c9 |
Programming Interface) extensions such as those used by Microsoft
|
|
Packit |
90a5c9 |
IIS and other Windows servers. More
|
|
Packit |
90a5c9 |
information is available. Note that Apache cannot
|
|
Packit |
90a5c9 |
load ISAPI Filters, and ISAPI Handlers with some Microsoft feature
|
|
Packit |
90a5c9 |
extensions will not work.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
When running CGI scripts, the method Apache uses to find
|
|
Packit |
90a5c9 |
the interpreter for the script is configurable using the
|
|
Packit |
90a5c9 |
ScriptInterpreterSource
|
|
Packit |
90a5c9 |
directive.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Since it is often difficult to manage files with names
|
|
Packit |
90a5c9 |
like .htaccess in Windows, you may find it useful to
|
|
Packit |
90a5c9 |
change the name of this per-directory configuration file using
|
|
Packit |
90a5c9 |
the AccessFilename
|
|
Packit |
90a5c9 |
directive.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Any errors during Apache startup are logged into the
|
|
Packit |
90a5c9 |
Windows event log when running on Windows NT. This mechanism
|
|
Packit |
90a5c9 |
acts as a backup for those situations where Apache is not yet
|
|
Packit |
90a5c9 |
prepared to use the error.log file. You can
|
|
Packit |
90a5c9 |
review the Windows Application Event Log by using the Event Viewer,
|
|
Packit |
90a5c9 |
e.g. Start - Settings - Control Panel - Administrative Tools
|
|
Packit |
90a5c9 |
- Event Viewer.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Apache comes with a utility called the Apache Service Monitor.
|
|
Packit |
90a5c9 |
With it you can see and manage the state of all installed Apache
|
|
Packit |
90a5c9 |
services on any machine on your network. To be able to manage an
|
|
Packit |
90a5c9 |
Apache service with the monitor, you have to first install the
|
|
Packit |
90a5c9 |
service (either automatically via the installation or manually).
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
You can install Apache as a Windows NT service as follows from
|
|
Packit |
90a5c9 |
the command prompt at the Apache bin subdirectory:
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
httpd.exe -k install
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
If you need to specify the name of the service you want to
|
|
Packit |
90a5c9 |
install, use the following command. You have to do this if you
|
|
Packit |
90a5c9 |
have several different service installations of Apache on your
|
|
Packit |
90a5c9 |
computer. If you specify a name during the install, you have to
|
|
Packit |
90a5c9 |
also specify it during any other -k operation.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
httpd.exe -k install -n "MyServiceName"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
If you need to have specifically named configuration files for
|
|
Packit |
90a5c9 |
different services, you must use this:
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
httpd.exe -k install -n "MyServiceName" -f "c:\files\my.conf"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
If you use the first command without any special parameters except
|
|
Packit |
90a5c9 |
-k install , the service will be called Apache2.4
|
|
Packit |
90a5c9 |
and the configuration will be assumed to be conf\httpd.conf .
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Removing an Apache service is easy. Just use:
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
httpd.exe -k uninstall
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
The specific Apache service to be uninstalled can be specified by using:
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
httpd.exe -k uninstall -n "MyServiceName"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Normal starting, restarting and shutting down of an Apache
|
|
Packit |
90a5c9 |
service is usually done via the Apache Service Monitor, by using
|
|
Packit |
90a5c9 |
commands like NET START Apache2.4 and NET STOP
|
|
Packit |
90a5c9 |
Apache2.4 or via normal Windows service management. Before
|
|
Packit |
90a5c9 |
starting Apache as a service by any means, you should test the
|
|
Packit |
90a5c9 |
service's configuration file by using:
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
httpd.exe -n "MyServiceName" -t
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
You can control an Apache service by its command line switches,
|
|
Packit |
90a5c9 |
too. To start an installed Apache service you'll use this:
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
httpd.exe -k start -n "MyServiceName"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
To stop an Apache service via the command line switches, use
|
|
Packit |
90a5c9 |
this:
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
httpd.exe -k stop -n "MyServiceName"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
or
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
httpd.exe -k shutdown -n "MyServiceName"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
You can also restart a running service and force it to reread
|
|
Packit |
90a5c9 |
its configuration file by using:
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
httpd.exe -k restart -n "MyServiceName"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
By default, all Apache services are registered to run as the
|
|
Packit |
90a5c9 |
system user (the LocalSystem account). The
|
|
Packit |
90a5c9 |
LocalSystem account has no privileges to your network
|
|
Packit |
90a5c9 |
via any Windows-secured mechanism, including the file system, named
|
|
Packit |
90a5c9 |
pipes, DCOM, or secure RPC. It has, however, wide privileges locally.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Never grant any network privileges to
|
|
Packit |
90a5c9 |
the LocalSystem account! If you need Apache to be able
|
|
Packit |
90a5c9 |
to access network resources, create a separate account for Apache as
|
|
Packit |
90a5c9 |
noted below.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
It is recommended that users create a separate account for running
|
|
Packit |
90a5c9 |
Apache service(s). If you have to access network resources via Apache,
|
|
Packit |
90a5c9 |
this is required.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Create a normal domain user account, and be sure to
|
|
Packit |
90a5c9 |
memorize its password.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Grant the newly-created user a privilege of Log on
|
|
Packit |
90a5c9 |
as a service and Act as part of the operating
|
|
Packit |
90a5c9 |
system. On Windows NT 4.0 these privileges are granted via
|
|
Packit |
90a5c9 |
User Manager for Domains, but on Windows 2000 and XP you probably
|
|
Packit |
90a5c9 |
want to use Group Policy for propagating these settings. You can
|
|
Packit |
90a5c9 |
also manually set these via the Local Security Policy MMC snap-in.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Confirm that the created account is a member of the Users
|
|
Packit |
90a5c9 |
group.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Grant the account read and execute (RX) rights to all document
|
|
Packit |
90a5c9 |
and script folders (htdocs and cgi-bin
|
|
Packit |
90a5c9 |
for example).
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Grant the account change (RWXD) rights to the
|
|
Packit |
90a5c9 |
Apache logs directory.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Grant the account read and execute (RX) rights to the
|
|
Packit |
90a5c9 |
httpd.exe binary executable.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
It is usually a good practice to grant the user the Apache
|
|
Packit |
90a5c9 |
service runs as read and execute (RX) access to the whole Apache2.4
|
|
Packit |
90a5c9 |
directory, except the logs subdirectory, where the
|
|
Packit |
90a5c9 |
user has to have at least change (RWXD) rights.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
If you allow the account to log in as a user and as a service,
|
|
Packit |
90a5c9 |
then you can log on with that account and test that the account has
|
|
Packit |
90a5c9 |
the privileges to execute the scripts, read the web pages, and that
|
|
Packit |
90a5c9 |
you can start Apache in a console window. If this works, and you
|
|
Packit |
90a5c9 |
have followed the steps above, Apache should execute as a service
|
|
Packit |
90a5c9 |
with no problems.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Error code 2186 is a good indication that
|
|
Packit |
90a5c9 |
you need to review the "Log On As" configuration for the service,
|
|
Packit |
90a5c9 |
since Apache cannot access a required network resource. Also, pay
|
|
Packit |
90a5c9 |
close attention to the privileges of the user Apache is
|
|
Packit |
90a5c9 |
configured to run as.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
When starting Apache as a service you may encounter an error
|
|
Packit |
90a5c9 |
message from the Windows Service Control Manager. For example,
|
|
Packit |
90a5c9 |
if you try to start Apache by using the Services applet in the
|
|
Packit |
90a5c9 |
Windows Control Panel, you may get the following message:
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Could not start the Apache2.4 service on \\COMPUTER
|
|
Packit |
90a5c9 |
Error 1067; The process terminated unexpectedly.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
You will get this generic error if there is any problem with
|
|
Packit |
90a5c9 |
starting the Apache service. In order to see what is really causing
|
|
Packit |
90a5c9 |
the problem you should follow the instructions for Running Apache
|
|
Packit |
90a5c9 |
for Windows from the Command Prompt.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
If you are having problems with the service, it is suggested
|
|
Packit |
90a5c9 |
you follow the instructions below to try starting httpd.exe from
|
|
Packit |
90a5c9 |
a console window, and work out the errors before struggling to
|
|
Packit |
90a5c9 |
start it as a service again.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Running Apache as a service is usually the recommended way to
|
|
Packit |
90a5c9 |
use it, but it is sometimes easier to work from the command line,
|
|
Packit |
90a5c9 |
especially during initial configuration and testing.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
To run Apache from the command line as a console application,
|
|
Packit |
90a5c9 |
use the following command:
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
httpd.exe
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Apache will execute, and will remain running until it is stopped
|
|
Packit |
90a5c9 |
by pressing Control-C.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
You can also run Apache via the shortcut Start Apache in Console
|
|
Packit |
90a5c9 |
placed to Start Menu --> Programs --> Apache HTTP Server
|
|
Packit |
90a5c9 |
2.4.xx --> Control Apache Server during the installation.
|
|
Packit |
90a5c9 |
This will open a console window and start Apache inside it. If you
|
|
Packit |
90a5c9 |
don't have Apache installed as a service, the window will remain
|
|
Packit |
90a5c9 |
visible until you stop Apache by pressing Control-C in the console
|
|
Packit |
90a5c9 |
window where Apache is running in. The server will exit in a few
|
|
Packit |
90a5c9 |
seconds. However, if you do have Apache installed as a service, the
|
|
Packit |
90a5c9 |
shortcut starts the service. If the Apache service is running
|
|
Packit |
90a5c9 |
already, the shortcut doesn't do anything.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
If Apache is running as a service, you can tell it to stop by opening another console
|
|
Packit |
90a5c9 |
window and entering:
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
httpd.exe -k shutdown
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Running as a service should be preferred over running in a
|
|
Packit |
90a5c9 |
console window because this lets Apache end any current operations
|
|
Packit |
90a5c9 |
and clean up gracefully.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
But if the server is running in a console window, you can
|
|
Packit |
90a5c9 |
only stop it by pressing Control-C in the same window.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
You can also tell Apache to restart. This forces it to reread
|
|
Packit |
90a5c9 |
the configuration file. Any operations in progress are allowed to
|
|
Packit |
90a5c9 |
complete without interruption. To restart Apache, either press
|
|
Packit |
90a5c9 |
Control-Break in the console window you used for starting Apache,
|
|
Packit |
90a5c9 |
or enter
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
httpd.exe -k restart
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if the server is running as a service.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Note for people familiar with the Unix version of Apache:
|
|
Packit |
90a5c9 |
these commands provide a Windows equivalent to kill -TERM
|
|
Packit |
90a5c9 |
pid and kill -USR1 pid . The
|
|
Packit |
90a5c9 |
command line option used, -k , was chosen as a reminder
|
|
Packit |
90a5c9 |
of the kill command used on Unix.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
If the Apache console window closes immediately or unexpectedly
|
|
Packit |
90a5c9 |
after startup, open the Command Prompt from the Start Menu -->
|
|
Packit |
90a5c9 |
Programs. Change to the folder to which you installed Apache, type
|
|
Packit |
90a5c9 |
the command httpd.exe , and read the error message. Then
|
|
Packit |
90a5c9 |
change to the logs folder, and review the error.log
|
|
Packit |
90a5c9 |
file for configuration mistakes. Assuming httpd was installed into
|
|
Packit |
90a5c9 |
C:\Program Files\Apache Software Foundation\Apache2.4\ ,
|
|
Packit |
90a5c9 |
you can do the following:
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
c:
|
|
Packit |
90a5c9 |
cd "\Program Files\Apache Software Foundation\Apache2.4\bin"
|
|
Packit |
90a5c9 |
httpd.exe
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Then wait for Apache to stop, or press Control-C. Then enter the
|
|
Packit |
90a5c9 |
following:
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
cd ..\logs
|
|
Packit |
90a5c9 |
more < error.log
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
When working with Apache it is important to know how it will
|
|
Packit |
90a5c9 |
find the configuration file. You can specify a configuration file
|
|
Packit |
90a5c9 |
on the command line in two ways:
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
-f specifies an absolute or relative path to
|
|
Packit |
90a5c9 |
a particular configuration file:
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
httpd.exe -f "c:\my server files\anotherconfig.conf"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
or
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
httpd.exe -f files\anotherconfig.conf
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
-n specifies the installed Apache service
|
|
Packit |
90a5c9 |
whose configuration file is to be used:
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
httpd.exe -n "MyServiceName"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
In both of these cases, the proper
|
|
Packit |
90a5c9 |
ServerRoot should be set in
|
|
Packit |
90a5c9 |
the configuration file.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
If you don't specify a configuration file with -f
|
|
Packit |
90a5c9 |
or -n , Apache will use the file name compiled into the
|
|
Packit |
90a5c9 |
server, such as conf\httpd.conf . This built-in path
|
|
Packit |
90a5c9 |
is relative to the installation directory. You can verify the compiled
|
|
Packit |
90a5c9 |
file name from a value labelled as SERVER_CONFIG_FILE when
|
|
Packit |
90a5c9 |
invoking Apache with the -V switch, like this:
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
httpd.exe -V
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Apache will then try to determine its ServerRoot by trying the following, in this order:
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
A ServerRoot directive
|
|
Packit |
90a5c9 |
via the -C command line switch.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
The -d switch on the command line.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Current working directory.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
A registry entry which was created if you did a binary
|
|
Packit |
90a5c9 |
installation.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
The server root compiled into the server. This is
|
|
Packit |
90a5c9 |
/apache by default, you can verify it by using
|
|
Packit |
90a5c9 |
httpd.exe -V and looking for a value labelled as
|
|
Packit |
90a5c9 |
HTTPD_ROOT .
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
If you did not do a binary install, Apache will in some
|
|
Packit |
90a5c9 |
scenarios complain about the missing registry key. This warning can
|
|
Packit |
90a5c9 |
be ignored if the server was otherwise able to find its
|
|
Packit |
90a5c9 |
configuration file.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
The value of this key is the
|
|
Packit |
90a5c9 |
ServerRoot directory which
|
|
Packit |
90a5c9 |
contains the conf subdirectory. When Apache starts it
|
|
Packit |
90a5c9 |
reads the httpd.conf file from that directory. If
|
|
Packit |
90a5c9 |
this file contains a ServerRoot
|
|
Packit |
90a5c9 |
directive which contains a different directory from the one
|
|
Packit |
90a5c9 |
obtained from the registry key above, Apache will forget the
|
|
Packit |
90a5c9 |
registry key and use the directory from the configuration file. If
|
|
Packit |
90a5c9 |
you copy the Apache directory or configuration files to a new
|
|
Packit |
90a5c9 |
location it is vital that you update the
|
|
Packit |
90a5c9 |
ServerRoot directive in the
|
|
Packit |
90a5c9 |
httpd.conf file to reflect the new location.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
After starting Apache (either in a console window or as a
|
|
Packit |
90a5c9 |
service) it will be listening on port 80 (unless you changed the
|
|
Packit |
90a5c9 |
Listen directive in the
|
|
Packit |
90a5c9 |
configuration files or installed Apache only for the current user).
|
|
Packit |
90a5c9 |
To connect to the server and access the default page, launch a
|
|
Packit |
90a5c9 |
browser and enter this URL:
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
http://localhost/
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Apache should respond with a welcome page and you should see
|
|
Packit |
90a5c9 |
"It Works!". If nothing happens or you get an error, look in the
|
|
Packit |
90a5c9 |
error.log file in the logs subdirectory.
|
|
Packit |
90a5c9 |
If your host is not connected to the net, or if you have serious
|
|
Packit |
90a5c9 |
problems with your DNS (Domain Name Service) configuration, you
|
|
Packit |
90a5c9 |
may have to use this URL:
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
http://127.0.0.1/
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
If you happen to be running Apache on an alternate port, you
|
|
Packit |
90a5c9 |
need to explicitly put that in the URL:
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
http://127.0.0.1:8080/
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Once your basic installation is working, you should configure it
|
|
Packit |
90a5c9 |
properly by editing the files in the conf subdirectory.
|
|
Packit |
90a5c9 |
Again, if you change the configuration of the Windows NT service
|
|
Packit |
90a5c9 |
for Apache, first attempt to start it from the command line to
|
|
Packit |
90a5c9 |
make sure that the service starts with no errors.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Because Apache cannot share the same port with
|
|
Packit |
90a5c9 |
another TCP/IP application, you may need to stop, uninstall or reconfigure
|
|
Packit |
90a5c9 |
certain other services before running Apache. These conflicting
|
|
Packit |
90a5c9 |
services include other WWW servers, some firewall implementations,
|
|
Packit |
90a5c9 |
and even some client applications (such as Skype) which will use port
|
|
Packit |
90a5c9 |
80 to attempt to bypass firewall issues.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Access to files over the network can be specified using two
|
|
Packit |
90a5c9 |
mechanisms provided by Windows:
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Mapped drive letters
|
|
Packit |
90a5c9 |
e.g., Alias "/images/" "Z:/"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
UNC paths
|
|
Packit |
90a5c9 |
e.g., Alias "/images/" "//imagehost/www/images/"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Mapped drive letters allow the administrator to maintain the
|
|
Packit |
90a5c9 |
mapping to a specific machine and path outside of the Apache httpd
|
|
Packit |
90a5c9 |
configuration. However, these mappings are associated only with
|
|
Packit |
90a5c9 |
interactive sessions and are not directly available to Apache httpd
|
|
Packit |
90a5c9 |
when it is started as a service. Use only UNC paths for
|
|
Packit |
90a5c9 |
network resources in httpd.conf so that the resources can
|
|
Packit |
90a5c9 |
be accessed consistently regardless of how Apache httpd is started.
|
|
Packit |
90a5c9 |
(Arcane and error prone procedures may work around the restriction
|
|
Packit |
90a5c9 |
on mapped drive letters, but this is not recommended.)
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Example DocumentRoot with UNC pathDocumentRoot "//dochost/www/html/"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Example DocumentRoot with IP address in UNC pathDocumentRoot "//192.168.1.50/docs/"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Example Alias and corresponding Directory with UNC pathAlias "/images/" "//imagehost/www/images/"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
<Directory "//imagehost/www/images/">
|
|
Packit |
90a5c9 |
#...
|
|
Packit |
90a5c9 |
<Directory>
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
When running Apache httpd as a service, you must create a
|
|
Packit |
90a5c9 |
separate account in order to access network resources, as described
|
|
Packit |
90a5c9 |
above.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
If more than a few dozen piped loggers are used on an operating system
|
|
Packit |
90a5c9 |
instance, scaling up the "desktop heap" is often necessary. For
|
|
Packit |
90a5c9 |
more detailed information, refer to the piped logging documentation.
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
Available Languages: en |
|
|
Packit |
90a5c9 |
fr |
|
|
Packit |
90a5c9 |
ko
|
|
Packit |
90a5c9 |
Notice:This is not a Q&A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our mailing lists.
|
|
Packit |
90a5c9 |
<script type="text/javascript">
|
|
Packit |
90a5c9 |
var comments_shortname = 'httpd';
|
|
Packit |
90a5c9 |
var comments_identifier = 'http://httpd.apache.org/docs/2.4/platform/windows.html';
|
|
Packit |
90a5c9 |
(function(w, d) {
|
|
Packit |
90a5c9 |
if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
|
|
Packit |
90a5c9 |
d.write('
|
|
Packit |
90a5c9 |
var s = d.createElement('script');
|
|
Packit |
90a5c9 |
s.type = 'text/javascript';
|
|
Packit |
90a5c9 |
s.async = true;
|
|
Packit |
90a5c9 |
s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
|
|
Packit |
90a5c9 |
(d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
else {
|
|
Packit |
90a5c9 |
d.write('
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
})(window, document);
|
|
Packit |
90a5c9 |
//--></script>
|
|
Packit |
90a5c9 |
Copyright 2018 The Apache Software Foundation. Licensed under the Apache License, Version 2.0.
|
|
Packit |
90a5c9 |
Modules | Directives | FAQ | Glossary | Sitemap <script type="text/javascript">
|
|
Packit |
90a5c9 |
if (typeof(prettyPrint) !== 'undefined') {
|
|
Packit |
90a5c9 |
prettyPrint();
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
//--></script>
|
|
Packit |
90a5c9 |
</body></html>
|