Informational Website publish

Blog

News about our company, tutorials about IT and much more you will find in this page.

How to rebuild httpd.conf when using cPanel/WHM

Janeiro 30th, 2018

The rebuild httpd conf (rebuildhttpdconf) Script

You can use the /usr/local/cpanel/scripts/rebuildhttpdconf script to rebuild Apache’s main configuration file.

Sometimes it can happen that your httpd.conf file got damaged, or you edited your file in a wrong way and now your Apache Web Server is unable to start, or even you just want to revert back to the default configuration. If you are using cPanel/WHM there is a way to rebuild the httpd.conf file using a simple shell script, and that is what you are going to learn in this tutorial.

/usr/local/cpanel/scripts/rebuildhttpdconf --preview --nolock

Success

If the script succeeds, it will return output similar to the following example:

# /scripts/rebuildhttpdconf
...
info [rebuildhttpdconf] Missing IP for domain install.example.com, using 192.168.0.20
info [rebuildhttpdconf] Missing ServerName for domain install.example.com, using install.example.com
info [rebuildhttpdconf] Missing port for domain install.example.com, using 80
info [rebuildhttpdconf] Missing user for domain install.example.com, using nobody
info [rebuildhttpdconf] Missing owner for domain install.example.com, force lookup to root
info [rebuildhttpdconf] Missing group for domain install.example.com, using nobody
Built /etc/apache2/conf/httpd.conf OK

Login to your server SSH with root access and run the following command to rebuild the httpd.conf file to it’s default configuration:

You should now be able to restart your Apache service via your cPanel/WHM panel with the newly rebuilt httpd.conf file!

That is all!