Tell me more ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is there a way to preserve amends we make to first (default) VirtualHost container in /etc/httpd/conf/httpd.conf?

We have a custom setup for a site and we want all unmatched hostnames to be caught by that VirtualHost. As per Apache manual all unmatched hosts are processed by first VirtualHost directive, hence we copied DocumentRoot, suPHP user and some other values from out main site's VH.

Running /usr/local/cpanel/bin/apache_conf_distiller --update and then /usr/local/cpanel/bin/build_apache_conf reverts our changes.

share|improve this question

2 Answers

What you could be doing is protecting the file with chattr +i filename and whenever you need it changed unprotect it with chattr -i filename.

NOTE: when you do such command nothing will be able to change the file so if any update was needed within httpd.conf for any reason it won't be done since the file is protected.


I am not aware of anything else since WHM follows a template for all domains and it will try to overwrite it...

Perhaps a better option would be for you to make a backup for the conf file before updating or running anything that will mess with it and re-update the given catchall-domain again or create a simple perl or bash script that will search httpd.conf for the catchall-domain and update it the way you want.

This would be rather simple to be done with a perl, php, py, bash code.

share|improve this answer

After much searching, here is a solution that worked for me:

edit httpd.conf through WHM using the following path in WHM.

Service Configuration -> Apache Configuration -> Include Editor -> Pre VirtualHost Include -> All Versions -> pre_virtualhost_global.conf

I added my Vhost details here, saved and restarted Apache and it worked perfectly. VH added here will appear above all other hosts, including the default host.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.