Apacheドキュメントルートを変更

Amazon LinuxでApacheドキュメントルートを変更する方法です。

デフォルトでは、apacheのドキュメントルートは”/var/www/html”となっています。

先日の記事でWordPressのソースコードをBitbucketからApacheドキュメントルートにクローンしましたが、このままではWebサイトのURLが、

http://<ホスト名>/<WordPressリポジトリ名>

となります。

これを、

http://<ホスト名>

となるよう、apacheドキュメントルートを変更しましょう。

別に1.のままでも構わないよという方はこの記事はスキップして下さい。

お使いのエディタでapache設定ファイルを開きます。

sudo emacs /etc/httpd/conf/httpd.conf

DocumentRootを検索し、その値を以下のように変更します。

# DocumentRoot: The directory out of which you will serve your                  
# documents. By default, all requests are taken from this directory, but        
# symbolic links and aliases may be used to point to other locations.           
#                                                                               
# DocumentRoot "/var/www/html"                                                  
DocumentRoot "/var/www/html/<Wordpressリポジトリ名>"

保存して閉じます。

Apacheを再起動します。

sudo service httpd restart

ブラウザから「http://<ホスト名>」へアクセスしてみましょう。サイトが表示されるハズです。