下一页 上一页 目录

7. 启用SSL

http://mario.espaciolinux.com/apache2_ssl.html http://ilovett.com/blog/projects/installing-ssl-on-debian-apache2 http://blog.23corner.com/2005/09/14/1108/

7.1 首先需要启用SSL模块, 默认未启用

tonybox:/etc/apache2# a2enmod ssl 
tonybox:/etc/apache2# apache2-ssl-certificate 

creating selfsigned certificate
replace it with one signed by a certification authority (CA)

enter your ServerName at the Common Name prompt

If you want your certificate to expire after x days call this programm
with -days x
Generating a 1024 bit RSA private key
..............................++++++
..++++++
writing new private key to '/etc/apache2/ssl/apache.pem'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [GB]:
State or Province Name (full name) [Some-State]:GZ
Locality Name (eg, city) []:GY
Organization Name (eg, company; recommended) []:linuxsir
Organizational Unit Name (eg, section) []:debian
server name (eg. ssl.domain.tld; required!!!) []:www.mydebian.com
Email Address []:etony@tom.com

7.2 创建ssl站点配置文件

#/etc/apache2/sites-available/ cp wwwmydebian ssl_site
在/etc/apache2/ports.conf 中添加

        Listen 443

修改/etc/apache2/sites-available/ssl_site, 将监听端口 改为 443

在配置文件中加入

SSLEngine On
SSLCertificateFile /etc/apache2/ssl/apache.pem

监听端口设置为443

例如:

<VirtualHost 192.168.1.254:443> 
        
        ServerAdmin webmaster@mydebian.com
        ServerName www.mydebian.com:443
        DocumentRoot /var/www/mysite

7.3 重启apache 服务

# /etc/init.d/apache2 restart

7.4 测试

访问URL http://www.mydebian.com:443/


下一页 上一页 目录