Xin lỗi để bump lên một bài cũ như thế này, nhưng để giúp người dùng Google khác ngoài kia tôi muốn chia sẻ làm thế nào tôi dealed với nó:
Tôi có một vài vhosts trên localhost của tôi, nói: localhost, foo.com, bar.com
Đây là trang web cục bộ trên máy tính xách tay của tôi (macosx) Tôi có thể lấy chứng chỉ tự ký và do đó phần ssl là giống nhau đối với tất cả vhost. ..
Điều tôi đã làm là:
Tôi đã tạo thư mục /etc/apache2/extra/vhosts/
.
Tôi tạo ra một /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
Một /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
Một /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
Và cuối cùng là một /etc/apache2/extra/vhosts/ssl.conf
:
SSLEngine on
SSLCertificateFile "/etc/apache2/ssl/server.crt"
SSLCertificateKeyFile "/etc/apache2/ssl/server.key"
Và trong tôi /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>
Một bản sao của http://serverfault.com/questions/83669/apache2-with-ssl-do-i-have-to-copy-virtualhost-blocks –