Make sure the mod_ssl security module is installed and enabled so the Apache web server can use the
OpenSSL library and toolkit:確認安裝 mod_ssl模組 到Apache
- yum install mod_ssl openssl
複製代碼
Execute the following commands:
執行以下指令建立ssl目錄
- mkdir -p /etc/httpd/ssl/
- mv /etc/httpd/conf.d/ssl.conf /etc/httpd/conf.d/ssl.conf.bak
- cd /etc/httpd/ssl/
複製代碼
Generate SSL certificate signing request (CSR) files for your domains:
產生該網域SSL簽名憑證CSR
- openssl genrsa -out domain1.key 2048
- openssl req -new -key domain1.key -out domain1.csr
- openssl genrsa -out domain2.key 2048
- openssl req -new -key domain2.key -out domain2.csr
複製代碼
and enter the following details for your certificates: - Country Name
- State or Province Name
- Locality Name
- Organization Name
- Organizational Unit Name
- Email Address
和進入憑證步驟 1.國家名 Taiwan 2.州名 Taipei 3.區域 4.組織名稱 5.組織單位名稱 6.EMAIL位址 When prompted for the Common Name (i.e. domain name), enter the FQDN (fully qualified domain name) for the website you are securing. It is recommended to install commercial SSL certificates when used in a production environment. Or, generate and use self-signed SSL certificates when you are just developing or testing a website or application using the following commands: 當輸入網址時(需輸入網址全名) - openssl x509 -req -days 365 -in domain1.csr -signkey domain1.key -out domain1.crt
- openssl x509 -req -days 365 -in domain2.csr -signkey domain2.key -out domain2.crt
複製代碼
Edit the ‘ssl.conf’ Apache configuration file: 編輯 Apache ssl.conf檔案 - vi /etc/httpd/conf.d/ssl.conf
複製代碼
and add the following lines: 和加入以下敘述 - LoadModule ssl_module modules/mod_ssl.so
- Listen 443
- NameVirtualHost *:443
- SSLPassPhraseDialog builtin
- SSLSessionCacheTimeout 300
- SSLMutex default
- SSLRandomSeed startup file:/dev/urandom 256
- SSLRandomSeed connect builtin
- SSLCryptoDevice builtin
- SSLStrictSNIVHostCheck off
- <VirtualHost *:443>
- DocumentRoot /var/www/html/domain1
- ServerName domain1.com
- ServerAlias www.domain1.com
- SSLEngine on
- SSLProtocol all -SSLv2
- SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
- SSLCertificateFile /etc/httpd/ssl/domain1.crt
- SSLCertificateKeyFile /etc/httpd/ssl/domain1.key
- #SSLCertificateChainFile /etc/httpd/ssl/ca.crt
- ErrorLog logs/ssl_error_log
- TransferLog logs/ssl_access_log
- LogLevel warn
- <Files ~ "\.(cgi|shtml|phtml|php3?)[ DISCUZ_CODE_73 ]quot;>
- SSLOptions +StdEnvVars
- </Files>
- SetEnvIf User-Agent ".*MSIE.*" \
- nokeepalive ssl-unclean-shutdown \
- downgrade-1.0 force-response-1.0
- CustomLog logs/ssl_request_log \
- "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x "%r" %b"
- </VirtualHost>
- <VirtualHost *:443>
- DocumentRoot /var/www/html/domain2
- ServerName domain2.com
- ServerAlias www.domain2.com
- SSLEngine on
- SSLProtocol all -SSLv2
- SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
- SSLCertificateFile /etc/httpd/ssl/domain2.crt
- SSLCertificateKeyFile /etc/httpd/ssl/domain2.key
- #SSLCertificateChainFile /etc/httpd/ssl/ca.crt
- ErrorLog logs/ssl_error_log
- TransferLog logs/ssl_access_log
- LogLevel warn
- <Files ~ "\.(cgi|shtml|phtml|php3?)[ DISCUZ_CODE_73 ]quot;>
- SSLOptions +StdEnvVars
- </Files>
- SetEnvIf User-Agent ".*MSIE.*" \
- nokeepalive ssl-unclean-shutdown \
- downgrade-1.0 force-response-1.0
- CustomLog logs/ssl_request_log \
- "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x "%r" %b"
- </VirtualHost>
複製代碼
When using a commercial SSL certificate, it is likely the signing authority will include an intermediate CA certificate. In that case, create a new ‘/etc/httpd/ssl/ca.crt’ file and paste the contents of the Intermediate CA into it, then edit the the ‘ssl.conf’ configuration file and uncomment the following line: 當使用SSL公開憑證時,他就像是作者簽名,在這個案例,產生一個憑證檔案,編輯‘/etc/httpd/ssl/ca.crt’並把CA內文貼入 - SSLCertificateChainFile /etc/httpd/ssl/ca.crt
複製代碼
so the Apache web server can find your CA certificate. Test the Apache configuration: 測試一下APACHE 設定檔語法是否正確 - /etc/init.d/httpd configtest
- Syntax OK
複製代碼
Restart the Apache service for the changes to take effect: 重啟APACHE
Of course you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to set up multiple SSL Certificates on your VPS for you. They are available 24×7 and will take care of your request immediately. PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.
參考網址:https://www.rosehosting.com/blog ... ing-one-ip-address/
|