Apache-2.2

Apache 從第一個虛擬主機為所有子域和主域提供服務

  • November 13, 2012

**目標:**讓多個子域成功使用萬用字元 SSL 證書。子域沒有單獨的專用 cpanel 帳戶,因此為 SSL 共享相同的專用 IP 地址(用於主域)。

**目前場景:**我們獲得了萬用字元 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 上。面板 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 webmaster@my-personal-website.com
   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 webmaster@my-personal-website.com
   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 中的順序相同。非常感謝任何有關如何使其正常工作的幫助。

謝謝你。

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

引用自:https://serverfault.com/questions/447877