Wednesday, November 07, 2012

apache: define multiple domain over http & https

to define multiple domain, make sure you include NameVirtualHost setting and <VirtualHost> entries in your apache configuration file.

i got the ff warning messages when i forgot to include these settings:
[] [warn] VirtualHost 127.0.0.1:443 overlaps with VirtualHost 127.0.0.1:443, the first has precedence, perhaps you need a NameVirtualHost directive
[] [warn] _default_ VirtualHost overlap on port 443, the first has precedence


here's what i have in my apache configuration file for multiple domain handling over http and https:
# this is important to handle different domains and ports
NameVirtualHost *:80
NameVirtualHost *:443

<VirtualHost *:80>
        ServerName mydomain1.ph
        ServerAlias www.mydomain1.ph
        DocumentRoot /usr/local/apache2/htdocs/
</VirtualHost>

<VirtualHost *:80>
        ServerName mydomain2.ph
        ServerAlias www.mydomain2.ph
        DocumentRoot /usr/local/apache2/htdocs/mydomain2
</VirtualHost>


<VirtualHost *:443>
        ServerName mydomain1.ph
        ServerAlias www.mydomain1.ph
        DocumentRoot /usr/local/apache2/htdocs/
        SSLEngine  on
        SSLCertificateFile /usr/local/apache2/conf/ssl.crt/server.crt
        SSLCertificateKeyFile /usr/local/apache2/conf/ssl.key/server.key
</VirtualHost>

<VirtualHost *:443>
        ServerName mydomain1.ph
        ServerAlias www.mydomain2.ph
        DocumentRoot /usr/local/apache2/htdocs/mydomain2
        SSLEngine  on
        SSLCertificateFile /usr/local/apache2/conf/ssl.crt/server.crt
        SSLCertificateKeyFile /usr/local/apache2/conf/ssl.key/server.key
</VirtualHost>

No comments:

Post a Comment

SSH : No matching host key type found. Their offer: ssh-rsa,ssh-dss

Got this while connecting to my mikrotik router via ssh   Unable to negotiate with <ip address> port <ssh port>: no matching hos...