本文以apache为例,配置SSl证书建立HTTPS访问的加密通道。
# yum install mod_ssl openssl
# openssl genrsa -out test.key 2048然后,生成证书签名请求(CSR),这里需要填写许多信息,如国家,省市,公司等
# openssl req -new -key test.key -out test.csr
最后,生成类型为X509的自签名证书。有效期设置1年
# openssl x509 -req -days 365 -in test.csr -signkey test.key -out test.crtPS:第2个命令是生成证书请求,如果你需要向CA申请SSL证书,email一定要是你的域名后缀的。提交给 ssl 提供商的时候就是这个 csr 文件。当然我这里并没有向证书提供商申请,而是自己签发证书。
# cp test.crt /etc/pki/tls/certs/ # cp test.key /etc/pki/tls/private/ # cp test.csr /etc/pki/tls/private/
ServerAdmin web@iewb.net ServerName test.com ServerAlias test.com SSLEngine on SSLCertificateFile /etc/pki/tls/certs/oapod.crt SSLCertificateKeyFile /etc/pki/tls/private/oapod.key DocumentRoot /home/test.com/public_html/ ErrorLog /home/test.com/logs/error.log CustomLog /home/test.com/logs/access.log combined
ServerAdmin web@iewb.net ServerName test.com ServerAlias test.com DocumentRoot /home/test.com/public_html/ ErrorLog /home/test.com/logs/error.log CustomLog /home/test.com/logs/access.log combined
ServerAdmin web@iewb.net ServerName test.com Redirect permanent / https://test.com/
RewriteEngine on RewriteBase /test RewriteCond %{SERVER_PORT} !^443$ RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
Proudly Powered By WordPress | IEWB.NET 2009-2024 版权所有