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.

Virtualhost keeps getting reset

Discussion in 'General Discussion' started by ckoehler, Aug 5, 2010.

  1. ckoehler

    ckoehler Member

    Joined:
    Aug 7, 2009
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    Hi,

    After a lengthy ordeal with renewing a SSL certificate, I finally got it by editing my httpd.conf manually. The problem is obvious.

    Here's the config the way I like it:

    Code:
    <VirtualHost 12.12.12.12:80> 
        ServerName mydomain.com 
        ServerAlias www.mydomain.com 
        DocumentRoot /home/myuser/public_html 
        ServerAdmin me@mydomain.com 
        UserDir disable 
        Include "/usr/local/apache/conf/userdata/std/2/myuser/mydomain.com/*.conf" 
        ## User myuser # Needed for Cpanel::ApacheConf 
        <IfModule !mod_disable_suexec.c> 
            SuexecUserGroup myuser myuser 
        </IfModule> 
    </VirtualHost> 
    
    <VirtualHost 12.12.12.12:443>
        ServerName mydomain.com
        ServerAlias www.mydomain.com
        DocumentRoot /home/myuser/public_html
        ServerAdmin webmaster@mydomain.com
        UseCanonicalName off
        UserDir public_html
        <IfModule mod_userdir.c>
            Userdir disabled
        </IfModule>
        <IfModule mod_suphp.c>
            suPHP_UserGroup myuser myuser
        </IfModule>
        ## User nobody # Needed for Cpanel::ApacheConf
        CustomLog /usr/local/apache/domlogs/mydomain.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
        ScriptAlias /cgi-bin/ /usr/local/apache/htdocs/cgi-bin/
        SSLEngine on
        SSLCertificateFile /etc/ssl/certs/www.mydomain.com.crt
        SSLCertificateKeyFile /etc/ssl/private/www.mydomain.com.key
        SSLCACertificateFile /etc/ssl/certs/www.mydomain.com.cabundle
        CustomLog /usr/local/apache/domlogs/mydomain.com-ssl_log combined
        SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
    </VirtualHost>
    
    And here's what it makes of it automatically when I run rebuildhttpdconf:

    Code:
    <VirtualHost 12.12.12.12:80>
        ServerName mydomain.com
        DocumentRoot /usr/local/apache/htdocs
        ServerAdmin me@mydomain.com
        UserDir disable
    </VirtualHost>
    
    <VirtualHost 12.12.12.12:443>
        ServerName mydomain.com
        ServerAlias www.mydomain.com
        DocumentRoot /home/myuser/public_html
        ServerAdmin webmaster@mydomain.com
        UseCanonicalName off
        CustomLog /usr/local/apache/domlogs/mydomain.com combined
        CustomLog /usr/local/apache/domlogs/mydomain.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
        ## User myuser # Needed for Cpanel::ApacheConf
        UserDir disabled
        UserDir enabled myuser
        <IfModule !mod_disable_suexec.c>
            SuexecUserGroup myuser myuser
        </IfModule>
        ScriptAlias /cgi-bin/ /home/myuser/public_html/cgi-bin/
        SSLEngine on
    
        SSLCertificateFile /etc/ssl/certs/www.mydomain.com.crt
        SSLCertificateKeyFile /etc/ssl/private/www.mydomain.com.key
            SSLCACertificateFile /etc/ssl/certs/www.mydomain.com.cabundle
        CustomLog /usr/local/apache/domlogs/mydomain.com-ssl_log combined
        SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
        <Directory "/home/myuser/public_html/cgi-bin">
            SSLOptions +StdEnvVars
        </Directory>
    
        # To customize this VirtualHost use an include file at the following location
        # Include "/usr/local/apache/conf/userdata/ssl/2/myuser/mydomain.com/*.conf"
    
    </VirtualHost>
    

    Notice the SSL virtualhost is about the same, only a few differences, none too bad. But the non-SSL virtualhost on port 80 is just the default.

    How do I make it permanent??

    Thanks!

    Christoph
     
  2. WebScHoLaR

    WebScHoLaR Well-Known Member

    Joined:
    Dec 14, 2005
    Messages:
    511
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    Planet Earth
    Direct changes to httpd.conf will not be preserved as httpd.conf is regenerated based on the information stored in /var/cpanel/userdata. If you need to make changes to SSL Virtual Host, you can make the changes to the virtual host template inside /var/cpanel/templates and then rebuild httpd.conf as /scripts/rebuildhttpdconf and the changes will be applied to httpd.conf. Make sure to restart Apache afterwards.
     
  3. ckoehler

    ckoehler Member

    Joined:
    Aug 7, 2009
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    I understand that. I want to setup my one account in WHM such that I don't need to edit anything. If I had never messed with SSL, creating an account would setup the non-SSL virtualhost just fine. Now that I have SSL, it seems to totally neglect the non-SSL side of things.

    How do I tell cPanel that I would like both SSL and non-SSL on that one account?

    Christoph
     
  4. ckoehler

    ckoehler Member

    Joined:
    Aug 7, 2009
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    Alright, I fixed this by manually defining the virtualhosts as I want them and including them in the pre_virtualhost include file from inside WHM.

    All is working now.

    Christoph
     
Loading...

Share This Page