LoginSignup
23
21

More than 5 years have passed since last update.

MacOSX Yosemiteでlocalhostのドキュメントルートを変更する

Last updated at Posted at 2014-12-02

Yosemiteでlocalhostを使う場合はこちらが参考になるかもしれません→MacOS X の Yosemite (10.10) で Sites ディレクトリを使って localhost をアカウント別に利用する方法

ついでに、
MacOS X の Mavericks (10.9) で Sites ディレクトリを使って localhost をアカウント別に利用する方法

目標

/Users/USERNAME/Sites/public
ここをドキュメントルートにする

httpd.conf

以下二箇所を変更。

$ sudo vi /etc/apache2/httpd.conf
----
1.
#DocumentRoot "/Library/WebServer/Documents"
DocumentRoot "/Users/USERNAME/Sites/public"

2.
#<Directory "/Library/WebServer/Documents">
<Directory "/Users/USERNAME/Sites/public">

USERNAME.conf

$ sudo vi /etc/apache2/users/USERNAME.conf
<Directory "/Users/USERNAME/Sites/public">
    AllowOverride All
    Options Indexes FollowSymLinks Multiviews
    Require all granted
</Directory>

apachectl restart

$ sudo apachectl restart

テスト

該当のディレクトリになんか文字列を書いたindex.htmlでもおいて、http://localhost/index.htmlとか接続してみる。
index.htmlの内容が表示されたらOK

23
21
0

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
23
21