How do you restart php-fpm?

Solution 1:

Note: prepend sudo if not root

  • Using SysV Init scripts directly:

    /etc/init.d/php-fpm restart    # typical
    /etc/init.d/php5-fpm restart   # debian-style
    /etc/init.d/php7.0-fpm restart # debian-style PHP 7
    
  • Using service wrapper script

    service php-fpm restart    # typical
    service php5-fpm restart   # debian-style
    service php7.0-fpm restart # debian-style PHP 7
    
  • Using Upstart (e.g. ubuntu):

    restart php7.0-fpm         # typical (ubuntu is debian-based) PHP 7
    restart php5-fpm           # typical (ubuntu is debian-based)
    restart php-fpm            # uncommon
    
  • Using systemd (newer servers):

    systemctl restart php-fpm.service    # typical
    systemctl restart php5-fpm.service   # uncommon
    systemctl restart php7.0-fpm.service # uncommon PHP 7
    

Or whatever the equivalent is on your system.

Solution 2:

For Mac OS X, this is what I do:

Make a script /usr/local/etc/php/fpm-restart:

#!/bin/sh

echo "Stopping php-fpm..."
launchctl unload -w ~/Library/LaunchAgents/homebrew-php*.plist

echo "Starting php-fpm..."
launchctl load -w ~/Library/LaunchAgents/homebrew-php*.plist

echo "php-fpm restarted"
exit 0

Then:

chmod ug+x /usr/local/etc/php/fpm-restart
cd /usr/local/sbin
ln -s /usr/local/etc/php/fpm-restart

make sure /usr/local/sbin is in your $PATH

then just call it from the terminal fpm-restart and BOOM!!