Sorry to encounter such an old post, but in order to help other googlers, I wanted to share how I dealt with it:
I have a couple of vhosts on my localhost, say: localhost, foo.com, bar.com
This is a local site on my laptop (macosx), I could leave with self-signed certificates, and so the ssl part will be the same for all vhosts ...
I have done the following:
I created the directory /etc/apache2/extra/vhosts/ .
I created /etc/apache2/extra/vhosts/localhost.conf :
ServerName localhost DocumentRoot "/www/localhost" <Directory /www/localhost> Require all granted </Directory> ErrorLog "/var/log/apache2/localhost.error_log" CustomLog "/var/log/apache2/localhost.access_log" common
A /etc/apache2/extra/vhosts/foo.conf :
ServerName foo.com DocumentRoot "/www/foo.com" <Directory /www/foo.com> Require all granted </Directory> ErrorLog "/var/log/apache2/foo.com.error_log" CustomLog "/var/log/apache2/foo.com.access_log" common
A /etc/apache2/extra/vhosts/bar.conf :
ServerName bar.com DocumentRoot "/www/bar.com" <Directory /www/bar.com> Require all granted </Directory> ErrorLog "/var/log/apache2/bar.com.error_log" CustomLog "/var/log/apache2/bar.com.access_log" common
And finally, /etc/apache2/extra/vhosts/ssl.conf :
SSLEngine on SSLCertificateFile "/etc/apache2/ssl/server.crt" SSLCertificateKeyFile "/etc/apache2/ssl/server.key"
And in my /etc/apache2/extra/httpd-vhosts.conf :
<VirtualHost *:80> Include /etc/apache2/extra/vhosts/localhost.conf </VirtualHost> <VirtualHost *:443> Include /etc/apache2/extra/vhosts/localhost.conf Include /etc/apache2/extra/vhosts/ssl.conf </VirtualHost> <VirtualHost *:80> Include /etc/apache2/extra/vhosts/foo.conf </VirtualHost> <VirtualHost *:443> Include /etc/apache2/extra/vhosts/foo.conf Include /etc/apache2/extra/vhosts/ssl.conf </VirtualHost> <VirtualHost *:80> Include /etc/apache2/extra/vhosts/bar.conf </VirtualHost> <VirtualHost *:443> Include /etc/apache2/extra/vhosts/bar.conf Include /etc/apache2/extra/vhosts/ssl.conf </VirtualHost>
RemyNL Nov 05 '15 at 13:17 2015-11-05 13:17
source share