Enable https for Apache on localhost

The simplest way to enable HTTPS for Apache on localhost:

  1. First save these server.crt & server.key files into your apache/conf directory.

  2. Then open httpd.conf file and add following lines

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    Listen 80
    Listen 443

    NameVirtualHost *:80
    NameVirtualHost *:443

    <VirtualHost *:443>
    # Your DocumentRoot
    DocumentRoot "d:/wamp/www"
    ServerName localhost
    SSLEngine on
    # Your files
    SSLCertificateFile "d:/wamp/bin/apache/Apache2.4.4/conf/server.crt"
    SSLCertificateKeyFile "d:/wamp/bin/apache/Apache2.4.4/conf/server.key"
    </VirtualHost>
  3. Test your configuration

    1
    2
    3
    4
    # navigate to Apache bin directory
    cd /Apache24/bin
    # Test httpd.conf validity
    httpd -t