I am going to write a little bit more of my PHP/Apache setup later. But here is the script (fpmctl
) I use to start/stop PHP-FPM. It’s pretty much based off apachectl
on OS X. The usage is simular … and eq. simple.
fpmctl [start|stop|restart|graceful etc ...]
I’m not sure if it would work in a Linux environment, but I guess it could be tweaked quite easy. I haven’t tested that yet. Anyway… On OS X there are 2 parts. One LaunchDaemon and this script.
fpmctl
Let’s start with the script. Save this as fpmctl
in the same folder as php-fpm
. For me that is:
/usr/local/php56/sbin/fpmctl
That will keep the script within PATH
… assuming your PHP isnstallation is listed there.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|
For this you need Links
installed and to setup the FPM status page properly. Adjust the values/path/programs to match your installation/setup.
Make sure to set owner and permissions:
sudo chown root:wheel /usr/local/php56/sbin/fpmctl
sudo chmod +x /usr/local/php56/sbin/fpmctl
LaunchDaemon
The LaunchDaemon I use is placed in:
/System/Library/LaunchDaemons/net.php.php-fpm.plist
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
|
There are bits and pieces that are leftovers… I’ve kept them there for now.
To load/unload it…
sudo launchctl load -w /System/Library/LaunchDaemons/net.php.php-fpm.plist
sudo launchctl unload -w /System/Library/LaunchDaemons/net.php.php-fpm.plist
Like before. Adjust the values/path/programs to match your installation/setup. Paths to program(s), logs etc. You also need to edit your php-fpm.conf
to match status, ping, logs etc…
Locations
If you wonder about the names/locations of the different files/scripts… I’ll write a post on my setup later on, but for all status pages I have adjusted the default pattern to include ap24
and p56
. Just to make it reasier to remember and to use.
It looks a little bit like this:
# Apache 2.4.12
{address}/ap24 # Apache 2.4 Manual (local)
{address}/ap24/status # Apache Server Status for {address} (via 127.0.0.1)
{address}/ap24/info # Apache Server Information
# PHP 5.6.7
{address}/p56/ # PHP-FPM real-time status page
{address}/p56/status # PHP-FPM status page (text-only)
{address}/p56/ping # pong
So, to avoid name conflicts I use /ap24
and /p56
. The other version of PHP (5.4.*) is an Apache module (mpd_php
).
Perhaps I should put these scripts in a repo on Github?