进入目录:

cd ~/Library/LaunchAgents

编辑文件:

vim php-fpm.plist

<plist version="1.0">
  <dict>
    <key>KeepAlive</key>
    <true/>
    <key>Label</key>
    <string>homebrew.mxcl.php</string>
    <key>ProgramArguments</key>
    <array>
      <string>/usr/local/opt/php/sbin/php-fpm</string>
      <string>--nodaemonize</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>WorkingDirectory</key>
    <string>/usr/local/var</string>
    <key>StandardErrorPath</key>
    <string>/usr/local/var/log/php-fpm.log</string>
  </dict>
</plist>

手动启动&关闭

launchctl load -w ~/Library/LaunchAgents/php-fpm.plist

launchctl unload -w ~/Library/LaunchAgents/php-fpm.plist