OS X: Auto start PHP FCGI via launchd on system st

2019-04-01 05:06发布

问题:

So, I installed PHP5 FCGI from MacPorts along with nginx and mysql. Last two are loading fine during system start. But PHP doesn't. I created a file /opt/local/etc/LaunchDaemons/org.macports.php5/org.macports.php5-cgi.plist and put this contents to it:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>org.macports.php5-cgi</string>
  <key>ProgramArguments</key>
  <array>
    <string>/opt/local/bin/php-cgi</string>
    <string>-b127.0.0.1:9000</string>
    <string>-q</string>
  </array>
  <key>EnvironmentVariables</key>
  <dict>
    <key>PHP_FCGI_CHILDREN</key>
    <string>8</string>
    <key>PHP_FCGI_MAX_REQUESTS</key>
    <string>256</string>
  </dict>
  <key>Debug</key><false/>
  <key>Disabled</key><true/>
  <key>KeepAlive</key><true/>
</dict>
</plist>

But it won't start on load. I need to execute sudo launchctl load -w /opt/... to start it manually.

回答1:

launchd doesn't read files from /opt/local/etc/LaunchDaemons. Put the file in /Library/LaunchDaemons, and remove the Disabled key.



标签: php launchd