phpmacosnginxlaunchdlaunchdagent

PHP Fast CGI on mac osx - phpfcgi.plist not runing by load, not runing by reboot neither


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 &

Solution

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