Customize Apache vhost on cPanel

cPanel Apache Vhost Template

If you want to some custom entry added for a vhost for single domain then you can easily do it by creating /usr/local/apache/conf/userdata/std/2/username/*.conf and adding the entries to it. But what if you want to add those entires to every domain on the server and the server contains more than 1000 domains. You can add it manually, create a custom script which will create all those files automatically. But what happens when you add a new domain to server? Then you will have to do the same for new domain again. The simple and best solution for this is to modify the cpanel apache vhost template itself so that you never have to worry again.

First of all copy vhost.default to vhost.local

cp -a /var/cpanel/templates/apache2/vhost.default  /var/cpanel/templates/apache2/vhost.local

Now edit the vhost.local and add you custom entries

<IfModule mod_custom>
Setting1 Value1
Setting2 Value3
Setting3 Value3
...
</IfModule>

Now rebuild the apache conf and restart apache and you are done 🙂

/scripts/rebuildhttpdconf
/etc/init.d/httpd restart

If you want a professional server management company to look into your cPanel Server then you can take a look at our cPanel Server Management plan.

About 

Sreejit is the founder of Server Management Plus. His motto is "If there's an easier way, Why do it any other way" and following it, he has created a lots of automation scripts for the company using which we are able to resolve issue at an extremely fast rate and save lots of time. He has a very keen interest in new technologies and spend most of his free time online researching about it apart from listening music and watching movies.

2 thoughts on “Customize Apache vhost on cPanel”

  1. Pingback: Custom Vhost Cpanel | Cloud Save

  2. Pingback: Cpanel Apache Vhost Location – Near By Circle

Comments are closed.