Apache Server mit SSL installieren

Als Root einloggen

sudo -s oder su -

Folgende Packete installieren:

  • Apache2
  • libapache2-mod-proxy-html

Zertifikat für ein Jahr erstellen. Die Fragen entsprechend beantworten.

apache2-ssl-certificate -days 365

oder neu

make-ssl-cert generate-default-snakeoil

SSL-Modul aktivieren

a2enmod ssl

Port 443 aktivieren

echo "Listen 443" | tee -a /etc/apache2/ports.conf

SSL Seite erstellen, indem das default-config File copiert und editiert wird.

cp /etc/apache2/sites-available/default /etc/apache2/sites-available/ssl

Editiere

/etc/apache2/sites-available/ssl

 

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>

Die Konfiguration aktivieren

sudo a2ensite ssl