Installl Apache2.2+SSL in Ubuntu(7.10)

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 (.*) [url]https://%[/url]{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

你可能感兴趣的:(职场,ssl,ubuntu,休闲,apache2.2)