Troubleshooting – Apache Restart Issues in systemd
Note: |
| The instructions included in this article are for managed servers running Apache with cPanel. |
Any time you change the configuration in Apache on your server, the service will need a restart for the new configuration to work.
Problem:
If you have completed changes to Apache and restarted the service and are still getting errors you may be experiencing an instance where the service looked like it restarted, but actually did not. Common issues after a restart will be SSLs not working properly, domains showing the default cPanel page, mod_sec rules not working when whitelisted or any other errors with your service.
This tutorial will walk you through how to troubleshoot and make sure that systemd allowed the restart and is working properly.
Warning: |
| These errors may not occur every time you change the configuration of Apache, but you can avoid issues by checking the status and confirming that multiple instances of the service are not running every time you stop/restart Apache on CentOS 7. |
In order to verify that your errors are caused by the service not actually restarting, confirm that the service is actually stopping by checking the status of the service.
ps faux | grep httpd | grep root | grep -v grep root 2958 0.0 0.9 193860 8160 ? Ss 11:31 0:00 /usr/sbin/httpd -k start
If you are seeing:
ps faux | grep httpd | grep root | grep -v grep root 48426 0.2 1.3 194328 12772 ? Ss Dec 12 15:32 0:00 /usr/sbin/httpd -k start root 6852 0.0 1.1 193852 10216 ? Ss Jan26 0:13 /usr/sbin/httpd -k start
Solution:
This means there is an httpd parent process still running an old configuration from December 12, even though it should have stopped.
- You will need to kill the process:
kill 48426
Note:
You can use the killall -9 httpd if there are multiple instances not stopping, but this should be used with extreme caution. If you are unsure, please contact our Support team for assistance. - Now it will actually be stopped.
- After you kill the process, restart Apache:
systemctl start httpd
or
/scripts/restartsrv_httpd
Note: |
If you have upgraded to EasyApache 4, you will need to use the following commands instead: apachectl statusapachectl stop apachectl start |