Apache2.2.21 インストール
続いてApacheのインストールを開始します。今回ダウンロードしたファイルはインストーラー付きではありませんのでまずファイルの展開を行い、必要な箇所の設定ファイルを変更し、その後Apacheを起動します。
ではファイルの展開から行います。ダウンロードした「httpd-2.2.21-win32-x86-ssl.zip」ファイルは圧縮ファイルです。展開して任意のディレクトリに配置して下さい。
展開されるファイルはデフォルトでは「Apache2」という名前のディレクトリ内に入っています。今回は以前に使用したいたディレクトリ名に合わせて「Apache2.2」に変更しました。私の環境では「C:\pg\Apache\Apache2.2」ディレクトリ内にApacheのファイルが展開された状態となっています。
ファイルを展開したディレクトリに合わせて設定ファイルを修正します。「Apache2.2\conf」ディレクトリに入っている「http.conf」ファイルをテキストエディタで開いて下さい。(心配であれば修正を行なう前のファイルをコピーしてバックアップを作成しておいて下さい)。
まず「c:/Apache2」となっている部分を「C:/pg/Apache/Apache2.2」に変更していきます。ご自身でファイルを展開されたディレクトリに合わせて変更して下さい。一箇所だけではないのでテキストエディタの置換などで行なわれるといいかと思います。
例えば35行目がデフォルトでは次のようになっていると思います。
# # ServerRoot: The top of the directory tree under which the server's # configuration, error, and log files are kept. # # Do not add a slash at the end of the directory path. If you point # ServerRoot at a non-local disk, be sure to point the LockFile directive # at a local disk. If you wish to share the same ServerRoot for multiple # httpd daemons, you will need to change at least LockFile and PidFile. # ServerRoot "C:/pg/Apache/Apache2.2"
これを次のように変更します。
# # ServerRoot: The top of the directory tree under which the server's # configuration, error, and log files are kept. # # Do not add a slash at the end of the directory path. If you point # ServerRoot at a non-local disk, be sure to point the LockFile directive # at a local disk. If you wish to share the same ServerRoot for multiple # httpd daemons, you will need to change at least LockFile and PidFile. # ServerRoot "C:/pg/Apache/Apache2.2"
同じファイル内にある他の箇所も同様に変更して下さい。(先頭が"#"で始まっている行はコメント行なので変更しなくても構いません)。
次にポート番号の設定を確認します。46行目付近を見てください。
# # Listen: Allows you to bind Apache to specific IP addresses and/or # ports, instead of the default. See also the# directive. # # Change this to Listen on specific IP addresses as shown below to # prevent Apache from glomming onto all bound IP addresses. # #Listen 12.34.56.78:80 Listen 80
使用するポート番号はデフォルトで80番となっています。通常はこれで問題ありませんが、既に他のアプリケーションで使用していると分かっている場合には変更して下さい。
最後に「ServerName」の設定です。172行目付近を見てください。
# # ServerName gives the name and port that the server uses to identify itself. # This can often be determined automatically, but we recommend you specify # it explicitly to prevent problems during startup. # # If your host doesn't have a registered DNS name, enter its IP address here. # #ServerName www.example.com:80
デフォルトでは省略されておりその場合は自動で取得されます。ただ明確に設定しておくことが推奨されています。公開サーバであればそのホスト名+ポート番号(ポート番号を省略した場合は先に設定した「Listen」に設定したポート番号が使用されます)を指定して下さい。ローカルで動かす場合は"localhost:80"や"127.0.0.1:80"を指定して下さい。
# # ServerName gives the name and port that the server uses to identify itself. # This can often be determined automatically, but we recommend you specify # it explicitly to prevent problems during startup. # # If your host doesn't have a registered DNS name, enter its IP address here. # #ServerName www.example.com:80 ServerName localhost
設定が終わりましたらファイルを保存しておいて下さい。これでApacheのインストールと事前準備は完了です。
( Written by T.buzz.Ikura+ )