apache2下的ssl支持

在UBUNTU FEISTY下如何添加APACHE2的SSL支持?

假设你的APACHE2已经可以运行了,现在只是需要添加SSL支持,首先安装:

sudo aptitude install openssl ssl-cert libapache-mod-ssl

注意,默认make-ssl-cert产生的ca只有一个月的有效期,因此我们需要延长这个时间,可以通过修改make-ssl-cert命令来实现:

sudo nano /usr/sbin/make-ssl-cert

假设需要把期限修改为10年:
就把”-keyout $output”修改为”-keyout $outpu -days 3650″。
然后来创建我们自己的签名,当然你也可以申请商业认证的签名。

sudo make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/ssl/apache.pem

注意,在填hostname的时候,要选择你所使用的域名。
接着,启用ssl模块

sudo a2enmod ssl

添加443监听端口

echo “Listen 443″ | sudo tee -a /etc/apache2/ports.conf

site文件的第一行修改为:

<VirtualHost *:443>

在site文件的最后一行前面添加:

SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.pem
SSLProtocol all
SSLCipherSuite HIGH:MEDIUM

重新启动服务:

sudo /etc/init.d/apache2 restart

若想强制所有的80端口访问都转送到443端口,可以这样设置:

sudo a2enmod rewrite

然后修改site文件,添加如下内容:

RewriteEngine on
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^(.*)$ https://%{SERVER_NAME}$1 [L,R]

reference:

https://help.ubuntu.com/community/forum/server/apache2/SSL

http://www.linode.com/wiki/index.php/Apache2_SSL_in_Ubuntu

This entry was posted in Linux and tagged , , , . Bookmark the permalink.

One Response to apache2下的ssl支持

  1. Pingback: LiangXu Wang » 安装subversion: ssl+auth_mysql+mod_svn

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Please copy the string hViYnj to the field below:

以新浪微博帐号登录