環境設定4.httpd.confファイル


ApacheとPHP。それぞれをインストールしただけでは、プログラミングとしての動作を期待することはできません。プログラミングとして動作させるために、まずはWebサーバであるApache側で、PHPを認識してもらいます。


httpd.confファイル


ApacheとPHPは、モジュール形式で連動します。そのモジュール形式を設定するためにいじるのが、この「httpd.conf」ファイルです。これは、「Apache2.2」→「conf」フォルダの中に入っています。


「Apache2.2」→「conf」フォルダの中へ。


「httpd.conf」というファイルがあります。

httpd.confの設定


「httpd.conf」ファイルをメモ帳などのテキストエディタで開き、データを次のように書き換えていきましょう。ちなみに、緑の文字は注釈ですんで書き足す必要はありません。

≪拡張モジュール・ディレクトリ≫
# Dynamic Shared Object (DSO) Support
      |
LoadModule php5_module c:/php5/php5apache2_2.dll ←左記をLoadModule群の末尾に追記。「php5」のフォルダ内にあるモジュールを指定します。なお、Apacheのバージョンが「2.2」なので「php5apache2_2.dll」を指定することになります。


※「PHP5」フォルダに含まれる、Apache対応モジュール。インストールしたApacheのバージョンに対応したモジュールがあるかどうか、ちゃんと確かめておきましょう。

≪拡張モジュール・ディレクトリ詳細≫
PHPIniDir "c:/php5/" ←左記を追記。「php.ini」のあるフォルダ指定です。「php.ini」については、環境設定5を参照。
<Directory "C:/Apache2.2/htdocs">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride Options ←左記のとおり、「Options」を指定。

# # Controls who can get stuff from this server.
#
Order allow,deny
Allow from all

</Directory>

≪拡張モジュール・タイプ≫
# If the AddEncoding directives above are commented-out, then you
# probably should define those extensions to indicate media types:
#
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php ←左記のとおり、phpの仕様を指定。