[APACHE DOCUMENTATION]

Apache HTTP Server Version 1.3

Using Apache With Microsoft Windows

このドキュメントは Microsoft Windows で Apache 1.3 をどのようにインストールして、設定し、走らせるかを述べたものです。 ここで注意して欲しいのは、Windows のサポートが全く実験的なもので、経験を積んだユーザにしか勧められないということです。 Apache Group はこのソフトウェアが記述通りに動くことを保証しません。もしバグがあったり、なんらかの貢献を望むなら、 バグ報告ページを使ってください。

警告: NT での Apache はまだパフォーマンスが最適化されていません。Apache がベストなパフォーマンスで動き、最も確実なのは Unix のプラットフォームです。 いずれ、NT のパフォーマンスは改善します。ウェブサーバの比較調査は、Solaris、FreeBSD、Linux といった Unix のプラットフォームでの Apache の比較をしています。

このドキュメントはバイナリ配布からのインストールを想定しています。もし自身でコンパイルなさりたいなら(開発や、バグ探しのために)、以下にある Windows での Apache のコンパイル セクションをご覧ください。



必須条件

Apache 1.3 は Windows NT 4.0 上で走るようになっています。バイナリのインストーラは Intel のプロセッサのみで動作します。Apache は Windows 95、Windows 98、Windows NT 3.5.1 でも動きますが、テストされていません。どの場合も TCP/IP ネットワークがインストールされていることが必要です。

Windows 95 で走らせるなら、"Winsock2" のアップグレードをお勧めしますが、必要ではありません。 NT 4.0 では、Service Pack 2 のインストールを推奨します。

Windows 版 Apache のダウンロード

Apache 最新版の情報は、Apache ウェブサイト http://www.apache.org/ で見ることができます。 ここでは、最新のリリース、α版、βテスト版のリリースが、ミラーサイト、anonymous ftp サイトと共に表示されています。

拡張子が .exe になっている、Windows 版 Apache をダウンロードしてください。これは Apache をインストールして、走らせる自己解凍ファイルです。自身で Apache をコンパイルするための、ソースコードのあるファイルは .zip です (もし .zip ファイルがなければ、ソースは .tar.gz ファイルが利用できます。しかし、これは Unix のラインエンドを持っています。 MSVC が認識するように、少なくとも .mak.dsp のファイルを DOS のラインエンドに変換してください)。

Windows 版 Apache のインストール

Run the Apache .exe file you downloaded above. This will ask for:

During the installation, Apache will configure the files in the conf directory for your chosen installation directory. However if any of the files in this directory already exist they will not be overwritten. Instead the new copy of the corresponding file will be left with the extension .default. So, for example, if conf\httpd.conf already exists it will not be altered, but the version which would have been installed will be left in conf\httpd.conf.default. After the installation has finished you should manually check to see what in new in the .default file, and if necessary update your existing configuration files.

Also, if you already have a file called htdocs\index.html then it will not be overwritten (no index.html.default file will be installed either). This should mean it a safe to install Apache over an existing installation (but you will have to stop the existing server running before doing the installation, then start the new one after the installation is finished).

After installing Apache, you should edit the configuration files in the conf directory as required. These files will be configured during the install ready for Apache to be run from the directory where it was installed, with the documents served from the subdirectory htdocs. There are lots of other options which should be set before you start really using Apache. However to get started quickly the files should work as installed.

Running Apache for Windows

There are two ways you can run Apache: To start Apache as a service, you first need to install it as a service. Run the "Install Apache as Service (NT only)" option from the Start menu. Once this is done you can start Apache by opening the Services window (in the Control Panel), selecting Apache, then clicking on Start. Apache will now be running in the background. You can later stop Apache by clicking on Stop. As an alternative to using the Services window, you can start and stop Apache from the control line with
  NET START APACHE
  NET STOP APACHE
To run Apache from a console window, select the "Start Apache as console app" option from the Start menu (in Apache 1.3.4 and earlier, this option was called "Apache Server"). This will open a console window and start Apache running inside it. The window will remain active until you stop Apache. To stop Apache running, either select the "Shutdown Apache console app" icon option from the Start menu (this is not available in Apache 1.3.4 or earlier), or see Signalling Apache when Running for how to control Apache from the command line.

After starting Apache running (either in a console window or as a service) if will be listening to port 80 (unless you changed the Port, Listen or BindAddress directives in the configuration files). To connect to the server and access the default page, launch a browser and enter this URL:

  http://localhost/
This should respond with a welcome page, and a link to the Apache manual. If nothing happens or you get an error, look in the error_log file in the logs directory.

Once your basic installation is working, you should configure it properly by editing the files in the conf directory.

Configuring Apache for Windows

Apache is configured by files in the conf directory. These are the same as files used to configure the Unix version, but there are a few different directives for Apache on Windows. See the Apache documentation for all the available directives.

The main differences in Apache for Windows are:

Running Apache for Windows from the Command Line

The Start menu icons and the NT Service manager can provide a simple interface for administering Apache. But in some cases it is easier to work from the command line.

When working with Apache it is important to know how it will find the configuration files. Apache will try one of the following, in this order.

The server root compiled into the server is usually "/apache". invoking apache with the -v switch will display this value labeled as HTTPD_ROOT.

Your current working directory when Apache is started up has no effect on Apache's behavior.

When invoked from the start menu or the Service Manager, Apache is usually passed no arguments, so using the registry entry is the preferred technique.

During a binary installation, a registry key will have been installed, for example:

  HKEY_LOCAL_MACHINE\Software\Apache Group\Apache\1.3.4\ServerRoot

This key is compiled into the server and can enable you to test new versions without affecting the current version. Of course you must take care not to install the new version on top of the old version in the file system. You cannot run two invocations of Apache on Windows simultaneously.

If you did not do a binary install then Apache will in some scenarios complain that about the missing registry key. This warning can be ignored if it otherwise was able to find it's configuration files.

The value of this key is the "ServerRoot" directory, containing the conf directory. When Apache starts it will read the httpd.conf file from this directory. If this file contains a ServerRoot directive which is different from the directory obtained from the registry key above, Apache will forget the registry key and use the directory from the configuration file. If you copy the Apache directory or configuration files to a new location it is vital that you update the ServerRoot directory in the httpd.conf file to the new location.

To run Apache from the command line as a console application, use the following command:

    apache -s
Apache will execute, and will remain running until it is stopped by pressing control-C. (The -s option is not required by Windows 95, but on Windows NT it prevents Apache waiting to see if Apache is running as a service.)

You can install Apache as a Windows NT service as follows:

    apache -i
and to remove the Apache service, use
    apache -u

Signalling Apache when running

On Windows 95, Apache runs as a console application. You can tell a running Apache to stop by opening another console window and running
    apache -k shutdown
Note: This option is only available with Apache 1.3.3 and later. For earlier versions, you need to use Control-C in the Apache console window to shut down the server.

This should be used instead of pressing Control-C in the running Apache console window, because it lets Apache end any current transactions and cleanup gracefully.

You can also tell Apache to restart. This makes it re-read the configuration files. Any transactions in progress are allowed to complete without interruption. To restart Apache, run

    apache -k restart
Note: This option is only available with Apache 1.3.3 and later. For earlier versions, you need to use Control-C in the Apache console window to shut down the server.

Note for people familiar 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.

Compiling Apache for Windows

Compiling Apache requires Microsoft Visual C++ 5.0 to be properly installed. It is easiest to compile with the command-line tools (nmake, etc...). Consult the VC++ manual to determine how to install them.

First, unpack the Apache distribution into an appropriate directory. Open a command-line prompt, and change to the src subdirectory of the Apache distribution.

The master Apache makefile instructions are contained in the Makefile.nt file. To compile Apache on Windows NT, simply use one of the following commands:

(1.3.4 and later) To compile Apache on Windows 95, use one of

These will both compile Apache. The latter will include debugging information in the resulting files, making it easier to find bugs and track down problems.

Apache can also be compiled using VC++'s Visual Studio development environment. Although compiling Apache in this manner is not as simple, it makes it possible to easily modify the Apache source, or to compile Apache if the command-line tools are not installed. Project files (.DSP) are included for each of the portions of Apache. To build Apache from the these projects files you will need to build the following projects in this order:

  1. os\win32\ApacheOS.dsp
  2. regex\regex.dsp
  3. ap\ap.dsp
  4. main\gen_uri_delims.dsp
  5. main\gen_test_char.dsp
  6. ApacheCore.dsp
  7. Apache.dsp
In addition, the src\os\win32 subdirectory contains project files for the optional modules (see below).

Once Apache has been compiled, it needs to be installed in its server root directory. The default is the \Apache directory, on the current hard drive.

To install the files into the \Apache directory automatically, use one the following nmake commands (see above):

or, for Windows 95 (1.3.4 and later), use one of: The dir argument to INSTDIR gives the installation directory; it can be omitted if Apache is to be installed into \Apache.

This will install the following:

If you do not have nmake, or wish to install in a different directory, be sure to use a similar naming scheme.

Before running the server you must fill out the conf directory. Copy the *.conf-dist-win from the distribution conf directory and rename *.conf. Edit the @@ServerRoot@@ entries to your actual server root (for example "C:\apache"). Copy over the conf/magic and conf/mime.types files as well.


このページの情報に関わる、ご質問、お問い合わせは、 japache@infoscience.co.jpまで。

JAPACHE ホームページ