Apache 2.2.17 インストールと設定

スポンサーリンク

■WordPress をローカル環境で構築しようと思ったのだが、うまく動作してくれなかった。
うまくいかないついでに、Apache 2.2.17 をインストールした。
(それまでは Apache2.0.55 を使用していた。)
ダウンロードから設定までの覚え書き。

■ダウンロード
http://httpd.apache.org/ より「httpd-2.2.17-win32-x86-openssl-0.9.8o.msi」をダウンロード。

Apache 2.2.17 ダウンロード Apache 2.2.17 ダウンロード Apache 2.2.17 ダウンロード

■インストール
「httpd-2.2.17-win32-x86-openssl-0.9.8o.msi」をダブルクリックしてあとは指示に従う。
インストール場所だけをデフォルトから変更した。

■設定
以前のバージョン Apache 2.2.17 は「httpd.conf」だけを変更したのだが、今回はそれに加え conf フォルダ内の「mime.types」と conf/extra フォルダ内の「extra/httpd-languages.conf」も変更した。

● httpd.conf の設定

  • mod_rewriteの設定(WordPress パーマリンク設定のため。)
    LoadModule rewrite_module modules/mod_rewrite.so
  • Apache ハンドラとしてのインストール
    PHPIniDir “C:/anton/php/”
    LoadModule php5_module C:/anton/php/php5apache2_2.dll
    <FilesMatch \.php$>
    SetHandler application/x-httpd-php
    </FilesMatch>
    ここに解説あり http://php.net/manual/ja/install.windows.apache2.php
  • ServerName の設定
    ServerName localhost:80
  • DocumentRoot の設定
    DocumentRoot “e:\foo\bar”
    ここを変更する時は次の場所も変更すること。
  • documentRoot の変更
    <Directory “e:\foo\bar”>
  • AllowOverrideの設定 (WordPress パーマリンク設定のため。)
    AllowOverride All
  • DirectoryIndex の設定
    <IfModule dir_module>
    DirectoryIndex index.html index.htm index.php index.html.var
    </IfModule>
  • AddType の設定
    AddHandler cgi-script .cgi
    AddType application/x-httpd-php .php
    PHPIniDir “C:/anton/php/”
  • SSL を使うための設定 (とりあえず必要ないと思うが一応。)
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml .html
  • 関連ファイルの読み込み
    # Language settings
    Include conf/extra/httpd-languages.conf

● conf/mime.types の設定

  • PHP 関連に関連する拡張子の定義設定
    末尾に次の2行を追加。

    application/x-httpd-php php
    application/x-httpd-php-source phps

● conf/extra/httpd-languages.conf の設定

  • 既定の言語を日本語にする
    DefaultLanguage ja
  • 既定の文字コード設定 (※ Shift-JIS では文字化けする。)
    AddDefaultCharset SJIS

Pocketstudio’z log さんの記事を参考にさせて頂いた。
http://pocketstudio.jp/log2/2007/01/windows_apache_224_php_520.html

コメント