我为具有不同语法的两个不同域设置了 SSL vhost。这两个文件的语法是,
文件 1:example.test.com.conf
<VirtualHost *:80>
DocumentRoot /var/www/example.org/htdocs
ServerName example.test.com
<Directory "/var/www/example.org/htdocs">
allow from all
Options -Indexes
</Directory>
</VirtualHost>
<VirtualHost *:443>
DocumentRoot /var/www/example.org/htdocs
ServerName example.test.com
<Directory "/var/www/example.org/htdocs">
allow from all
Options -Indexes
</Directory>
SSLEngine on
SSLCertificateFile /etc/ssl/ssl.crt/example_org.crt
SSLCertificateKeyFile /etc/ssl/ssl.key/example_org.key
</VirtualHost>
文件 2:example.dev.com.conf
<VirtualHost *:80>
DocumentRoot "/var/www/example.org/htdocs"
ServerName example.dev.com
<Directory "/var/www/example.org/htdocs">
allow from all
Options +Indexes
</Directory>
</VirtualHost>
<VirtualHost *:443>
DocumentRoot "/var/www/example.org/htdocs"
ServerName example.dev.com
<Directory "/var/www/example.org/htdocs">
allow from all
Options +Indexes
</Directory>
SSLEngine on
SSLCertificateFile /etc/ssl/ssl.crt/STAR_dev_org.crt
SSLCertificateKeyFile /etc/ssl/ssl.key/dev.key
</VirtualHost>
这两个文件之间的区别是,
file1: DocumentRoot /var/www/example.org/htdocs
file2: DocumentRoot "/var/www/example.org/htdocs"
file1: Options -Indexes
flie2: Options +Indexes
file1: SSLCertificateFile /etc/ssl/ssl.crt/example_org.crt
flie2: SSLCertificateFile /etc/ssl/ssl.crt/STAR_dev_org.crt
file1: SSLCertificateKeyFile /etc/ssl/ssl.key/example_org.key
flie2: SSLCertificateKeyFile /etc/ssl/ssl.key/dev.key
设置此文件后,重新启动 Apache 服务器并运行两个域,
1) http://www.example.test.com and https://www.example.test.com
2) http://www.example.dev.com and https://www.example.dev.com
第一个域在 http 和 https 中都可以使用,但第二个域在 http 中不起作用。
创建配置文件是否有任何语法可遵循?请帮忙,谢谢!