「MacbookにLAMP環境を構築」を参考に、HomebrewでMavericks (10.9.2) にインストールしたApacheを自動起動しようとしたがうまくいかない (正確に言えば、ちょっと前まで動いていたが、なぜかうまく動かなくなった)。手続きは簡単で、
$ sudo cp /usr/local/opt/httpd/*.plist /Library/LaunchDaemons $ sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.httpd.plist
の2行を実行するだけ。ところがある時から再起動時にsudo apachectl startなどとしないとApacheが起動しなくなってしまった。再起動後に「$ sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.httpd.plist」とやると、「homebrew.mxcl.httpd: Already loaded」と言われるのでロードはされているのだろう。
となると、ロードされるhomebrew.mxcl.httpd.plistの中身が気になる。ということで、中身を見てみた。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>homebrew.mxcl.httpd</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/opt/httpd/sbin/apachectl</string>
<string>start</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
こんな感じ。これを以下のように書き換えてみた。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>Label</key>
<string>homebrew.mxcl.httpd</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/opt/httpd/sbin/apachectl</string>
<string>start</string>
</array>
<key>OnDemand</key>
<false/>
</dict>
</plist>
変更点はDisabledをfalse、OnDemandをfalseにしたところ。これで再起動時にきちんとApacheが立ち上がるようになった。