0

I have loaded phpcgi.plist but php-fastcgi is not runing.

The plist file is:

Michaels-MacBook-Pro:~ michael$ ll com*
-rwxr--r--  1 michael  admin  664  4  7 13:40 com.phpfcgi.plist*

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

Linked it:

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

and I load it:

Michaels-MacBook-Pro:~ michael$ launchctl load -w Library/LaunchAgents/com.phpfcgi.plist
com.phpfcgi: Already loaded

and I check it:

Michaels-MacBook-Pro:~ michael$ ps -A | grep php
 1110 ttys000    0:00.00 grep php

NOT WORKING.

But I can start php fastcgi by run.

Michaels-MacBook-Pro:~ michael$ cat start_php-fastcgi
/usr/local/bin/php-cgi -q -b 127.0.0.1:9000 &
emj365
  • 2,028
  • 2
  • 19
  • 24

2 Answers2

1

There is a difference between loading and starting a job. Your job definition does not contain a run condition. You specified RunAtLoad false, telling launchd(8) to not run the job when it is loaded. If you did this on purpose you can run the job with launchctl start com.phpfcgi.

LCC
  • 1,175
  • 1
  • 10
  • 11
1

should no space between "-b" and the host (my system is osx 10.8)

I found a comment:

Thank you for this plist file! A lot of the tutorials show a space between "-b" and the host name and port. My process kept dying with a status of 255, until I removed that space. – Matt Aug 26 '12 at 16:24

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

It solved my problem.

The new 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>
Community
  • 1
  • 1
emj365
  • 2,028
  • 2
  • 19
  • 24
  • 1
    A space is ok on the command line, because the shell treats spaces as separators between arguments, and php-cgi will understand when "-b" and the host are passed as separate arguments. But in a launchd .plist, if you include a space in a string element of the ProgramArguments array, it's treated as part of the argument. So for launchd, either remove the space, or list -b and the host as separate strings. – Gordon Davisson Apr 08 '13 at 06:45
  • BTW: I removed the debug section, I think it's not the point for me. I just want to run php in Nginx for develop. – emj365 Apr 08 '13 at 06:52