OS X:在系统启动时通过launchd自动启动PHP FCGI

时间:2011-10-12 14:06:09

标签: php launchd

所以,我从MacPorts安装了PHP5 FCGI以及nginx和mysql。最后两个在系统启动期间正常加载。但PHP没有。我创建了一个文件/opt/local/etc/LaunchDaemons/org.macports.php5/org.macports.php5-cgi.plist并将此内容放入其中:

<?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>

但它不会在加载时启动。 我需要执行sudo launchctl load -w /opt/...手动启动它。

1 个答案:

答案 0 :(得分:3)

launchd不会从/opt/local/etc/LaunchDaemons读取文件。将文件放入/Library/LaunchDaemons,然后移除Disabled键。