Everything is at http://log4think.com now.

刘金雨的Blog

mirror of http://log4think.com

Ubuntu 5.10 下 Apache2 SSL 的配置方法

Ubuntu下Apache的配置文件跟Solaris和FreeBSD下面有点不“太”一样,不过本质上还是那些。有的时候我就奇怪,这一个软件在不同的平台上咋能折腾出这么多花样来。

Apache2在Ubuntu系统内的基本情况如下
默认站点在 /var/www/
配置文件在 /etc/apache2/
日志在 /var/log/apache/
启动脚本是 /usr/sin/apache2ctl 或者 /etc/init.d/apache2

安装Apache2
#apt-get install apache2

安装SSL模块
#a2enmod ssl

创建默认的SSL证书
#apache2-ssl-certificate

复制一份站点配置做为SSL配置的原型
#cp /etc/apache2/sites-available/default /etc/apache2/sites-available/ssl
#ln -s /etc/apache2/sites-available/ssl /etc/apache2/sites-enabled/ssl


编辑SSL的配置
#vi /etc/apache2/sites-enabled/ssl
把端口改为443
加入SSL认证配置

其它的根据需要自己定制 与普通配置无异
NameVirtualHost *:443
<VirtualHost *:443>
    ServerSignature On
    SSLEngine On
    SSLCertificateFile /etc/apache2/ssl/apache.pem


    ServerAdmin webmaster@localhost
#[......]

修改普通http方式的配置
#vi /etc/apache2/sites-enabled/default
把端口改为80
NameVirtualHost *:80
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
#[......]

编辑Apache端口配置,加入443端口(SSL的)
#vi /etc/apache2/ports.conf:
Listen 80
Listen 443

重新载入Apache的配置
#/etc/init.d/apache2 force-reload

以下是SSL的配置文件的示例
NameVirtualHost *:443
<VirtualHost *:443>
        ServerSignature On
        SSLEngine On
        SSLCertificateFile /etc/apache2/ssl/apache.pem

        ServerAdmin webmaster@localhost

        DocumentRoot /var/www/
        
<Directory />
                Options FollowSymLinks
                AllowOverride None
        
</Directory>
        
<Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
                # This directive allows us to have apache2's default start page
                # in /apache2-default/, but still have / go to the right place
                # Commented out for Ubuntu
                #RedirectMatch ^/$ /apache2-default/
        
</Directory>

posted on 2006-02-18 11:52  古月春秋(刘云涛)  阅读(1807)  评论(0编辑  收藏  举报

导航