I need to reload my php.ini and there's nothing in the help dialog about restarting it.
18 Answers
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 7Using service wrapper script
service php-fpm restart # typical service php5-fpm restart # debian-style service php7.0-fpm restart # debian-style PHP 7Using 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 # uncommonUsing 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.
- 2What about on a Mac? php-fpm was installed using homebrew.
which php-fpmgives/usr/local/sbin/php-fpm.hobbes3– hobbes32013-03-16 23:06:58 +00:00Commented Mar 16, 2013 at 23:06 - 6@hobbes3 try
brew services restart php56(if you get an error about no available formula, try a different version e.g. php5 or php55). If you don't have brew services installed, it should install it for you on the first run.Doktor J– Doktor J2015-12-21 22:22:51 +00:00Commented Dec 21, 2015 at 22:22 - None of the above worked for me, but this did:
service php-fcgi-mydomain-com restartAnd I had to repeat it for every domain from sites-enabledIlyich– Ilyich2018-03-12 19:01:20 +00:00Commented Mar 12, 2018 at 19:01 - This one was the good one for me (centOs) :
systemctl reload php70-php-fpm4wk_– 4wk_2018-07-25 12:58:52 +00:00Commented Jul 25, 2018 at 12:58 - I'm on Ubuntu 16.04 and this seemed to work:
systemctl restart php5.6-fpm.servicerelipse– relipse2018-12-07 19:36:51 +00:00Commented Dec 7, 2018 at 19:36
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!!
- 4Use
homebrew.mxcl.php*.plistif it doesn't workDaniil Ryzhkov– Daniil Ryzhkov2015-08-11 20:21:32 +00:00Commented Aug 11, 2015 at 20:21 - github.com/Homebrew/homebrew-php#installing-multiple-versions is case you can't find ths .plist file.Frank Fang– Frank Fang2016-09-05 01:22:36 +00:00Commented Sep 5, 2016 at 1:22
- brew services basically does what your script does.Qiulang 邱朗– Qiulang 邱朗2019-01-23 07:58:25 +00:00Commented Jan 23, 2019 at 7:58
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 - Thanks, this fixed exactly my issue. (
stop: Unknown instance:)Nilloc– Nilloc2016-08-31 15:00:09 +00:00Commented Aug 31, 2016 at 15:00
This should work:
pkill -o -USR2 php-fpm pkill -o -USR2 php5-fpm - 3If you installed PHP-FPM via homebrew on a Mac, the first command works a lot better than unload+load'ing the plistAlan Ivey– Alan Ivey2013-07-19 21:01:18 +00:00Commented Jul 19, 2013 at 21:01
-
- On OSX the above gave me an error "Unknown user SR2". Reversing the arguments fixed it: "pkill -USR2 -o php-fpm"Keeth– Keeth2015-01-09 11:44:19 +00:00Commented Jan 9, 2015 at 11:44
- Exactly what I needed to restart FPM in a container, thanks!Adrian Günter– Adrian Günter2015-10-27 00:32:24 +00:00Commented Oct 27, 2015 at 0:32
- I am using the pre-installed, or bundled with xcode, version of php and its associated -fpm for some reason, and not through Homebrew. Just thought I should use what's there already. I am using a combination of
php-fpm --prefix /usr/local, making some directories under that one it needs, and as @Keeth has stated,pkill -USR2 -o php-fpm, checking withpgrep -l fpm, and the PIDs do indeed change! I had no plist files or services to take advantage of mentioned by some of the other answers.Pysis– Pysis2017-08-10 03:41:43 +00:00Commented Aug 10, 2017 at 3:41
For Mac OSX brew services restart php56 worked for me.
- 1yup, works for me also. Mac osxMike Nguyen– Mike Nguyen2017-05-24 05:15:49 +00:00Commented May 24, 2017 at 5:15
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
- 5
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` - I am liking @dialt0ne's and @Keeth's
pkill ...answer & comment above more; shorter and simpler.Pysis– Pysis2017-08-10 03:43:59 +00:00Commented Aug 10, 2017 at 3:43 - this is better, and nice explanation. the pkill runs the risk, if you don't get the processes matched correctly, of killing off your other PHP clusters if you happen to have them running on the same box (yes this is bad practice).Richard– Richard2017-10-30 16:47:00 +00:00Commented Oct 30, 2017 at 16:47
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
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.
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 On RedHat / CentOS 7 using PHP 7 from softwarecollections.org
service rh-php70-php-fpm start service rh-php70-php-fpm stop service rh-php70-php-fpm reload service rh-php70-php-fpm restart service rh-php70-php-fpm status or if you're using systemctl:
systemctl start rh-php70-php-fpm systemctl stop rh-php70-php-fpm systemctl reload rh-php70-php-fpm systemctl restart rh-php70-php-fpm systemctl status rh-php70-php-fpm The simplest way to find the name of php-fpm service is to search for it:
systemctl -l --type service --all | grep fpm - 2You can make it simpler:
systemctl list-units *fpm*Michael Hampton– Michael Hampton2019-03-17 16:40:02 +00:00Commented Mar 17, 2019 at 16:40
On Windows:
Open Services in the Management Console:
Start -> Run -> "services.msc" -> OKSelect
php-fpmfrom the list- Rightclick and select restart
For old versions of debian & ubuntu - php 5.6 it will be
/etc/init.d/php-fpm56 restart service php-fpm56 restart On Alpine with nginx this is working here:
To kill all php-fpm7 processes:
kill $(ps -o pid,comm | grep php-fpm7 | awk '{print $1}')
To start php-fpm7:
php-fpm7
To list systemd services on CentOS/RHEL 7.x+ use
systemctl
To list all services:
systemctl list-unit-files
Where you can find service named * php-fpm * copy service name and run the following command
systemctl restart ea-php72-php-fpm.service
NOTE : ea-php72-php-fpm.service user your service name
Another method for MaxOS
Open ActivityMonitor, search php-fpm, find the pid.
Open terminal, use kill [pid] to stop php-fpm
Then php-fpm on terminal to start it.
If there is error information that 127.0.0.1:9000 Already in use, just ignore that.
Refresh Nginx page, should see php.ini changes take effects.
- What is MaxOS? Just running
php-fpmwill most probably run it under the wrong user; ignoring error messages is never a good idea.Gerald Schneider– Gerald Schneider2019-09-23 08:44:34 +00:00Commented Sep 23, 2019 at 8:44