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.

Edit default template of apache

Discussion in 'EasyApache' started by pratapsingh, Oct 15, 2010.

  1. pratapsingh

    pratapsingh Active Member

    Joined:
    Mar 20, 2009
    Messages:
    39
    Likes Received:
    0
    Trophy Points:
    6
    Hello ,

    I would like to make some changes in my Apache configuration file.
    I want users should be able to view their domain using the sub-domain added to the server Host-name.

    Users can also access their website using the url "http://cpuser_name.server-hostname.com" . But for this a ServerAlias entry should be added in the VirtualHost entry for the users domain name.

    Since I want to do this for all the domain hosted on the server and in the future if I add other domain then it should be added by default I do not have to make this changes manually.

    I have also followed the instruction given on the URL "http://www.cpanel.net/documentation/easyapache/ea3_changes.html" and rebuild apache conf but dint worked.

    I have added the entry "[% vhost.user %].server-hostname.com" in the file "/var/cpanel/templates/apache1/vhost.default" and in the other file as well, as suggested in the above url and also run the script "/scripts/rebuildhttpdconf" .

    I'm pasting the editted portion of the file:"vhost.default" below for your reference:
    --------------------------------------------------------------
    <VirtualHost[% FOREACH ipblock IN vhost.ips %] [% ipblock.ip %]:[% ipblock.port %][% END %]>
    ServerName [% vhost.servername %]
    [% IF vhost.serveralias_array.size -%]
    [% FOREACH alias IN vhost.serveralias_array -%]
    ServerAlias [% alias %]
    [% END -%]
    [% ELSE -%]
    ServerAlias [% vhost.serveralias %] [% vhost.user %].server-hostname.com
    [% END -%]
    DocumentRoot [% vhost.documentroot %]
    [% IF vhost.serveradmin -%]

    ---------------------------------------------------------

    However I could not find any changes in Apache virtual host after rebuilding the apache conf. Let me know if I am missing any thing.
     
  2. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Hello pratapsingh,

    To confirm, you are using Apache 1.3? I ask as this template:

    /var/cpanel/templates/apache1/vhost.default

    Would be if you are running Apache 1.3. If you are running Apache 2 or 2.2, then it would be:

    /var/cpanel/templates/apache2/vhost.default

    Next, you would not want to edit vhost.default as cPanel will reupdate it to the default each time you change it. You need to copy it to vhost.local and edit vhost.local instead.

    Thanks.
     
  3. pratapsingh

    pratapsingh Active Member

    Joined:
    Mar 20, 2009
    Messages:
    39
    Likes Received:
    0
    Trophy Points:
    6
    Thank you Danielle ,

    I am using apache 1. I added the entry in the apche1/vhost.default earlier too. but I found that I added the entry at the wrong place which now I have added to the correct block and it is working fine for the domain which were already added but now if I add a new domain then the serveralias entry is not getting added to the virtual host entry and I have to rebuild the apache conf again to make the changes or I have to add it manually. I want this entry to be added at the time of creation of an account.

    If you could let me know where should I add the entry in the vhost.default file so that it will add the server alias entry at the time of creation of an account.

    Here is the part of modified vhost.file file
    ==========================
    <VirtualHost[% FOREACH ipblock IN vhost.ips %] [% ipblock.ip %]:[% ipblock.port %][% END %]>
    ServerName [% vhost.servername %]
    [% IF vhost.serveralias_array.size -%]
    [% FOREACH alias IN vhost.serveralias_array -%]
    ServerAlias [% alias %] [% vhost.user %].server-hostname.com
    [% END -%]
    [% ELSE -%]
    ServerAlias [% vhost.serveralias %] [% vhost.user %].server-hostname.com
    [% END -%]
    DocumentRoot [% vhost.documentroot %]
    [% IF vhost.serveradmin -%]
    ServerAdmin [% vhost.serveradmin %]
    [% ELSE %]
    ==================================

    Thank you
     
    #3 pratapsingh, Oct 16, 2010
    Last edited: Oct 16, 2010
  4. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    As I previously mentioned, you would not want to add anything to the vhost.default file as cPanel will remove what you add on each update. It wipes your changes and reverts them to the default. Please copy the /var/cpanel/templates/apache1/vhost.default to /var/cpanel/templates/apache1/vhost.local and edit vhost.local

    After you've copied vhost.local and modified it instead, then rebuild Apache again using /scripts/rebuildhttpdconf and try seeing if you still have the same issue with adding new domains at that point. If you do, then we can work through it.
     
  5. pratapsingh

    pratapsingh Active Member

    Joined:
    Mar 20, 2009
    Messages:
    39
    Likes Received:
    0
    Trophy Points:
    6
    Hello Danielle ,

    I did as you suggested . I copied the file vhost.default to vhost.local and modified the entry and rebuilt the apache conf file and tried adding a new domain from WHM after that I checked the virtual host entry, I could not find the Serveralias entry for it.

    Thank you .
     
  6. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    When you rebuild Apache using /scripts/rebuildhttpdconf, please paste the return it provides

    Next, please paste the new domain added what it has for the entire virtual host entry.
     
  7. pratapsingh

    pratapsingh Active Member

    Joined:
    Mar 20, 2009
    Messages:
    39
    Likes Received:
    0
    Trophy Points:
    6
    Here it is
    ==================================================
    /scripts/rebuildhttpdconf
    info [rebuildhttpdconf] 'local' datastore in use (/var/cpanel/conf/apache/local)
    Built /usr/local/apache/conf/httpd.conf OK
    ==================================================
    <VirtualHost 192.168.0.121:80>
    ServerName checking.com
    ServerAlias www.checking.com
    DocumentRoot /home/checking/public_html
    ServerAdmin webmaster@checking.com
    UseCanonicalName Off
    CustomLog /usr/local/apache/domlogs/checking.com combined
    BytesLog /usr/local/apache/domlogs/checking.com-bytes_log
    ## User checking # Needed for Cpanel::ApacheConf
    <IfModule !mod_disable_suexec.c>
    User checking
    Group checking
    </IfModule>
    UserDir disabled
    UserDir enabled checking.
    <IfModule mod_suphp.c>
    suPHP_UserGroup checking checking
    </IfModule>
    <IfModule concurrent_php.c>
    php4_admin_value open_basedir "/home/checking:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/tmp"
    php5_admin_value open_basedir "/home/checking:/usr/lib/php:/usr/local/lib/php:/tmp"
    </IfModule>
    <IfModule !concurrent_php.c>
    <IfModule mod_php4.c>
    php_admin_value open_basedir "/home/checking:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/tmp"
    </IfModule>
    <IfModule mod_php5.c>
    php_admin_value open_basedir "/home/checking:/usr/lib/php:/usr/local/lib/php:/tmp"
    </IfModule>
    </IfModule>
    ScriptAlias /cgi-bin/ /home/checking/public_html/cgi-bin/

    # To customize this VirtualHost use an include file at the following location
    # Include "/usr/local/apache/conf/userdata/std/1/checking/checking.com/*.conf"

    </VirtualHost>


    ==================================================

    Thank you
     
    #7 pratapsingh, Oct 16, 2010
    Last edited: Oct 16, 2010
  8. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    I tested this on my machine and I can see exactly what you mean about it not doing it for new accounts. I had thought possibly modifying the /usr/local/cpanel/etc/httptemplates/apache2_2/default file (yours under Apache 1 might be called apache1 or apache1_3 for the folder), but even upon editing that file, new accounts are created without the changes to the vhost container.

    The best suggestion I have is to create a postwwwacct script (in /scripts/postwwwacct) that will simply run /scripts/rebuildhttpdconf on each new account creation. Since new accounts will check for a script on postwwwacct area, that will run at the very end of the account creation process.
     
Loading...

Share This Page