Reputation: 31
I am using PHP-FPM with default settings. My server is running the latest Arch Linux.
I issue command sudo systemctl restart php-fpm
and it takes five minutes to restart and get back to the prompt.
Is there a known solution to this problem?
Upvotes: 3
Views: 2704
Reputation: 3527
This is caused by the way the systemctl script for PHP-FPM was created. I too had this exact same problem. Here is how I've resolved it.
First find your start-up script, if you don't know you can do systemctl status php-fpm
and you'll see something like: /etc/systemd/system/php.service
Now edit this file and it should look like this:
[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target
[Service]
Type=notify
PIDFile=/run/php-fpm/php-fpm.pid
PrivateTmp=true
ExecStart=/usr/bin/php-fpm --nodaemonize --pid /run/php-fpm/php-fpm.pid
ExecReload=/bin/kill -USR2 $MAINPID
[Install]
WantedBy=multi-user.target
Change it to this:
[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target
[Service]
ExecStart=/usr/bin/php-fpm --nodaemonize
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
[Install]
WantedBy=multi-user.target
One the file is changed run this command to refresh systemctl -> systemctl daemon-reload
Now restart FPM. I'd recommend to shutdown FPM first before making changes to this file. Once the changes are made FPM will start/stop/restart instantly.
Now I don't know why as of just yet, but sometimes after I've made this change it would appear that FPM still takes forever to start/stop/restart. So I just went ahead and rebooted my machine and from then on it was instant. So I'm guessing something was hanging that I haven't found yet but a reboot resolved that. I know you shouldn't have to reboot, but until I can find where exactly it's hanging this did the trick for now.
Upvotes: 3