ペチパーノート

WEB開発系Tipsブログです。

/でindex.phpを実行させる

先の記事でAWSLAMP環境を作成しました。
~AWSでLAMP環境を作る~ まとめ
 

今回はhttp://{IPアドレス or ドメイン}/
でindex.phpを動かせるようにします。

デフォルトでindex.htmlが出力されますが
存在しない場合、index.phpを実行させるようにApacheの設定を変更します。

手順

Apacheの設定ファイルを更新

# vi /etc/httpd/conf/httpd.conf

   

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
# The index.html.var file (a type-map) is used to deliver content-
# negotiated documents.  The MultiViews Option can be used for the
# same purpose, but it is much slower.
#
DirectoryIndex index.html index.html.var index.php ←index.phpを追加

※index.htmlよりもindex.phpを優先したい場合は
 index.phpをindex.htmlよりも左側に記述します。

   

  Apache再起動

service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

これでOKです。