You have a website managed through WHM CPanel but need to add special configuration directives to the virtual host configuration (e.g. mod_rewrite rules that don’t work in an .htaccess file).
You need to create a directory for your configuration overrides via the Linux command-line.
- Logon to the host server with root privileges (using sudo as a normal user will work just fine)
- Run the following command, where domain.com is the domain to which you want to add the new virtual host configuration
# /scripts/ensure_vhost_includes –domain=domain.com
Note: this command will restart the Apache webserver
- If you search /etc/httpd/conf/httpd.conf for the domain name, you should see a line like the following:
# grep “Include.*domain.com”
- Create the target directory, if doesn’t already exist:
# mkdir -p “/usr/local/apache/conf/userdata/std/2/username/domain.com/”
- Create a new file in that directory; the name doesn’t really matter so long it ends in .conf. For the mod_rewrite example mentioned above, you might use the following:
# touch “/usr/local/apache/conf/userdata/std/2/username/domain.com/rewrite.conf”
- Edit the new file and enter your directives in the file.
# vim “/usr/local/apache/conf/userdata/std/2/username/domain.com/rewrite.conf”
- Restart Apache
# service httpd restart
- Refresh the site in your browser and confirm everything is working as expected. Remember: any incorrect configuration directives in your new file may prevent Apache from restarting. If the site doesn’t load, you can change the extension on your new file and restart Apache again to get it back to the previous working state while you review your changes.