![Ubuntu Server Apache2 SSL 虚拟主机不工作](https://linux22.com/image/851033/Ubuntu%20Server%20Apache2%20SSL%20%E8%99%9A%E6%8B%9F%E4%B8%BB%E6%9C%BA%E4%B8%8D%E5%B7%A5%E4%BD%9C.png)
我已经在 ubuntu 上完全设置了使用 SSL 加密的 Web 服务器。我正在尝试设置默认的 -SSL 文件以指向正确的目录。geekychicgirls 运行正常,但是 thepeepinghole 总是解析为 geekychicgirls,任何帮助都值得感激,请参阅下面的代码。
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin [email protected]
DocumentRoot "/var/www/thepeepinghole"
SSLEngine on
SSLCertificateFile /ssl/14252798.crt
SSLCertificateKeyFile /ssl/private.key
SSLCertificateChainFile /ssl/futureretrogaming.ca-bundle
ServerName www.thepeepinghole.tk
ServerAlias thepeepinghole.tk
ErrorLog "/var/www/thepeepinghole/log/error.log"
CustomLog "/var/www/thepeepinghole/log/access.log" common
<Directory /var/www/thepeepinghole>
DirectoryIndex index.html
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
<VirtualHost *:443>
ServerAdmin [email protected]
DocumentRoot "/var/www/geekychicgirls"
SSLEngine on
SSLCertificateFile /ssl/14252798.crt
SSLCertificateKeyFile /ssl/private.key
SSLCertificateChainFile /ssl/futureretrogaming.ca-bundle
ServerName www.geekychicgirls.tk
ServerAlias geekychicgirls.tk
ErrorLog "/var/www/geekychicgirls/log/error.log"
CustomLog "/var/www/geekychicgirls/log/access.log" common
<Directory /var/www/geekychicgirls>
DirectoryIndex index.html
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
</IfModule>
答案1
解决方案是首先确保apache2.conf
包含sites-enabled
文件夹而不是sites-available
文件夹。
然后,您需要在sites-enabled
文件夹中创建一个额外的符号链接,链接到ssl
您在文件夹中创建的默认文件sites-available
。最后重新启动 apache2 服务,一切就绪了。
答案2
尝试把
名称虚拟主机 *:443
<IfModule mod_ssl.c>
NameVirtualHost *:443
<VirtualHost *:443>
ServerAdmin [email protected]
DocumentRoot "/var/www/thepeepinghole"
SSLEngine on
...
编辑1
我唯一能说的是:现在尝试一些完全不同的东西。
编辑 /etc/apache2/ports.conf 并添加以下行:
Listen 443
还请在 /etc/apache2/ports.conf 中注释掉以下内容:
<IfModule mod_ssl.c>
# SSL name based virtual hosts are not yet supported, therefore no
# NameVirtualHost statement here
Listen 443
</IfModule>
创建一个名为 /etc/apache2/ssl.conf 的文件,并将您发布的文件的所有内容(不包括开头和结尾)放入其中。
<VirtualHost *:443>
ServerAdmin [email protected]
DocumentRoot "/var/www/thepeepinghole"
SSLEngine on
SSLCertificateFile /ssl/14252798.crt
SSLCertificateKeyFile /ssl/private.key
SSLCertificateChainFile /ssl/futureretrogaming.ca-bundle
ServerName www.thepeepinghole.tk
ServerAlias thepeepinghole.tk
ErrorLog "/var/www/thepeepinghole/log/error.log"
CustomLog "/var/www/thepeepinghole/log/access.log" common
<Directory /var/www/thepeepinghole>
DirectoryIndex index.html
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
<VirtualHost *:443>
ServerAdmin [email protected]
DocumentRoot "/var/www/geekychicgirls"
SSLEngine on
SSLCertificateFile /ssl/14252798.crt
SSLCertificateKeyFile /ssl/private.key
SSLCertificateChainFile /ssl/futureretrogaming.ca-bundle
ServerName www.geekychicgirls.tk
ServerAlias geekychicgirls.tk
ErrorLog "/var/www/geekychicgirls/log/error.log"
CustomLog "/var/www/geekychicgirls/log/access.log" common
<Directory /var/www/geekychicgirls>
DirectoryIndex index.html
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
在 /etc/apache2/apache2.conf 中添加一行:
Include "/etc/apache2/ssl.conf"
使用以下命令重新启动 Apache2:apache2ctl restart
答案3
我创建了一个脚本,您可以使用它来为已创建的虚拟主机配置文件生成并自动安装自签名证书。您可以通过查阅本教程找到该脚本http://www.bytelinux.com/create-self-signed-certificates-enable-apache-ssl-ubuntu-14-10/并在您自己的服务器上创建 a2sslcert bash 脚本。