拡張子の登録
PHPで使う拡張子(.php)とPHPを関連付けます。例えば「a.php」というファイルへアクセスがあった場合に、ファイルに記述された内容をそのまま返すのではなく、PHPで実行した結果を返すようになります。
「httpd.conf」ファイルで「AddType」で検索して下さい。デフォルトでは369行目付近に次のような記述があります。
# # AddType allows you to add to or override the MIME configuration # file specified in TypesConfig for specific file types. # #AddType application/x-gzip .tgz # # AddEncoding allows you to have certain browsers uncompress # information on the fly. Note: Not all browsers support this. # #AddEncoding x-compress .Z #AddEncoding x-gzip .gz .tgz # # 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
上記の一番最後に次の2行を追加して下さい。
AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps
これで拡張子が「.php」のファイルへアクセスがあった場合にPHPプログラムとして処理した結果を返すようになります。