我已经加载了phpcgi.plist但是php-fastcgi没有运行。
plist文件是:
Michaels-MacBook-Pro:~ michael$ ll com*
-rwxr--r-- 1 michael admin 664 4 7 13:40 com.phpfcgi.plist*
plist XML:
Michaels-MacBook-Pro:~ michael$ cat com.phpfcgi.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>Debug</key>
<false/>
<key>EnvironmentVariables</key>
<dict>
<key>PHP_FCGI_CHILDREN</key>
<string>2</string>
<key>PHP_FCGI_MAX_REQUESTS</key>
<string>1000</string>
</dict>
<key>Label</key>
<string>com.phpfcgi</string>
<key>OnDemand</key>
<false/>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/php-cgi</string>
<string>-b 127.0.0.1:9000</string>
<string>-q</string>
</array>
<key>RunAtLoad</key>
<false/>
</dict>
</plist>
链接它:
Michaels-MacBook-Pro:~ michael$ ll Library/LaunchAgents/com.phpfcgi.plist
lrwxr-xr-x 1 michael admin 47 4 7 13:27 Library/LaunchAgents/com.phpfcgi.plist@ -> /Volumes/MainHD/Users/michael/com.phpfcgi.plist
然后加载它:
Michaels-MacBook-Pro:~ michael$ launchctl load -w Library/LaunchAgents/com.phpfcgi.plist
com.phpfcgi: Already loaded
我检查一下:
Michaels-MacBook-Pro:~ michael$ ps -A | grep php
1110 ttys000 0:00.00 grep php
不工作。
但是我可以通过运行启动php fastcgi。
Michaels-MacBook-Pro:~ michael$ cat start_php-fastcgi
/usr/local/bin/php-cgi -q -b 127.0.0.1:9000 &
答案 0 :(得分:1)
加载和启动作业之间存在差异。您的作业定义不包含运行条件。您指定了RunAtLoad false
,告诉launchd(8)
在加载作业时不运行该作业。如果您故意这样做,可以使用launchctl start com.phpfcgi
运行作业。
答案 1 :(得分:1)
“ - b”与主机之间不应有空格(我的系统是osx 10.8)
我发现了一条评论:
感谢您提供这个plist文件!很多教程都在“-b”和主机名和端口之间显示了一个空格。我的进程一直处于255状态,直到我删除了那个空间。 - 马特2012年8月26日16:24
来自OS X: Auto start PHP FCGI via launchd on system start
它解决了我的问题。
新的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>EnvironmentVariables</key>
<dict>
<key>PHP_FCGI_CHILDREN</key>
<string>2</string>
<key>PHP_FCGI_MAX_REQUESTS</key>
<string>1000</string>
</dict>
<key>Label</key>
<string>com.phpfcgi</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/opt/php54/bin/php-cgi</string>
<string>-b127.0.0.1:9000</string>
<string>-q</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>