Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Custom templates that will apply to a single virtual host when rebuilding an existing

Discussion in 'General Discussion' started by haulpd, May 27, 2011.

  1. haulpd

    haulpd Active Member

    May 20, 2011
    Likes Received:
    Trophy Points:
    I do like the link below:

    Changes Contained within a VirtualHost Directive

    but i don't understand step 5 where:

    Use the following script to add the necessary information to the data structure:
        perl -MYAML::Syck -e 'my $hr = YAML::Syck::LoadFile($ARGV[0]);$hr->{$ARGV[1]} = $ARGV[2];YAML::Syck::DumpFile($ARGV[0],$hr);' /var/cpanel/userdata/$username/$domainname $key $path/to/template 
    how to do this ?

  2. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Apr 11, 2011
    Likes Received:
    Trophy Points:
    cPanel Access Level:
    Root Administrator
    Re: Custom templates that will apply to a single virtual host when rebuilding an exis

    Hello :)

    You would simply run the following via the command line as root:

    perl -MYAML::Syck -e 'my $hr = YAML::Syck::LoadFile($ARGV[0]);$hr->{$ARGV[1]} = $ARGV[2];YAML::Syck::DumpFile($ARGV[0],$hr);' /var/cpanel/userdata/$username/$domainname $key $path/to/template
    Any value that begins with the "$" symbol, you would replace that with the specific entry. EX:

    "$username" would be replaced with the actual cPanel username.
    "$domainname" would be replaced with the domain name you are editing the VirtualHost for.
    "$path/to/template" would be replaced with the exact path to the template file moved during step 4.

    The $key value should be:

    custom_vhost_template_ap1 for Apache 1
    custom_vhost_template_ap2 for Apache 2

    Let's say you were making this change for the "" domain name on the "test01" account and the system uses Apache 2. The custom template file from step 4 would have been moved to "/var/cpanel/templates/custom-directory/vhost.local" in this scenario. The command would be:

    perl -MYAML::Syck -e 'my $hr = YAML::Syck::LoadFile($ARGV[0]);$hr->{$ARGV[1]} = $ARGV[2];YAML::Syck::DumpFile($ARGV[0],$hr);' /var/cpanel/userdata/test01/ custom_vhost_template_ap2 /var/cpanel/templates/custom-directory/vhost.local
    Thank you.
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice