&tag(Homebrew/apache);
*目次 [#k3bbf3df]
#contents
*参考情報 [#v5a49fd8]
-[[Homebrew]]
-[[./古い情報20140426]]

*インストール [#yb2943dd]

**バージョン2.2のインストール [#v90c8087]
-tap実行
 brew tap homebrew/apache
-バージョン2.2をインストール
 brew install httpd22
-次のような指示が表示される。
#pre{{
To have launchd start httpd22 at login:
    ln -sfv /usr/local/opt/httpd22/*.plist ~/Library/LaunchAgents
Then to load httpd22 now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.httpd22.plist
}}

**古い方法 [#w9352f71]
-tapが必要
#pre{{
$ brew tap homebrew/dupes
$ brew install httpd
}}
-次のようなインストラクションが表示される
-次のような指示が表示される。
#pre{{
You should reload httpd:
    launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.httpd.plist
To have launchd start httpd at login:
    ln -sfv /usr/local/opt/httpd/*.plist ~/Library/LaunchAgents
Then to load httpd now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.httpd.plist
}}
*設定ファイルなど [#s415330a]
-/usr/local/etc/apache2/httpd.conf を編集する。
*起動 [#t209dc83]
-デフォルト設定のポート80で動かす場合root権限が必要。この場合rootで起動するために/Library/LaunchAgentsにplistのシンボリックリンクを貼る
 sudo cd /Library/LaunchAgents
 sudo ln -s /Library/LaunchAgents/homebrew.mxcl.httpd.plist
 sudo chown root:wheel homebrew.mxcl.httpd.plist
 sudo launchctl load -w /Library/LaunchAgents/homebrew.mxcl.httpd.plist

-一般ユーザーで動かす場合
 launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.httpd.plist
*未確認情報[#i738145d]
**brew servicesって何? [#icb13c46]
-以下のコマンドを実行すると/Library/LaunchDaemonsにplistが作られる。
 sudo brew services start httpd
-/Library/LaunchAgents/homebrew.mxcl.httpd.plistが作られる。これを使えばroot起動が簡単?
 sudo launchctl load  -w /Library/LaunchAgents/homebrew.mxcl.httpd.plist
*設定 [#s9b8fc7a]

**run、logディレクトリが作られない? [#k662a466]
※[[httpd log and run directories not being created · Issue #119 · Homebrew/homebrew-dupes · GitHub:https://github.com/Homebrew/homebrew-dupes/issues/119]]に、run、logディレクトリが作られず起動できないエラーが報告されている。手動でディレクトリを作らないとだめかも(と思ったけど、rootで起動すれば大丈夫かも。場所は/usr/local/var/apache2/log)。
**自動起動設定 [#e8aa8be3]

*トラブルシューティング [#laa2340b]
**ユーザーディレクトリにアクセスできない。 [#nd11dfc3]
-extra/httpd-userdir.confがまちがっていないか確認する。
-初期状態だと、UserDir public_html、Directory /home/*/public_htmlになっていた。当然こんなフォルダMacには存在しないのでエラーになる。MacPortsと同じにしたい場合次のように、UserDirとDirectoryを療法変更する。
-デフォルトのapacheを無効にしておく
 sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
***ポート80で自動起動する(実効ユーザーは自分 or www) [#p7ccf0c0]
-rootユーザーで動かしたい場合、plistを/Library/LaunchDaemons以下にコピーする必要がある
 sudo cp /usr/local/opt/httpd22/homebrew.mxcl.httpd22.plist /Library/LaunchDaemons
-設定ファイル/usr/local/etc/apache2/httpd.confを編集する。
-ポート番号を80に変更
-ユーザーの変更
--自分の場合
#pre{{
User sora
Group staff
}}
--実効ユーザーをwwwにする場合は以下。
#pre{{
User www
Group www
}}
-launchctlで設定する。
 sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.httpd22.plist


※ちなみに「sudo brew services start httpd」でいけそうに思えるがうまくいかない。
-brew services start httpdは、homebrew.mxcl.httpd.plistを改変してから /Library/LaunchDaemons/homebrew.mxcl.httpd.plistへコピーする。
-このときUserNameにsoraという値が設定されてしまい、rootで起動する設定にもかかわらず一般ユーザー起動扱いになり、ポート80で動かなくなる。
-brew-services.rbを読む限り仕様っぽいがとにかくこのままでは使えない。
** ユーザーディレクトリを有効化 [#p1310a99]
-httpd.confで以下をコメントアウト
#pre{{
# User home directories
Include /usr/local/etc/apache2/2.2/extra/httpd-userdir.conf
}}
-httpd-userdir.confを編集。
#pre{{
UserDir Sites

#
# Control access to UserDir directories.  The following is an example
# for a site where these directories are restricted to read-only.
#
<Directory "/Users/*/Sites">
    AllowOverride FileInfo AuthConfig Limit Indexes
    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
    <Limit GET POST OPTIONS>
        Order allow,deny
        Allow from all
    </Limit>
    <LimitExcept GET POST OPTIONS>
        Order deny,allow
        Deny from all
    </LimitExcept>
</Directory>
}}

*トラブルシューティング [#cab86675]
**知らないhttpdが動いていた? [#hff9bb22]
-パスの関係で、デフォルトのapachectrlを動かしてしまったのかも。/usr/local/binがパスの戦闘にあることを確認する。


トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS