How to Fix & Rebuild Apache in cPanel/WHM
How to Fix & Rebuild Apache in cPanel/WHM (The Easy Guide)
Introduction
Apache is the web server software that powers countless websites, including those managed by cPanel and WHM (Web Hosting Control Panel). It’s responsible for processing website requests and delivering content to your visitors. Occasionally, Apache might encounter issues that can affect your website’s performance.
This guide provides a clear and easy-to-follow approach to fixing and rebuilding Apache in cPanel/WHM. Even if you’re not a technical expert, you can follow these steps to get your website back on track.
Before You Begin
It’s important to understand that there are two main approaches:
- Fixing Apache: This involves troubleshooting minor issues without completely rebuilding the configuration.
- Rebuilding Apache: This essentially resets the Apache configuration to its default state, potentially resolving configuration errors.
Fixing Apache in cPanel/WHM
-
Login to SSH / Terminal
-
Run the below commands one by one
cd /etc/ mv apache2 apache2bk yum reinstall ea-apache* -y
- You have re-installed the required files. Now let’s move to the next step which is rebuilding apache.
Rebuilding Apache in cPanel/WHM (Use with Caution!)
-
Login to SSH / Terminal
-
Run the below commands one by one
/scripts/rebuildhttpdconf /scripts/restartsrv_httpd
- That’s it. You have finally completed all the required steps and fixed the Apache issue completely.
Important / Error Note:
If the above commands prove ineffective, attempt the following (note that the process may take 2-5 minutes):
yum reinstall ea-apache24-config-runtime -y
In case the reinstallation fails due to Imunify360’s hardened PHP, particularly if it was previously installed, and you encounter an error similar to: Installed package ea-apache24-config-runtime-2:1.0-191.el8.cloudlinux.noarch (from imunify360-ea-php-hardened) is not available. Error: No packages marked for reinstall.
- Resolve this issue by removing the package using:
rpm -e --nodeps ea-apache24-config-runtime
- Then, reinstall the package to address the problem:
yum install ea-apache24-config-runtime -y
Conclusion
By following these steps, you should be able to fix minor Apache issues or rebuild it if necessary. Remember, rebuilding is a more advanced step, so always back up your website beforehand. If you encounter any difficulties, don’t hesitate to seek help from your hosting provider’s support team.