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.

virtual host advice

Discussion in 'Security' started by ozzieonline, Jan 23, 2013.

  1. ozzieonline

    ozzieonline Well-Known Member

    Joined:
    Dec 20, 2012
    Messages:
    126
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    Hi guys,

    I only use 1 cPanel account and all of the websites on my VPS will be set as add-on domains.

    I used WHM to set all of the Apache (security) settings. All of my (automatically generated) virtual hosts contain a lot of the exact same lines of code. I am wondering if I can adjust the templates and take these lines of code out of the virtual host and place them between <Directory /home/xxx/public_html></Directory>. I ask this because each virtual host contains about 40 lines of code, which I think is quite much. Imagine if I have 500 sites one day... then the httpd.conf file would contain 20.000 lines of code! So therefore I would be glad to strip some of that code and place it between the <Directory> tags. But... will that work, and is it safe to do? (And if so, does it matter if I place the <Directory> tags before or after the virtual hosts?)

    This is what each virtual host looks like. The lines in red are exactly the same for each virtual host, and I wonder if I can place these lines between <Directory /home/xxx/public_html></Directory>. Any advice?

    Code:
    <VirtualHost xx.xxx.xxx.xx:80>
        ServerName xxx.xxx.com
        ServerAlias xxx.xxx.xxx.com xxx.xxx.com xxx.com
        DocumentRoot /home/xxx/public_html
     [COLOR="#FF0000"]   ServerAdmin [email]xxxxx@xxxxx.com[/email]
        UseCanonicalName Off
        Options -ExecCGI -Includes
        RemoveHandler cgi-script .cgi .pl .plx .ppl .perl[/COLOR]
        CustomLog /usr/local/apache/domlogs/xxx.xxx.com combined
        CustomLog /usr/local/apache/domlogs/xxx.xxx.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
        ## User xxx # Needed for Cpanel::ApacheConf
     [COLOR="#FF0000"]   UserDir disabled
        <IfModule mod_suphp.c>
            suPHP_UserGroup xxx xxx
        </IfModule>
        <IfModule concurrent_php.c>
            php4_admin_value open_basedir "/home/xxx:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/tmp"
            php5_admin_value open_basedir "/home/xxx:/usr/lib/php:/usr/local/lib/php:/tmp"
        </IfModule>
        <IfModule !concurrent_php.c>
            <IfModule mod_php4.c>
                php_admin_value open_basedir "/home/xxx:/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/xxx:/usr/lib/php:/usr/local/lib/php:/tmp"
            </IfModule>
            <IfModule sapi_apache2.c>
                php_admin_value open_basedir "/home/xxx:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/tmp"
            </IfModule>
        </IfModule>
        <IfModule !mod_disable_suexec.c>
            <IfModule !mod_ruid2.c>
                SuexecUserGroup xxx xxx
            </IfModule>
        </IfModule>
        <IfModule mod_ruid2.c>
            RUidGid xxx xxx
        </IfModule>[/COLOR]
        # To customize this VirtualHost use an include file at the following location
        # Include "/usr/local/apache/conf/userdata/std/2/xxx/xxx.xxx.com/*.conf"
    </VirtualHost>
    
    So what I would like to do is this:

    One time:

    Code:
    <Directory /home/xxx/public_html>
     [COLOR="#FF0000"]   ServerAdmin [email]xxxxx@xxxxx.com[/email]
        UseCanonicalName Off
        Options -ExecCGI -Includes
        RemoveHandler cgi-script .cgi .pl .plx .ppl .perl[/COLOR]
     [COLOR="#FF0000"]   UserDir disabled
        <IfModule mod_suphp.c>
            suPHP_UserGroup xxx xxx
        </IfModule>
        <IfModule concurrent_php.c>
            php4_admin_value open_basedir "/home/xxx:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/tmp"
            php5_admin_value open_basedir "/home/xxx:/usr/lib/php:/usr/local/lib/php:/tmp"
        </IfModule>
        <IfModule !concurrent_php.c>
            <IfModule mod_php4.c>
                php_admin_value open_basedir "/home/xxx:/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/xxx:/usr/lib/php:/usr/local/lib/php:/tmp"
            </IfModule>
            <IfModule sapi_apache2.c>
                php_admin_value open_basedir "/home/xxx:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/tmp"
            </IfModule>
        </IfModule>
        <IfModule !mod_disable_suexec.c>
            <IfModule !mod_ruid2.c>
                SuexecUserGroup xxx xxx
            </IfModule>
        </IfModule>
        <IfModule mod_ruid2.c>
            RUidGid xxx xxx
        </IfModule>[/COLOR]
     </Directory>
    And then every virtual host would be like this:

    Code:
    <VirtualHost xx.xxx.xxx.xx:80>
        ServerName xxx.xxx.com
        ServerAlias xxx.xxx.xxx.com xxx.xxx.com xxx.com
        DocumentRoot /home/xxx/public_html
        CustomLog /usr/local/apache/domlogs/xxx.xxx.com combined
        CustomLog /usr/local/apache/domlogs/xxx.xxx.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
        ## User xxx # Needed for Cpanel::ApacheConf
        # To customize this VirtualHost use an include file at the following location
        # Include "/usr/local/apache/conf/userdata/std/2/xxx/xxx.xxx.com/*.conf"
    </VirtualHost>
    Is that something that should work correctly?
     
    #1 ozzieonline, Jan 23, 2013
    Last edited: Jan 23, 2013
Loading...

Share This Page