Apache 从第一个虚拟主机为所有子域和主域提供服务

Apache 从第一个虚拟主机为所有子域和主域提供服务

客观的:让多个子域名成功使用通配符 SSL 证书。子域名没有单独的专用 cpanel 帐户,因此共享相同的专用 IP 地址(用于主域名)用于 SSL。

当前情况:我们获得了一个通配符 SSL 并将其安装在 VPS 上。我们有两个子域 next.my-personal-website.com 和 wp.my-personal-website.com。之前,任何子域都没有端口 443 的虚拟主机条目。所有对子域的 https 请求都从主域的相应 url 提供。

在我们编辑 httpd.conf 文件并为 next.my-personal-website.com 的端口 443 添加虚拟主机条目后,所有对主域和 wp.my-personal-website.com 的 https 请求都开始从 next.my-personal-website.com 获得服务

我们使用的是 Linux VPS。Cpanel 11.30.6、Apache 2.2.22、PHP 5.3.13

我们试图遵循本教程,但似乎并没有起到作用。

虚拟主机条目:

<VirtualHost xx.xx.144.72:443>
    ServerName next.my-personal-website.com
    ServerAlias www.next.my-personal-website.com
    DocumentRoot /home/myguardi/public_html/next.my-personal-website.com
    ServerAdmin [email protected]
    UseCanonicalName On
    CustomLog /usr/local/apache/domlogs/next.my-personal-website.com combined
    CustomLog /usr/local/apache/domlogs/next.my-personal-website.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
    ## User myguardi # Needed for Cpanel::ApacheConf
    <IfModule mod_suphp.c>
        suPHP_UserGroup myguardi myguardi
    </IfModule>
    <IfModule !mod_disable_suexec.c>
        SuexecUserGroup myguardi myguardi
    </IfModule>
    ScriptAlias /cgi-bin/ /home/myguardi/public_html/next.my-personal-website.com/cgi-bin/
    SSLEngine on

    SSLCertificateFile /etc/ssl/certs/my-personal-website.com.crt
    SSLCertificateKeyFile /etc/ssl/private/my-personal-website.com.key
    SSLCACertificateFile /etc/ssl/certs/my-personal-website.com.cabundle
    CustomLog /usr/local/apache/domlogs/next.my-personal-website.com-ssl_log combined
    SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
    <Directory "/home/myguardi/public_html/cgi-bin">
        SSLOptions +StdEnvVars
    </Directory>

    # To customize this VirtualHost use an include file at the following location
    # Include "/usr/local/apache/conf/userdata/ssl/2/myguardi/my-personal-website.com/*.conf"

</VirtualHost>


<VirtualHost xx.xx.144.72:443>
    ServerName my-personal-website.com
    ServerAlias www.my-personal-website.com
    DocumentRoot /home/myguardi/public_html
    ServerAdmin [email protected]
    UseCanonicalName Off
    CustomLog /usr/local/apache/domlogs/my-personal-website.com combined
    CustomLog /usr/local/apache/domlogs/my-personal-website.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
    ## User myguardi # Needed for Cpanel::ApacheConf
    <IfModule mod_suphp.c>
        suPHP_UserGroup myguardi myguardi
    </IfModule>
    <IfModule !mod_disable_suexec.c>
        SuexecUserGroup myguardi myguardi
    </IfModule>
    ScriptAlias /cgi-bin/ /home/myguardi/public_html/cgi-bin/
    SSLEngine on

    SSLCertificateFile /etc/ssl/certs/my-personal-website.com.crt
    SSLCertificateKeyFile /etc/ssl/private/my-personal-website.com.key
    SSLCACertificateFile /etc/ssl/certs/my-personal-website.com.cabundle
    CustomLog /usr/local/apache/domlogs/my-personal-website.com-ssl_log combined
    SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
    <Directory "/home/myguardi/public_html/cgi-bin">
        SSLOptions +StdEnvVars
    </Directory>

    # To customize this VirtualHost use an include file at the following location
    # Include "/usr/local/apache/conf/userdata/ssl/2/myguardi/my-personal-website.com/*.conf"

</VirtualHost>

与 httpd.conf 中的顺序相同。任何有关如何使其正常工作的帮助都将不胜感激。

谢谢。

答案1

您需要包含 NameVirtualHost xx.xx.144.72:443 指令。

相关内容