After you've downloaded and installed WAMP Server, follow these steps:
- Generate SSL certificate using OpenSSL:
-
Add
C:\wamp64\bin\apache\apache2.4.27\bindirectory to the PATH so you can accessopensslcommand from the command prompt (WAMP comes with its own version of OpenSSL already integrated, so you don't need to install it. You'll find it in this directory.).IMPORTANT: Please note that the path of your installation depends on your version of Apache! DO NOT copy and paste the paths presented in this gist as they will not match with yours!
-
Navigate to your user directory (
C:\Users\%YOUR_USERNAME%\), create a new folder (.openssl), navigate to it with Powershell and run these commands:openssl genrsa -aes256 -out private.key 2048 openssl rsa -in private.key -out private.key openssl req -new -x509 -nodes -sha1 -key private.key -out certificate.crt -days 36500 -config c:\wamp64\bin\apache\apache2.4.27\conf\openssl.cnf -
You can pretty much answer the questions any way you want though real answers are best. The one question that really matters here is the FQDN. It should be:
localhost.
-
Copy the generated
private.keyandcertificate.crtfiles fromC:\Users\%YOUR_USERNAME%\.opensslto theC:\wamp64\bin\apache\apache2.4.27\conf\key\folder. If thekeyfolder doesn't already exist, create it. -
Using a text editor, open
C:\wamp64\bin\apache\apache2.4.27\conf\httpd.confand un-comment following 3 lines:LoadModule ssl_module modules/mod_ssl.so Include conf/extra/httpd-ssl.conf LoadModule socache_shmcb_module modules/mod_socache_shmcb.so -
Now open
C:\wamp64\bin\apache\apache2.4.27\conf\extra\httpd-ssl.confand apply the following changes below the<VirtualHost _default_:443>line. Check the following parameters to ensure they are configured correctly and not commented:DocumentRoot "c:/wamp64/www" ServerName localhost:443 ServerAdmin admin@example.com SSLSessionCache "shmcb:${SRVROOT}/logs/ssl_scache(512000)" ErrorLog "${SRVROOT}/logs/error.log" TransferLog "${SRVROOT}/logs/access.log" SSLCertificateFile "${SRVROOT}/conf/key/certificate.crt" SSLCertificateKeyFile "${SRVROOT}/conf/key/private.key" -
You can add your virtual hosts in the same file (
C:\wamp64\bin\apache\apache2.4.27\conf\extra\httpd-ssl.conf) by adding the following configuration below the closing</VirtualHost>, for each virtual host:<VirtualHost _default_:443> DocumentRoot "d:/dev/example" ServerName example.com:443 ServerAlias example.org ServerAdmin admin@example.com ErrorLog "${SRVROOT}/logs/error.log" TransferLog "${SRVROOT}/logs/access.log" SSLEngine on SSLCertificateFile "${SRVROOT}/conf/key/certificate.crt" SSLCertificateKeyFile "${SRVROOT}/conf/key/private.key" <FilesMatch "\.(cgi|shtml|phtml|php)$"> SSLOptions +StdEnvVars </FilesMatch> <Directory "d:/dev/example"> SSLOptions +StdEnvVars Options +Indexes +Includes +FollowSymLinks +MultiViews Require all granted AllowOverride All </Directory> BrowserMatch "MSIE [2-5]" \ nokeepalive ssl-unclean-shutdown \ downgrade-1.0 force-response-1.0 CustomLog "${SRVROOT}/logs/ssl_request.log" \ "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" </VirtualHost> -
You're done! Now, to check the validity of the file, type
httpd -tin your command prompt. It will show you if there's any syntax errors. If eveything is fine, restart your WAMP Server and go tohttps://localhostorhttps://example.comor whatever virtual hosts you may have.
Please note that you'll get a warning in the browser saying that the certificate is not valid! This is perfectly normal, as the certificate is self-signed. Just add an exception for it and save it in your browser.
Please also note that you can't use valid SSL certificates generated with Let's Encrypt or other free SSL service, because you need to own the domain name that you're trying to validate. These instructions are for localhost development only, we don't need valid certificates for that.
If this was useful, you can buy me a coffee here. Thank you!