LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   Virtualhost entries gets over-written when apache httpd.conf is rebuilt (http://www.linuxquestions.org/questions/linux-server-73/virtualhost-entries-gets-over-written-when-apache-httpd-conf-is-rebuilt-4175438530/)

amit.roy 11-24-2012 06:32 AM

Virtualhost entries gets over-written when apache httpd.conf is rebuilt
 
Background:
We have been trying to get a wildcard SSL working on multiple sub domains on a single dedicated address. We have two sub domains next.my-personal-website.com and blog.my-personal-website.com

Part of our strategy has been to edit the httpd.conf and add the NameVirtualHost xx.xx.144.72:443 directive and the virtualhost entries for port 443 for the subdomains there. This works good if we just edit the httpd.conf, add the entries, save it and restart the apache.


The problem:
But if we add a new sub domain from cpanel or we run the

Code:

# /usr/local/cpanel/bin/apache_conf_distiller --update
# /scripts/rebuildhttpdconf

the virtualhost entries that we added manually are no more there in the newly generated httpd.conf file. Only the virtualhost entry for the main domain for port 443 that was there before we made edits to the httpd.conf is there(assuming we are not discussing virtualhost entries for port 80).

I understand we need to put the new virtualhost entries in some include files as mentioned here in the cpanel documentation. But am not sure where to.

So the question would be where do I put the NameVirtualHost xx.xx.144.72:443 directive and the two virtualhost directive for port 443, so that they are not overwritten when httpd.conf is rebuilt/regenerated later.

Virtualhost entries:

The two virtualhost entries for the subdomains are:

Code:

<VirtualHost xx.xx.144.72:443>
    ServerName next.my-personal-website.com
    ServerAlias www.next.my-personal-website.com
    DocumentRoot /home/myguardi/public_html/next.my-personal-website.com
    ServerAdmin webmaster@my-personal-website.com
    UseCanonicalName On
    CustomLog /usr/local/apache/domlogs/next.my-personal-website.com combined
    CustomLog /usr/local/apache/domlogs/next.my-personal-website.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
    ## User myguardi # Needed for Cpanel::ApacheConf
    <IfModule mod_suphp.c>
        suPHP_UserGroup myguardi myguardi
    </IfModule>
    <IfModule !mod_disable_suexec.c>
        SuexecUserGroup myguardi myguardi
    </IfModule>
    ScriptAlias /cgi-bin/ /home/myguardi/public_html/next.my-personal-website.com/cgi-bin/
    SSLEngine on

    SSLCertificateFile /etc/ssl/certs/my-personal-website.com.crt
    SSLCertificateKeyFile /etc/ssl/private/my-personal-website.com.key
    SSLCACertificateFile /etc/ssl/certs/my-personal-website.com.cabundle
    CustomLog /usr/local/apache/domlogs/next.my-personal-website.com-ssl_log combined
    SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
    <Directory "/home/myguardi/public_html/cgi-bin">
        SSLOptions +StdEnvVars
    </Directory>
</VirtualHost>

<VirtualHost xx.xx.144.72:443>
    ServerName blog.my-personal-website.com
    ServerAlias www.blog.my-personal-website.com
    DocumentRoot /home/myguardi/public_html/blog.my-personal-website.com
    ServerAdmin webmaster@my-personal-website.com
    UseCanonicalName On
    CustomLog /usr/local/apache/domlogs/blog.my-personal-website.com combined
    CustomLog /usr/local/apache/domlogs/blog.my-personal-website.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
    ## User myguardi # Needed for Cpanel::ApacheConf
    <IfModule mod_suphp.c>
        suPHP_UserGroup myguardi myguardi
    </IfModule>
    <IfModule !mod_disable_suexec.c>
        SuexecUserGroup myguardi myguardi
    </IfModule>
    ScriptAlias /cgi-bin/ /home/myguardi/public_html/blog.my-personal-website.com/cgi-bin/
    SSLEngine on

    SSLCertificateFile /etc/ssl/certs/my-personal-website.com.crt
    SSLCertificateKeyFile /etc/ssl/private/my-personal-website.com.key
    SSLCACertificateFile /etc/ssl/certs/my-personal-website.com.cabundle
    CustomLog /usr/local/apache/domlogs/blog.my-personal-website.com-ssl_log combined
    SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
    <Directory "/home/myguardi/public_html/cgi-bin">
        SSLOptions +StdEnvVars
    </Directory>
</VirtualHost>

The full httpd.conf file I posted in earlier post is here

I really appreciate if somebody can help me out on this. Thank you.

j-ray 11-25-2012 11:54 AM

You can name the file as you want and then include it in httpd.conf or apache2.conf

include vhosts.conf (example)

restart the server and that's it


All times are GMT -5. The time now is 03:03 AM.