====== 匯入 Gandi SSL 憑證到您的 Apache ====== 如果您是從 Gandi AI 上轉換到虛擬站台(virtualhost),在您進行本教學之前請參考 [[http://wiki.gandi.net/en/hosting/using-linux/tutorials/gandiai#quit-gandi-ai-to-install-a-ssl-virtualhost-on-apache2|這個文件]] 來調整設定與安裝套件。 ===== 安裝 Apache 2 ===== 首先,您需要在伺服器上安裝 Apache 應用程式。 aptitude install apache2 然後您需要啟動 SSL 模組(稍後我們會重開 Apache): a2enmod ssl 接下來,請確認 Apache 有啟動 HTTPS 埠。 如果沒有,請在 /etc/apache2/ports.conf 這個檔案內增加: Listen 443 NameVirtualHost YOUR_IP_ADDRESS:443 ===== 取得中繼憑證 ===== 安裝中繼憑證號,這樣您的憑證簽發單位就可以被信任,Gandi 的中繼憑證在這裡: [[en:ssl:intermediate| Gandi 的中繼憑證]]。 ===== 啟動網域名稱的 Apache 加密連線(SSL) ===== 安裝您的金鑰/憑證與任何必要的中繼憑證到伺服器,安裝到 /etc/ssl 內: cp cert-domain.tld.crt /etc/ssl/certs/domain.tld.crt cp myserver.key /etc/ssl/private/domain.tld.key cp GandiXXXSSLCA.pem /etc/ssl/certs/GandiXXXSSLCA.pem 請別忘記將 **domain.tld** 替換成您的網域名稱。另外 **GandiXXXSSLCA.pem** 這個名稱應該是替換成您在 Gandi 取得的中繼憑證檔 設定 Apache 使用這個網域名稱的加密連線,請建立一個獨立檔案: vi /etc/apache2/sites-available/000-domain.tld-ssl ...設定虛擬站台使用 SSL 連線: ServerName www.domain.tld ServerAlias domain.tld DocumentRoot /var/www/www.domain.tld/ CustomLog /var/log/apache2/secure_access.log combined SSLEngine on SSLCertificateFile /etc/ssl/certs/domain.tld.crt SSLCertificateKeyFile /etc/ssl/private/domain.tld.key SSLCertificateChainFile /etc/ssl/certs/GandiXXXSSLCA.pem SSLVerifyClient None 重新啟動 Apache 之後 SSL 連線就會啟用: a2ensite 000-domain.tld-ssl /etc/init.d/apache2 reload 如果您的伺服器有開啟防火牆,請記得開啟 443 埠的連線。 ===== 檢查你的 SSL 鏈(Chain)是否完整正確 ===== 使用 openssl 指令來測試您的連線,請將 IP 位置(或是網域名稱)替換成實際的值,並連接服務的埠(Apache2/SSL 埠是 443): openssl s_client -connect ip.ip.ip.ip:port 或是使用 http://www.digicert.com/help/ 的視覺化界面來幫助您除錯。