mac 初期設定 part9 - Apache と MySQL の自動起動設定
~/Library/LaunchAgentsにシンボリックリンクをはる。
$ ln -sfv /usr/local/opt/httpd/*.plist ~/Library/LaunchAgents
/Users/username/Library/LaunchAgents/homebrew.mxcl.httpd.plist -> /usr/local/opt/httpd/homebrew.mxcl.httpd.plist
OS起動時にApacheを自動で起動する。
$ sudo launchctl load ~/Library/LaunchAgents/homebrew.mxcl.httpd.plist
Password:
launchctl: Dubious ownership on file (skipping): /Users/username/Library/LaunchAgents/homebrew.mxcl.httpd.plist
nothing found to load
なんかエラーっぽい。。
plistファイルの権限をroot:wheelにする必要があるとか・・・。
$ sudo chown root:wheel ~/Library/LaunchAgents/homebrew.mxcl.httpd.plist
で、リトライ!
$ sudo launchctl load ~/Library/LaunchAgents/homebrew.mxcl.httpd.plist
$ sudo apachectl restart
うまくいったっぽいです。
~/Library/LaunchAgentsにシンボリックリンクをはる。
$ ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
/Users/username/Library/LaunchAgents/homebrew.mxcl.mysql.plist -> /usr/local/opt/mysql/homebrew.mxcl.mysql.plist
一度再起動して確認しましょう!
OSを再起動してみて、ApacheとMySQLが動いていればOK!
のはずが・・・Apacheが起動されない><。
MySQLは起動してるのに。
いろいろ調べた結果、 /System/Library/LaunchDaemonsにシンボリックリンクを張れば良さそうです。
$ sudo ln -sfv /usr/local/opt/httpd/*.plist /System/Library/LaunchDaemons
Password:
/System/Library/LaunchDaemons/homebrew.mxcl.httpd.plist -> /usr/local/opt/httpd/homebrew.mxcl.httpd.plist
$ sudo apachectl restart
OS再起動して、
username 437 0.1 0.0 2432784 604 s000 S+ 12:44AM 0:00.00 grep httpd
daemon 151 0.0 0.0 2478244 780 ?? S 12:43AM 0:00.00 /usr/local/Cellar/httpd/2.2.26/sbin/httpd -k start
daemon 150 0.0 0.0 2478244 760 ?? S 12:43AM 0:00.00 /usr/local/Cellar/httpd/2.2.26/sbin/httpd -k start
daemon 149 0.0 0.0 2478244 816 ?? S 12:43AM 0:00.00 /usr/local/Cellar/httpd/2.2.26/sbin/httpd -k start
daemon 148 0.0 0.0 2478244 736 ?? S 12:43AM 0:00.00 /usr/local/Cellar/httpd/2.2.26/sbin/httpd -k start
daemon 147 0.0 0.0 2478244 784 ?? S 12:43AM 0:00.00 /usr/local/Cellar/httpd/2.2.26/sbin/httpd -k start
daemon 140 0.0 0.0 2467084 736 ?? S 12:43AM 0:00.00 /usr/local/Cellar/httpd/2.2.26/sbin/httpd -k start
root 139 0.0 0.2 2478244 7820 ?? Ss 12:43AM 0:00.21 /usr/local/Cellar/httpd/2.2.26/sbin/httpd -k start