Set up apache2 for https

From LQWiki
Jump to: navigation, search

This article describes how to secure your webpage running on apache2 with https. You create demo-certificates yourself for this. Find out your distribution, then proceed accordingly:

SUSE Linux

This article assumes you know about SSL, https and certificates.

  1. set up your Certification authority and create dummy-certificates
  2. /usr/bin/gensslcert
  3. get your SSL Configuration from the given template
  4. cd /etc/apache2/vhosts.d
    cp vhost-ssl.template vhost-ssl.conf
  5. change your SSL Configuration
  6. have apache2 start per default with SSL. To do this, edit /etc/sysconfig/apache2: replace



  7. restart apache2
  8. /etc/init.d/apache2 restart
  9. make sure you have content to show
  10. echo "this is a test" >> /srv/www/htdocs/index.html
  11. test your configuration
  12. wget --no-check-certificate --no-proxy https://localhost

Ubuntu Linux

Follow If you use name-based virtual hosts, your apache configuration will look like this afterwards:

<VirtualHost *:443>
DocumentRoot /var/www/foo

SSLEngine on
SSLOptions +StrictRequire
SSLCertificateFile /etc/ssl/certs/server.crt
SSLCertificateKeyFile /etc/ssl/private/server.key