LoginSignup
10
4

More than 5 years have passed since last update.

概要

macOSのbrewでインストールしたapache httpdを開発で利用しやすように設定します。

http://localhost/でアクセスすると~/Sitesディレクトリの、ユーザー権限で編集できるファイルにアクセスされるようにします。

httpd.conf編集

/usr/local/etc/httpd/httpd.confを編集します。それぞれの字句を検索して該当箇所を変更してください。

ポート変更

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to 
# prevent Apache from glomming onto all bound IP addresses.
#
Listen 80

DocumentRoot

DocumentRootとその直後のDirectoryのディレクトリを変更します。
(下記のをls -d ~/Sitesで表示されるディレクトに変更します)

# 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 "/Users/<user>/Sites"
<Directory "/Users/<user>/Sites">

<Directory ...>の中のAllowOverrideallに変更

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride All

mod_rewrite

#を除去してアンコメントします。

LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so

User & Group

ユーザーとグループ名を変更。
これでユーザー権限でweb公開ファイルが編集できます。

User <user>
Group staff

ServerName

サーバー名をlocalhostに

ServerName localhost

以上で設定完了です。

確認

apacheをリスタートさせ http://localhost/ で確認してみましょう。

sudo apachectl -k restart

以下のwebページが表示されます。 1

image.png

関連


  1. ちなみにiWebは2011年に開発終了してます... 

10
4
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
10
4