LoginSignup
2

More than 5 years have passed since last update.

OSをEl Capitanにアップデートしたらlocalhostで404エラーになる

Last updated at Posted at 2016-04-05

はじめに

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にアクセスすると、問題なく表示されてます!

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2