I need to reload my php.ini and there's nothing in the help dialog about restarting it.
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.
For Mac OS X, this is what I do:
Make a script
#!/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
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!!
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
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`
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 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
Another method for MaxOS
Open ActivityMonitor, search php-fpm, find the pid.
Open terminal, use
kill [pid] to stop php-fpm
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.