はじめに
MacのOSをEl Capitanにアップデート後、localhostにアクセスしたするとなぜか404エラーになってしまったのでその時の対処法をまとめます。
対処法
とりあえずhttpd.conf
が怪しいと思い、ファイルの更新日時を見てみる。
$ la /private/etc/apache2
total 168
drwxr-xr-x 16 root wheel 544B 4 5 17:37 extra
-rw-r--r-- 1 root wheel 20K 4 5 17:34 httpd.conf
-rw-r--r-- 1 root wheel 20K 8 1 2015 httpd.conf.pre-update
-rw-r--r-- 1 root wheel 20K 2 18 20:12 httpd.conf~previous
-rw-r--r-- 1 root wheel 13K 8 1 2015 magic
-rw-r--r-- 1 root wheel 52K 8 1 2015 mime.types
drwxr-xr-x 4 root wheel 136B 8 1 2015 original
drwxr-xr-x 3 root wheel 102B 8 1 2015 other
drwxr-xr-x 4 root wheel 136B 4 5 17:36 users
なんと、OSアップデート時にhttpd.conf
も上書きされてしまうんですね。。
変更箇所
$ sudo vim /private/etc/apache2/httpd.conf
ということでhttpd.conf
の236行目〜237行目あたりのDocumentRootを今まで設定していた場所に変更します。
DocumentRoot "/Users/[username]/hogehoge"
<Directory "/Users/[username]/hogehoge">
httpd.conf
を保存して、問題ないかをテストした後、apacheの再起動を行います。
$ sudo apachectl configtest
$ sudo apachectl restart
http://localhost/hogehoge
にアクセスすると、問題なく表示されてます!