How can i auto restart my server or my php-fpm if its crashed?
Hi,
I just want to know about one feature that i have heard from some sources that (systemctl) means if php-fp crashed then it will automatically get restart.
I am facing issue regarding php-fpm crashing when max children reached.
I have upgrade mx children setting but no luck.
Its started happening since i had upgraded and updated the server and that time my php also upgrade to php8.2
after i set php8.2-fpm in all my website configuration files from that time my server(php-fpm) got crashing continuously.
So, I need fix on this issue. I had already raised this on linode support but could not find proper response from them.
Thats why i need anything auto restarting setting or command something for restart php-fpm.
Because after restarting php-fpm websites works properly.
Thanks in advanced
1 Reply
Gosh, that is problematic… I can tell that must be really annoying. Do you mind providing more information on your Linode, for example, webserver, crash logs, CPU, RAM, etc?
>>> Please Save A Copy Of The Files Before Editing Them. <<<
For a more direct answer to your question. Try these steps to see if they work. First, access your Linux machine, find your php-fpm unit file, and open it.
For me, it was here
sudo nano /etc/systemd/system/php-fpm.service
For Nginx -- Usually, all web servers automatically restart without additional configuration, so the answers to why it isn't restarting will most likely be in the logs file.
sudo nano /lib/systemd/system/nginx.service
or
sudo nano /etc/systemd/system/nginx.service
Again, the location differs based on what you've used to set up the website.
Under the "[Service]" section, find "Restart" and "RestartSec." If you don't see it, add them. Please make sure the settings are similar to what I've added below.
Restart=on-failure
RestartSec=3s
Save and exit the editor.
Finally, restart both systemd and php-fpm
sudo systemctl daemon-reload
sudo systemctl restart php-fpm
Restarting on Nginx
sudo systemctl restart nginx