OS X:在系统启动时通过 launchd 自动启动 PHP FCGI
因此,我从 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/... 来手动启动它。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
launchd 不会从
/opt/local/etc/LaunchDaemons
读取文件。将文件放入/Library/LaunchDaemons
中,然后删除Disabled
键。launchd doesn't read files from
/opt/local/etc/LaunchDaemons
. Put the file in/Library/LaunchDaemons
, and remove theDisabled
key.