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.

Promote particular user's Apache VirtualHost to default

Discussion in 'Workarounds and Optimization' started by eggyal, Mar 31, 2015.

  1. eggyal

    eggyal Registered

    Joined:
    Mar 31, 2015
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    London, UK
    cPanel Access Level:
    Root Administrator
    As documented by Apache under Using Name-based Virtual Hosts:
    Currently, the template at /var/cpanel/templates/apache2_4/main.default generates such a default VirtualHost (per IP address) with DocumentRoot [% serverroot %]/htdocs.

    We would instead like the VirtualHost that is generated for a particular user to be that default. What is the best/recommended way of accomplishing this?

    My current thinking is to place the user's (compiled) VirtualHost directive in /usr/local/apache/conf/includes/pre_virtualhost_2.conf, but this obviously won't be managed by WHM should the user's configuration change.

    Is there a better way?
     
  2. eggyal

    eggyal Registered

    Joined:
    Mar 31, 2015
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    London, UK
    cPanel Access Level:
    Root Administrator
    Thanks cPanelMichael—but following that suggestion appears, to me, to provide little benefit over that I proposed in my question: either way, the arising default VirtualHost configuration will be "detached" from the user's VirtualHost that is managed by WHM.

    Is there no way that the "default" vhost can be that of a user, as managed by WHM?
     
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    675
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Yes, you could simply manually modify the position of the VirtualHost in /usr/local/apache/conf/httpd.conf and distill the changes via:

    Code:
    /usr/local/cpanel/bin/apache_conf_distiller --update
    Thank you.
     
  4. terabit

    terabit Registered

    Joined:
    Aug 14, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    I am also trying to reorder the virtualhosts in my httpd.conf but using apache_conf_distiller --update does not seem to preserve their order at all.

    My problem is that cpanel keeps rebuilding the config with the wildcard defined first and which makes apache ignore the explicitly named sub domain that is being defined after the wildcard... I need to be able to force cpanel to define multiple virtualhosts before the wildcard host.

    Should "apache_conf_distiller --update" be working for this? I don't see any indication in the documentation saying that it would. It seems to only save settings not the order that they are in.

    Code:
    <VirtualHost xxx.xxx.xxx.xxx:80>
      ServerName domain.com
      ServerAlias *.domain.com www.domain.com
      etc...
    
    <VirtualHost xxx.xxx.xxx.xxx:80>
      ServerName blog.domain.com
      ServerAlias www.blog.domain.com
      etc...
    
    <VirtualHost xxx.xxx.xxx.xxx:80>
      ServerName blog2.domain.com
      ServerAlias www.blog2.domain.com
    
    etc...
     
    #5 terabit, May 11, 2015
    Last edited by a moderator: May 11, 2015
  5. terabit

    terabit Registered

    Joined:
    Aug 14, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    675
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator

Share This Page