The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

EasyApache4 and custom templates

Discussion in 'EasyApache' started by carock, Sep 14, 2016.

  1. carock

    carock Well-Known Member

    Joined:
    Sep 25, 2002
    Messages:
    232
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    St. Charles, MO
    I need to add some custom configuration to a virtual host. I'm running WHM 58.0 (build 28)

    This server is using EasyApache4 and this is my first server I've used with that.

    I started by looking at the Apache config file here: /usr/local/apache/conf/httpd.conf

    In each of the Virtual host sections these lines are there.

    # To customize this VirtualHost use an include file at the following location
    # Include "/etc/apache2/conf.d/userdata/std/2_4/chan/mysite.com/*.conf"

    This is different than the past with the userdata directory under the apache config.

    Looking at the documentation for EasyApache4, there is no section for using these custom templates like there is in EasyApache3 and the EasyApache3 documentation has different directories shown.

    Modify Virtualhost Containers With Include Files - EasyApache - cPanel Documentation

    Also, in the top of the Apache httpd.conf file, there used to be a part stating what commands to run to keep changes, i.e. distiller

    This new EasyApache4 httpd.conf file has no information other than ANY changes will be overwritten.

    Code:
    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
    #
    #   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    #   DO NOT EDIT. AUTOMATICALLY GENERATED.  USE INCLUDE FILES IF YOU NEED TO MAKE A CHANGE
    #   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    #
    #   Direct modifications to the Apache configuration file WILL be lost upon subsequent
    #   regeneration of this configuration file, or an Apache update.
    #
    #   To have your modifications retained, you should create/edit administrator-specific
    #   include files:
    #
    #       /etc/apache2/conf.d/includes/pre_main_global.conf
    #       /etc/apache2/conf.d/includes/pre_virtualhost_global.conf
    #       /etc/apache2/conf.d/includes/post_virtualhost_global.conf
    #
    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
    
    The /etc/apache2/conf.d/userdata directory structure didn't exist, so I created it, but if I can't remove the # remark in front of the virtual host config include line in the main httpd.conf file and keep the change, how will the custom configuration stay live?

    Thanks,
    Chuck
     
  2. sparek-3

    sparek-3 Well-Known Member

    Joined:
    Aug 10, 2002
    Messages:
    1,381
    Likes Received:
    23
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    Create the directory structure

    Code:
    mkdir -p /etc/apache2/conf.d/userdata/std/2_4/chan/mysite.com
    Then create/modify whatever configuration additions you want to make for mysite.com using whatever command line editor you like

    Code:
    /etc/apache2/conf.d/userdata/std/2_4/chan/mysite.com/custom.conf
    Then enable that section of code to be read by the httpd.conf file

    Code:
    /scripts/ensure_vhost_includes --user=chan
    For what it's worth, the configuration paths changed in EasyApache4 from EasyApache3. In EasyApache3, these userdata directories were located in

    /usr/local/apache/conf/userdata/std/2/%user%/%domain%


    in EasyApache4 these changed to

    /etc/apache2/conf.d/userdata/std/2_4/%user%/%domain%
     
    cPanelMichael likes this.
  3. carock

    carock Well-Known Member

    Joined:
    Sep 25, 2002
    Messages:
    232
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    St. Charles, MO
    Awesome! It works.

    The command I couldn't find in the docs was the
    /scripts/ensure_vhost_includes

    Thank you for your help.

    Chuck
     
    cPanelMichael likes this.
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    651
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page