Enable virtual hosts with self signed SSL on WAMP

Let’s say you have a website on you wamp server by name project. So there’s a directory project in your C:\wamp\www directory. Also visiting http://localhost/project on the browser takes us to your project website. Now we want to set up a virtual host with self signed SSL certificate so that we can visit our website on https://project.localhost.com. Below are the steps to achieve this.

Install OpenSSL

  • Install OpenSSL exe found at http://slproweb.com/products/Win32OpenSSL.html
    While installation the setup will ask you to select a directory for installation. Note the path.
    Let’s say you installed it in C:\ drive. So after installation you’ll have a directory like C:\OpenSSL-Win64.
  • Copy C:\wamp\bin\apache\apache2.4.9\conf\openssl.cnf to C:\Program Files\Common Files\SSL (Create SSL folder if it doesn’t exists)

Generate key and certificate

  • Open command prompt and cd to bin folder in above directory

    Type the below command

    It will ask you for a password and then later ask you verify it by reentering.
  • Then type below command

    In case you are having any other version than 2.4.9 of apache then change it in above command (Check the C:\wamp\bin\apache directory)
  • After above command you’ll be asked few questions. Just make sure you enter your domain name (eg abc.localhost.com) when asked for Common Name (e.g. server FQDN or YOUR name).
  • After entering details run the below command

    Since WAMP doesn’t support passphrase for key we’ll remove it
  • Now three files server.crt, server.key and servernopass.key should have been generated in bin folder. Copy the server.crt and servernopass.key.
    Create a new folder ‘ssl-certs’ in C:\wamp and paste the server.crt and servernopass.key files in this directory.

Update conf files to create new virtual host and include certificates

  • Open C:\wamp\bin\apache\apache2.4.9\conf\httpd.conf file in a text editor
    Remove the comment ‘#’ from the line

    So it should now look like

    Similary remove ‘#’ from below lines in same file

    Move the last line Include conf/extra/httpd_ssl.conf after the below line

  • Open C:\wamp\bin\apache\apache2.4.9\bin\php.ini in a text editor
    Make sure the following line is uncommented by removing the semicolon (;) from the beginning.

  • Now take a backup of C:\wamp\bin\apache\apache2.4.9\conf\extra\httpd_ssl.conf file. You can simply copy and paste it with a different name (httpd_ssl_original.conf) in the same folder. Now open the httpd_ssl.conf file, delete all the code inside it (we are assuming this is the first time you are setting up a SSL on your WAMP server) and paste the below code.
  • Similarly after taking a backup of C:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.conf file replace the code inside it with below one.

That’s it. Now in your browser visit https://project.localhost.com. You’ll get a security warning which is because we are usign the self signed certificate. If you are using Chrome browser then click on the advanced link at the bottom and then Proceed unsafe. You’ll now see the website over https.

Join the discussion

  1. Robert says:

    Thank you for the detailed description. I have been searching for a few days to find out if it is possible to generate one OpenSSL certificate to be used by WAMP that will cover all virtual hosts regardless of the virtual host names. I cannot find any statement saying such cannot be accomplished, but, I can’t find where it specifically says it can be done, and then how to do it.

Leave a Reply

Your email address will not be published. Required fields are marked *