Apache 2.4.2(Apache Lounge版)をWindows 7にインストールした

ノートPCのWindows 7(64ビット版)にApache 2.4.2(Apache Lounge版)をインストールした時のメモを以下に記載する。

(1)Apacheのインストールファイルの入手

Apache 2.4.2(Apache Lounge版)のインストールファイルは、Apache Loungeのダウンロードサイト(http://www.apachelounge.com/download/)より入手できる。

このサイトに、

Apache 2.4.2 Same as above, except build with OpenSSl 0.9.8x instead of 1.0.1c

httpd-2.4.2-win32-ssl_0.9.8.zip            info    13 May '12  10.062K

とあったので、httpd-2.4.2-win32-ssl_0.9.8.zipをダウンロードした。

 

(2)Apacheのインストール開始

ダウンロードしたZIPファイルを解凍し、解凍フォルダ(httpd-2.4.2-win32-ssl_0.9.8)直下にあった「ReadMe.txt」ファイルを見ながら、Apacheのインストールを開始する。

ReadMe.txt記載内容(ここから)
--------------------------------------------------------------------------------------------
Build with Visual Studioョ 2010 SP1 (VC10) x86
---------------------------------------------
Be sure you have installed the Visual C++ 2010 SP1 Redistributable Package x86.
Download and install, if you not have it already, from:

  http://www.microsoft.com/download/en/details.aspx?id=8328

Loads 2.4 Win32 modules VC9 and VC10.


Minimum system required
-----------------------

Windows 7
Windows Server 2008 R2
Windows Vista
Windows Server 2008 
Windows XP SP3
Windows Server 2003 R2
 

Install
-------


- Unzip the Apache24 folder to c:/Apache24 (that is the ServerRoot in the config).
  Default folder for your your webpages is DocumentRoot "c:/Apache24/htdocs"

  When you unzip to an other location, change ServerRoot in the httpd.conf,
  and change in httpd.conf e.g. the Documenroot, Directories, ScriptAlias,
  also when you use the extra folder config files change to your location there. 

Start apache in a DOS box:

>httpd.exe

Install as a service:

>httpd.exe -k install

ApacheMonitor:

Double click ApacheMonitor.exe, or put it in your Startup folder.

 

Upgrading
---------

- Upgrading from 2.2.x see: httpd.apache.org/docs/2.4/upgrading.html
  and see httpd.apache.org/docs/2.4/new_features_2_4.html .

- Updating from 2.3.x
  copy all the files over, except your changed .conf files.
--------------------------------------------------------------------------------------------
ReadMe.txt記載内容(ここまで)

 

(3)Visual C++ 2010 SP1 Redistributable Package x86のインストール状況確認およびインストール

ReadMeファイルに、

Be sure you have installed the Visual C++ 2010 SP1 Redistributable Package x86.

と記載されていたので、Visual C++ 2010 SP1 Redistributable Package x86がWindows 7にインストールされているかを確認してみた。

コントロール パネル>プログラム>プログラムと機能

で確認すると、

Microsoft Visual C++ 2010 x86 Redistributable - 10.0.40219

が確認できた。

しかし、ReadMeファイルでは、「Visual C++ 2010 SP1」となっており、Windows 7に入っている「SP1」ではない「Visual C++ 2010」ではダメだろう、と思った。(こう思ったことを後悔することになる。)

そこで、ReadMeファイルの

Download and install, if you not have it already, from:

  http://www.microsoft.com/download/en/details.aspx?id=8328

という記述に従い、マイクロソフトのホームページを開いて確認してみる。

http://www.microsoft.com/download/en/details.aspx?id=8328
Microsoft Visual C++ 2010 SP1 Redistributable Package (x86)

The Microsoft Visual C++ 2010 SP1 Redistributable Package (x86) installs runtime components of Visual C++ Libraries required to run applications developed with Visual C++ 2010 SP1 on a computer that does not have Visual C++ 2010 SP1 installed.

上記のページから「日本語版のページ」に移動する。

http://www.microsoft.com/ja-jp/download/details.aspx?id=8328
Microsoft Visual C++ 2010 SP1 再頒布可能パッケージ (x86)

Microsoft Visual C++ 2010 SP1 再頒布可能パッケージ (x86) は、Visual C++ 2010 SP1 で開発されたアプリケーションを Visual C++ 2010 SP1 がインストールされていないコンピューター上で実行するために必要な、Visual C++ ライブラリのランタイム コンポーネントをインストールします。

この日本語サイトから、「vcredist_x86.exe」というファイルをダウンロードした。

ダウンロードした実行ファイル「vcredist_x86.exe」をダブルクリックで起動したところ、「Microsoft Visual C++ 2010 x86 Redistributable メンテナンス」という画面が表示され

次のオプションから選択してください

○Microsoft Visual C++ 2010 x86 Redistributableを元の状態に修復します
○このコンピューターからMicrosoft Visual C++ 2010 x86 Redistributableを削除します

と、どちらかを選択するように求められた。

「元の状態に修復します」はオカシイだろうと思って、「削除します」を選んだところ、Microsoft Visual C++ 2010 x86 Redistributable - 10.0.40219がアンインストールされた。(コントロールパネルで確認すると、たしかに消えていた。)

あれ?SP1のインストールは始まらないの?と思い、再度、ダウンロードした実行ファイル「vcredist_x86.exe」をダブルクリックで起動したところ、

Welcome to Microsoft Visual C++ 2010 x86 Redistributable セットアップへようこそ

という画面が表示され、「マイクロソフト ソフトウェア ライセンス条項」という文字の下に

MICROSOFT VISUAL C++ 2010 RUNTIME LIBRARIES WITH SERVICE PACK 1

と書かれていた。

よし、と思ってインストールを終え、コントロールパネルで確認すると、先ほどアンインストールしたMicrosoft Visual C++ 2010 x86 Redistributable - 10.0.40219が復活していた。

ここでやっと、私の使っているWindows 7には、最初っからVisual C++ 2010 SP1 Redistributable Package x86がインストールされており、わざわざインストール(結果的には再インストール)する必要がなかった、ということが分かった。

コントロールパネルでは、「SP1」という表記はなかったが、どうやら、コントロールパネルで確認できる

Microsoft Visual C++ 2010 x86 Redistributable - 10.0.40219は
Visual C++ 2010 SP1 Redistributable Package x86と同じものだったようだ。

このインストール作業は、無駄だったなぁ...と少し後悔しながら、次の作業に移る。

 

(4)Apacheフォルダの設置

ReadMeファイルには、

Unzip the Apache24 folder to c:/Apache24 (that is the ServerRoot in the config).
  Default folder for your your webpages is DocumentRoot "c:/Apache24/htdocs"

と書かれている。

この例に従うなら、ドキュメントルートが「c:/Apache24/htdocs」になるように設定すれば、例と同じになるので設定が楽そうだ。

解凍フォルダ「httpd-2.4.2-win32-ssl_0.9.8」の直下に「Apache24」というフォルダがあり、そのフォルダ配下にはhtdocsフォルダやconfフォルダなどが存在することを確認したので、「Apache24」フォルダをCドライブ直下に設置した。

 

(5)httpd.confファイルの確認

ReadMeファイルには、

When you unzip to an other location, change ServerRoot in the httpd.conf,
  and change in httpd.conf e.g. the Documenroot, Directories, ScriptAlias,
  also when you use the extra folder config files change to your location there.

と書かれている。

c:/Apache24以外の場所にフォルダを設置した場合は、httpd.confを修正する必要があるみたいだった。今回、c:/Apache24に設置したので、httpd.confの修正は不要に思えたが、念のためにhttpd.confの中身を確認してみた。

ServerRoot "c:/Apache24"
DocumentRoot "c:/Apache24/htdocs"
<Directory "c:/Apache24/htdocs">
ScriptAlias /cgi-bin/ "c:/Apache24/cgi-bin/"
<Directory "c:/Apache24/cgi-bin">

「c:/Apache24」で設定されているものが合計5つ見つかったが、このままにしておいても大丈夫だろう、と思ったので、このままにしておくことにする。

 

(6)コマンドプロンプトでのApache起動

ReadMeファイルには、

Start apache in a DOS box:

>httpd.exe

Install as a service:

>httpd.exe -k install

ApacheMonitor:

Double click ApacheMonitor.exe, or put it in your Startup folder.

と書かれている。

ここに書かれている通りに、何も考えずに「httpd.exe」と(コマンドプロンプトで)叩くと、以下のようにエラーになる。

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\neko>httpd.exe
'httpd.exe' は、内部コマンドまたは外部コマンド、
操作可能なプログラムまたはバッチ ファイルとして認識されていません。

このようになってしまうのは、httpd.exeのパスが通っていないからだが、特に今のところパスを通したいとも思わないので、カレントディレクトリを変更してhttpd.exeを実行することとする。

httpd.exeが格納されているフォルダまでcdコマンドで移動する。

実行すると......

C:\Users\neko>cd c:\Apache24\bin

c:\Apache24\bin>httpd.exe
AH00558: httpd.exe: Could not reliably determine the server's fully qualified domain name, using fe80::1155:696f:bc0c:6ebd. Set the 'ServerName' directive globally to suppress this message

というエラーになってしまった。

ServerNameを修正しないといけないようだった。

 

(7)httpd.confの修正

C:\Apache24\confにあるhttpd.confを修正する。

以下のように、httpd.conf内の記述「#ServerName www.example.com:80」の下に「ServerName localhost:80」を追記した。

#ServerName www.example.com:80
ServerName localhost:80

httpd.confの修正後、再度同じコマンドを実行してみる。

c:\Apache24\bin>httpd.exe

エラーメッセージは表示されないが、応答が返ってこない。

 

(8)Apacheのインストール

ReadMeファイルを再度見直し、

Install as a service:

>httpd.exe -k install

と書かれているので、「サービスとしてApacheをインストールする」ことをやってみることにした。

コマンドプロンプトで、httpd.exe -k installを実行してみる。

c:\Apache24\bin>httpd.exe -k install
Installing the Apache2.4 service
(OS 5)アクセスが拒否されました。  : AH00369: Failed to open the WinNT service ma
nager, perhaps you forgot to log in as Adminstrator?

上記のようなエラーになってしまった。

しかし、このエラーは、「you forgot to log in as Adminstrator」を見て何となく分かった。おそらく、コマンドプロンプトを管理者権限で実行できていないことが原因だろう。

コマンドプロンプトを管理者権限で実行していなかったので、管理者権限で実行する。

※コマンドプロンプトを管理者権限で実行するには、以下のどちらかの方法になると思う。

  A)スタートメニューで「コマンド プロンプト」を探し、右クリック→「管理者として実行」をクリック

  B)「プログラムとファイルの検索」の入力欄で「cmd」と入力し、Ctrl+Shift+Enterキー

コマンドプロンプトを管理者権限で実行できるようになった後で、再度インストールを試す。

c:\Apache24\bin>httpd.exe -k install
Installing the Apache2.4 service
The Apache2.4 service is successfully installed.
Testing httpd.conf....
Errors reported here must be corrected before the service can be started.

インストールには成功したようだが、「Errors」というメッセージが見えたので、「httpd.confにエラーがあるから、サービスを開始する前に修正すべきである」、というメッセージであると思った。(後にこれは間違いであると気付いた。)

httpd.confの文法チェックでもしようかな、と思って、Apache2.2の時に利用したconfigtestコマンドで確認してみた。

コマンドプロンプトで

c:\Apache24\bin\httpd.exe -w -t -f "c:\Apache24\conf\httpd.conf" -d "c:\Apache24\."

というコマンドを実行した。

結果は、「Syntax OK」だった。

「Syntax OK」と出たので、httpd.confの記述ミスなどはないようだった。

また、C:\Apache24\logsのerror.logを見たが、参考になりそうなエラーは記録されていなかった。

実はインストールをもう1度やってみたらうまくいくのかな、と思ってもう1回インストールコマンドを実行してみると...

c:\Apache24\bin>httpd.exe -k install
[Sun Jul 22 02:30:36.502008 2012] [mpm_winnt:error] [pid 9584:tid 144] AH00433:
Apache2.4: Service is already installed.

となった。

「Apache 2.4サービスはインストール済みです」ということなので、インストールはたぶん正常に終了しているのだろう。

さて、どうしようかなぁ、と思ってC:\Apache24\binフォルダ内を眺めていると、ApacheMonitor.exeがあった。

このApacheMonitor.exeをダブルクリックで実行し、タスクトレイに表示されたApacheのアイコンをクリック→Apache 2.4→Startをクリックすると、特にエラーメッセージなどが表示されることもなく、あっさりとApacheが起動してしまった。

再度、ReadMeファイルをよく見ると、

>httpd.exe -k install

という記述のすぐ下に

ApacheMonitor:

Double click ApacheMonitor.exe, or put it in your Startup folder.

という記述があることに気付いた。

結果的には、ApacheMonitor.exeをダブルクリックで実行した行為は、正解だったようだ。しかし、たまたま正解だったからよかったが、もっとReadMeファイルを読まないといけないなぁ、と反省した。

さらに、インストール時に表示されたメッセージ

Testing httpd.conf....
Errors reported here must be corrected before the service can be started.

についても、再度考えてみた。

これはてっきり、「エラーが出た」というメッセージだと思い込んでいたのだが、この英語メッセージを直訳すると「httpd.confをテストしています。ここで見つかったエラーは、(Apache)サービスを開始する前に修正すべきです。」ということなので、「httpd.confにエラーが見つかった場合は、httpd.confを修正しておきなさい」というものであり、エラーが出ていたことを示しているのではなかったのかも。

このメッセージについては釈然としないながらも、これで何とかApache 2.4.2(Apache Lounge版)がインストールできたので、今後これを使って少しずつ遊んでいきたい。

前へ

「2012まさき町夏祭り」(愛媛県松前町)の花火大会の実施予定日時

次へ

原作・Juan D&iacute;az Canales/作画・Juanjo Guarnido『BLACKSAD ブラックサッド 黒猫の男』