Results 1 to 8 of 8
  1. #1
    Join Date
    Nov 2004
    Location
    New Jersey
    Posts
    108

    Altering an existing account/VirtualHost in httpd.conf via an Include

    Since cPanel occassionally rebuilds the Apache configuration file, any alterations to httpd.conf are supposed to be done using Include directives, which are retained even in rebuilds. How can one alter an existing account via an include? For instance say the following is present in httpd.conf:
    Code:
    <VirtualHost 1.2.3.4:80>
        ServerName domain.com
        ServerAlias www.domain.com
        ...
    </VirtualHost>
    And you want something like an Alias or AliasMatch directive. Is that doable via an include? I tried adding something like making a file edit.conf with:
    Code:
    <VirtualHost 1.2.3.4:80>
    Alias /dir1 /dir2
    </VirtualHost>
    And adding this to httpd.conf:
    Code:
    Include "/usr/local/apache/conf/includes/edit.conf"
    But that failed.

    Also, is it possible to ovveride httpd.conf's settings via an Include - for instance httpd.conf has "ServerAdmin [email protected]" and you want to change that to "ServerAdmin [email protected]", but because of the cPanel rebuild issue it's not recommended to do it via direct httpd.conf edit.

  2. #2
    Join Date
    Mar 2009
    Location
    Austin Tx
    Posts
    2,001
    The path is relative. try

    Include conf/includes.edit.conf

    I'm using this on 9 servers currently.

    You can't override anything in an include, an include just dumps the files text into the httpd.conf at that point. It's the same as manually typing the lines into the conf file itself, so you would just end up with two conflicting directives.

    You CAN include different server admins inside your virtualhost directives for each site. All can have their own independent ServerAdmin named.
    This is the best signature in the world....Tribute!
    (It is not the best signature in the world, no. This is just a tribute)

  3. #3
    Join Date
    Nov 2004
    Location
    New Jersey
    Posts
    108
    The path isn't the issue, I'm using includes to add many extra VirtualHosts and other things.

    Are you saying that you can't add an extra directive like Alias or AliasMatch via Include?

  4. #4
    Join Date
    Mar 2009
    Location
    Austin Tx
    Posts
    2,001
    Quote Originally Posted by Kadence View Post
    The path isn't the issue, I'm using includes to add many extra VirtualHosts and other things.

    Are you saying that you can't add an extra directive like Alias or AliasMatch via Include?
    No, I'm not saying that, I'm saying a setting in an include won't override anything any more than just entering it directly into the httpd.conf itself. It's nothing more than a text dump.

    What exactly is not working? I'm not sure if it's the include, or what you have in the include that is not working. If your other includes (I assume in the same file) are working, and you are giving the same path, then I would suspect what is IN the include, not the include itself.

    You can put anything in an include that you can put straight into the conf file itself.
    This is the best signature in the world....Tribute!
    (It is not the best signature in the world, no. This is just a tribute)

  5. #5
    Join Date
    Nov 2004
    Location
    New Jersey
    Posts
    108
    The Include is working. It is the Alias that is not working - clearly I am not doing that correctly. What I'd like to know, is how to do something like that, where you are altering a VirtualHost entry already present in httpd.conf.

  6. #6
    Join Date
    Mar 2009
    Location
    Austin Tx
    Posts
    2,001
    Not sure exactly what you mean...how are you altering the VirtualHost entry? Is this a global entry, or something that is in it's own <virtualhost:xx> directive?
    If you can show what you are doing, that would help...if you can show what is in your conf and what you are trying to load with the include.
    This is the best signature in the world....Tribute!
    (It is not the best signature in the world, no. This is just a tribute)

  7. #7
    Join Date
    Nov 2004
    Location
    New Jersey
    Posts
    108
    I am not successfully altering the VirtualHost entry, that is what I am trying and failing to do.

    It is all as in my first post. My httpd.conf contains this, with the Include being the only edit and everything else unaltered:
    Code:
    <VirtualHost 1.2.3.4:80>
        ServerName domain.com
        ServerAlias www.domain.com
        ...
    </VirtualHost>
    Include "/usr/local/apache/conf/includes/edit.conf"
    And the edit.conf contents I tried were
    Code:
    <VirtualHost 1.2.3.4:80>
    Alias /dir1 /dir2
    </VirtualHost>
    In an attempt to add the Alias directive to the the "domain.com" domain via Include. But this did not work.

  8. #8
    Join Date
    Mar 2009
    Location
    Austin Tx
    Posts
    2,001
    If the IP is the same in both, you can't make two VirtualHost entries with the same IP address:port combo. It will try to bind to the port with that IP twice, the first one is going to win, which is why your include is not working.
    You need to put it all in one place or the other, or use namevirtualhost . Are these pointed to the same directory, and you are just trying to create an alias?

    If you must use an include, this is clunky but it would work...

    <VirtualHost 1.2.3.4:80>
    ServerName domain.com
    ServerAlias www.domain.com
    Include "/usr/local/apache/conf/includes/edit.conf"
    </VirtualHost>

    Then your edit.conf would only include this:
    Alias /dir1 /dir2

    (no virtual host directive in your edit.conf, your are placing it between the existing vhost tags with strategic placement of the Include line.)
    This is the best signature in the world....Tribute!
    (It is not the best signature in the world, no. This is just a tribute)

Similar Threads

  1. httpd.conf virtualhost entry
    By winlinfix in forum Web Hosting
    Replies: 1
    Last Post: 03-31-2008, 01:17 AM
  2. WHM Dns Zone and account problems, httpd.conf file corrupt
    By eazyjimmy23 in forum Dedicated Server
    Replies: 5
    Last Post: 11-18-2005, 04:47 PM
  3. Replies: 5
    Last Post: 08-21-2005, 07:16 AM
  4. VirtualHost Entry in httpd.conf
    By ChickenSteak in forum Hosting Security and Technology
    Replies: 21
    Last Post: 12-25-2002, 06:55 AM
  5. Q abt httpd.conf VirtualHost
    By Indian in forum Web Hosting
    Replies: 3
    Last Post: 10-22-2001, 12:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •