Applicable to:
- Plesk for Linux
Question
-
How to enable/disable graceful restart for Apache in Plesk?
-
How to make Apache reload instead of restarting when applying settings in Plesk?
Answer
Note: Graceful restart for Apache is enabled by default on all new Plesk Obsidian installations.
-
Go to Tools & Settings > Apache Web Server.
-
Enable/disable the Apache graceful restart option and apply the changes.
To enable Apache graceful restart, set the restart_apache_gracefully
parameter to true
in the psa.misc
table:
-
Connect to the Plesk server via SSH.
-
For security reasons, create a dump of the Plesk database:
# plesk db dump psa > psa_backup.$(date +%F_%R).sql
-
Run the following command:
-
To enable Apache graceful restart
# plesk db "INSERT INTO psa.misc VALUES ('restart_apache_gracefully', 'true')"
-
If
restart_apache_gracefully
already exists (the command above fails with "Duplicate entry") in thepsa.misc
table, run:# plesk db "UPDATE psa.misc SET val='true' WHERE param = 'restart_apache_gracefully'"
-
-
To disable Apache graceful restart
# plesk db "UPDATE psa.misc SET val='false' WHERE param = 'restart_apache_gracefully'"
-
-
Check Apache graceful restart status with the command:
# plesk db "select * from psa.misc WHERE param = 'restart_apache_gracefully'"
where true - Apache graceful restart is enabled, false - disabled.
Comments
17 comments
The manual does not notice how to enable this change:
Hello David, article is correct. It's not needed to run httpdmng command to apply changes.
No David is correct. I run a webapp from within Plesk, and simply completing this database edit did not do the job. My logs showed:
503 POST {my uri} HTTP/1.0
(104)Connection reset by peer: AH01075: Error dispatching request to :, referer: {my uri}
Thank you David for posting the final step.
s intende@Justin, Hi!
Let me try to explain to you how it works and why it is actually not required to run httpdmng utility.
The solution from this article is to add a particular parameter to Pleks database. Every time when Plesk runs reconfiguration of some configuration files, it checks the value of 'restart_apache_gracefully' parameter. If it is true, then Plesk will restart apache gracefully. If you run httpdmng after these steps, it will not make anything to achieve what this article is intended for.
As for the errors, I believe they could have been resolved by running httpdmng to fix them, however, the cause of them different and the solution from this article makes nothing to fix them.
To enable:
INSERT INTO psa.misc VALUES ('restart_apache_gracefully', 'true') ON DUPLICATE KEY UPDATE val='true';
To disable:
INSERT INTO psa.misc VALUES ('restart_apache_gracefully', 'false') ON DUPLICATE KEY UPDATE val='false';
VERY VERY HELPFULL TO AVOID 502 NGINX ERRORS !!!
quick way to check if grafecull restart is active?
@Luis Zubeldia
This command will do the trick: plesk db "select * from misc where param = 'restart_apache_gracefully';" . It will either show the "true" or "false" value or it won't show anything - it means that graceful restart is disabled.
If you want to do this completely from within Plesk:
@Peter Wise
Thank you for the detailed steps! I am sure that other Plesk users will find it really helpful.
The "What's new" page of Plesk 18 Obsidian states the following :
"Apache graceful restart is now strong enough to be set as the default to reduce downtime for websites."
Could a Plesk Team member confirm if Apache Graceful restart is enabled by default on Plesk Obsidian ? Or should we still enable it ourselves ?
Hi @Charley,
On new servers, where Plesk Obsidian has been installed from the scratch, the Apache graceful restart is enabled by default with Apache restart interval=0.
You can check it in Tools & Settings > Apache Web Server.
On servers, where Plesk has been updated to Plesk Obsidian, for example from Plesk Onyx, Apache graceful restart still being disabled.
Thanks @Anzhelika-Khapaknysh !
May I suggest that someone from Plesk update this article to clarify this and explain that apache2 graceful restart are now strong enough ? :)
Hi Charley,
Thanks for your suggestion!
We've updated the article with Plesk Obsidian instructions :)
Apache graceful restart is such a welcome improvement to Plesk! It was very annoying that after a change was made in a customer's PHP settings for example, all websites would go down for ~5 seconds with "502 Bad Gateway". Graceful restart fixes this issue. Thanks guys!! :)
After upgrading to Plesk 18.0.30 apache gracefully restart seems not working well.
In this morning apache has stopped 3 times, 502 bad gateway errors. I run: service apache restart and works again but about 30 minutes after apache goes down.
In apache logs at the time it's stop:
[mpm_prefork:notice] [pid 11915] AH00171: Graceful restart requested, doing restart
[Wed Sep 16 14:00:33.871226 2020] [:alert] [pid 11923] (4)Interrupted system call: FastCGI: read() from pipe failed (0)
[Wed Sep 16 14:00:33.871322 2020] [:alert] [pid 11923] (4)Interrupted system call: FastCGI: the PM is shutting down, Apache seems to have disappeared - bye
[Wed Sep 16 14:00:34.190598 2020] [:notice] [pid 11915] mod_bw : Memory Allocated 0 bytes (each conf takes 48 bytes)
[Wed Sep 16 14:00:34.190623 2020] [:notice] [pid 11915] mod_bw : Version 0.92 - Initialized [0 Confs]
[Wed Sep 16 14:00:35.208190 2020] [fcgid:emerg] [pid 11915] (9)Bad file descriptor: mod_fcgid: Can't lock process table for initialization
[Wed Sep 16 14:00:35.208353 2020] [:notice] [pid 23246] FastCGI: process manager initialized (pid 23246)
[Wed Sep 16 14:00:35.210659 2020] [:alert] [pid 23246] FastCGI: read() from pipe failed (0)
[Wed Sep 16 14:00:35.210686 2020] [:alert] [pid 23246] FastCGI: the PM is shutting down, Apache seems to have disappeared - bye
I've run Plesk repair web without change.
Temporal I've disabled apache graceful restart.
@Emilio Ortiz
I see the error Bad file descriptor: mod_fcgid: Can't lock process table for initialization
Please create a ticket to our support department so we could check the issue in details.
Please sign in to leave a comment.