注册 | 登录 忘记密码? 51cto首页 | 博客 | 论坛 | 招聘
热点文章 linux服务器被黑了
 帮助

Installl Apache2.2+SSL in Ubuntu(7.10)


2007-11-26 11:09:30
 标签:Ubuntu SSL Apache2.2   [推送到技术圈]

版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://speedooo.blog.51cto.com/226772/52220
1. We need install Apache2.2 first, which is 2.2.4.3 version including SSL

sudo apt--get install apache2

Or you can install it from SPM manager.

2. setup  SSL certification
There is bug in this release "apache2-ssl-certificate: command not found", so I tried using /usr/sbin/make-ssl-cert. But the  key file apache.pem is not stored. What i done is:

sudo mkdir /etc/apache2/ssl
sudo openssl req -new -x509 -days 365 -nodes -out /etc/apache2/ssl/apache.pem -keyout /etc/apache2/ssl/apache.pem

answer the questions:
I put  CommonName or hostName to admin.domain.com

3. Configration
sudo a2enmod ssl

I want to setup rewrite rule so:
sudo a2enmod rewrite

sudo cp /etc/apache2/sites-available/default
/etc/apache2/sites-available/ssl
modified these two files:

"default" file:

NameVirtualHost *:80
<virtualhost *:80>
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
    RewriteLog      "/var/log/apache2/rewrite.log"
</virtualhost>

"ssl" file:
NameVirtualHost *:443
<virtualhost *:443>
        ServerAdmin webmaster@localhost

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

        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>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </directory>

        ErrorLog /var/log/apache2/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/access.log combined
        ServerSignature On

    Alias /doc/ "/usr/share/doc/"
    <directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </directory>

</virtualhost>

After then:

sudo a2ensite ssl
4. set serverName in apache2.conf

add line like:
ServerName admin.domain.com
the name is the same as in your certification key file.

5. all done
sudo /etc/init.d/apache2 force-reload

OR

sudo /etc/init.d/apache2 restart
6 some bug already fixed in next version Ubuntu and you can see the message 
in error.log

本文出自 “我爱我家” 博客,请务必保留此出处http://speedooo.blog.51cto.com/226772/52220





    文章评论
 
2007-11-26 11:25:53
study the apache config file thanks

2008-05-13 08:47:49
  * sudo make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/ssl/private/certname.pem

 

发表评论

昵   称:
验证码:  点击图片可刷新验证码  博客过2级,无需填写验证码
内   容: