MacOSのWebサーバー Apache へユーザーディレクトリを有効化

MacOSのWebサーバー Apache へユーザーディレクトリを有効化
設定ファイルをviで開いて編集

-----------------------------------------------------

sudo vi /private/etc/apache2/httpd.conf

-----------------------------------------------------

コメントアウトするか行を追加

 

-----------------------------------------------------

LoadModule userdir_module libexec/apache2/mod_userdir.so
LoadModule authz_core_module libexec/apache2/mod_authz_core.so
LoadModule authz_host_module libexec/apache2/mod_authz_host.so

# User home directories
Include /private/etc/apache2/extra/httpd-userdir.conf

-----------------------------------------------------

 

ユーザー個別の設定ファイルを追加

/etc/apache2/users/th.conf <= th はユーザー名なので、適宜置き換え

-----------------------------------------------------

DocumentRoot "/Users/th/Sites/"  <= th はユーザー名なので、適宜置き換え

<Directory "/Users/th/Sites"> <= th はユーザー名なので、適宜置き換え

   AddType text/html .shtml .html

   AddHandler server-parsed .shtml .html

   Options Indexes MultiViews FollowSymlinks Includes

   AllowOverride all

   Require all granted

</Directory>

-----------------------------------------------------

 

自分のディレクトリにドキュメントディレクトリをつくる

-----------------------------------------------------

mkdir /Users/th/Sites/

-----------------------------------------------------

 

 

 

 

編集後の設定ファイルの文法チェックを起動

-----------------------------------------------------

sudo apachectl -t 

-----------------------------------------------------

エラーが出なければ apache を再起動

 

-----------------------------------------------------

sudo apachectl restart

-----------------------------------------------------

 WebBrowserで動作確認

 

http://localhost/~th/

 

で接続できればOK