SnapOverflow

SnapOverflow Logo SnapOverflow Logo

SnapOverflow Navigation

  • Home
  • Server
  • Ubuntu

Mobile menu

Close
  • Home
  • System Administrators
    • Hot Questions
    • New Questions
    • Tags
  • Ubuntu
    • Hot Questions
    • New Questions
    • Tags
  • Help
Home / server / Questions / 189940
Accepted
Galen
Galen
Asked: 2010-10-12 17:58:12 +0800 CST2010-10-12 17:58:12 +0800 CST 2010-10-12 17:58:12 +0800 CST

How do you restart php-fpm?

  • 772
Locked. This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions.

I need to reload my php.ini and there's nothing in the help dialog about restarting it.

php nginx php5 php-fpm
  • 18 18 Answers
  • 994263 Views

18 Answers

  • Voted
  1. Best Answer
    tylerl
    2010-10-12T19:37:32+08:002010-10-12T19:37:32+08:00

    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.

    • 335
  2. Diego Antunes
    2013-09-23T20:55:13+08:002013-09-23T20:55:13+08:00

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

    • 30
  3. BurninLeo
    2014-08-09T03:55:47+08:002014-08-09T03:55:47+08:00

    Usually, service php5-fpm restart will do fine, on an up-to-date distribution.

    But somtimes, it fails, telling you restart: Unknown instance: (or such).

    Now, if you do not like to reboot your server, just kill the processes and have a fresh start (edited as of here):

    $ sudo pkill php5-fpm; sudo service php5-fpm start
    
    • 22
  4. dialt0ne
    2011-02-02T12:08:49+08:002011-02-02T12:08:49+08:00

    This should work:

    pkill -o -USR2 php-fpm
    pkill -o -USR2 php5-fpm
    
    • 13
  5. Blake Frederick
    2015-12-31T13:25:27+08:002015-12-31T13:25:27+08:00

    For Mac OSX brew services restart php56 worked for me.

    • 12
  6. Gediminas
    2017-03-27T00:57:31+08:002017-03-27T00:57:31+08:00

    I had a problem restarting php7-fpm, because I didn't knew how exactly the service was named. This function gave me the answer:

    service --status-all

    php7-fpm service in my Ubuntu was called php7.0-fpm, so I did:

    service php7.0-fpm restart

    • 11
  7. Pitarou
    2014-03-12T23:01:35+08:002014-03-12T23:01:35+08:00

    php-fpm will restart if you send a USR2 signal to the main process:

    sudo kill -USR2 php-fpm_main_process_id
    

    So we just need to instruct php-fpm to record its pid somewhere. In this example, I'll assume you want to save it at /etc/private/php-fpm.pid, and that php-fpm runs as user _php. First, add this line to the configuration file:

    pid = /etc/php-fpm.pid
    

    Then create the file /etc/php-fpm.pid, and make sure php-fpm has permission to modify it:

    $ cd /etc
    $ sudo touch php-fpm.pid
    $ sudo chown _php php-fpm.pid
    $ sudo chmod 644 php-fpm.pid
    

    Now, next time php-fpm starts, you'll be able to get its pid and restart it like this:

    $ cat /etc/php-fpm.pid
    815
    $ sudo kill -USR2 815
    

    Or you can combine these into a single command:

    $ sudo kill -USR2 `cat /etc/private/php-fpm.pid`
    
    • 6
  8. Pooch
    2013-09-26T11:24:40+08:002013-09-26T11:24:40+08:00

    For me I had just upgraded via apt and the service restart wasn't working. I ended up needing to kill the existing processes before it worked using: killall php5-fpm

    • 3
  9. Danack
    2013-05-12T07:03:14+08:002013-05-12T07:03:14+08:00

    To allow the PHP-FPM restart script to work, you must use specify a PID file in your php-fpm.conf file. i.e.

    pid = /var/run/php-fpm/php-fpm.pid
    

    The default value for pid in php-fpm.conf is nothing, which means to not create a PID file, which means that the restart script can't tell which process to end during the restart.

    • 2
  10. Fokwa Best
    2016-06-29T02:44:48+08:002016-06-29T02:44:48+08:00

    On CentOS 7

    sudo systemctl enable php-fpm // Just incase is disabled. Also ensures it starts automatically with the server
    
    sudo systemctl start php-fpm  // Start the service
    
    sudo systemctl stop php-fpm   // Stop the service
    
    sudo systemctl status php-fpm  // View status
    
    • 2

Sidebar

Stats

  • Questions 681965
  • Answers 980273
  • Best Answers 280204
  • Users 287326
  • Popular
  • Answers
  • Marko Smith

    Ping a Specific Port

    • 18 Answers
  • Marko Smith

    How do I tell Git for Windows where to find my private RSA key?

    • 30 Answers
  • Marko Smith

    How do you restart php-fpm?

    • 18 Answers
  • Marko Smith

    What's the default superuser username/password for postgres after a new install?

    • 5 Answers
  • Marko Smith

    What port does SFTP use?

    • 6 Answers
  • Marko Smith

    Resolve host name from IP address

    • 8 Answers
  • Marko Smith

    How can I sort du -h output by size

    • 30 Answers
  • Marko Smith

    Command line to list users in a Windows Active Directory group?

    • 9 Answers
  • Marko Smith

    What is a Pem file and how does it differ from other OpenSSL Generated Key File Formats?

    • 3 Answers
  • Marko Smith

    How to determine if a bash variable is empty?

    • 15 Answers
  • Martin Hope
    Davie Ping a Specific Port 2009-10-09 01:57:50 +0800 CST
  • Martin Hope
    binaryorganic How do I tell Git for Windows where to find my private RSA key? 2010-10-26 08:45:39 +0800 CST
  • Martin Hope
    tobym What exactly do the colors in htop status bars mean? 2010-09-14 12:22:43 +0800 CST
  • Martin Hope
    MikeN In Nginx, how can I rewrite all http requests to https while maintaining sub-domain? 2009-09-22 06:04:43 +0800 CST
  • Martin Hope
    Tom Feiner How can I sort du -h output by size 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    0x89 What is the difference between double and single square brackets in bash? 2009-08-10 13:11:51 +0800 CST
  • Martin Hope
    Kyle Brandt How does IPv4 Subnetting Work? 2009-08-05 06:05:31 +0800 CST
  • Martin Hope
    Noah Goodrich What is a Pem file and how does it differ from other OpenSSL Generated Key File Formats? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent How to determine if a bash variable is empty? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus How do you find what process is holding a file open in Windows? 2009-05-01 16:47:16 +0800 CST

Related Questions

Trending Tags

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • Home
  • Questions
    • Hot Questions
    • New Questions
  • Tags
  • Help

Footer

SnapOverflow

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy

Help

© 2022 SOF-TR. All Rights Reserve