DEV Community

Ahtisham Hasan Khan
Ahtisham Hasan Khan

Posted on • Edited on

How to enable HTTPS for WAMP Server.

Securing your web applications with HTTPS is a fundamental aspect of web development. In a previous article, we discussed how to enable HTTPS on XAMPP. Now, we'll focus on achieving the same security on WAMP, a widely used web development environment. Let's dive into the process of enabling HTTPS on WAMP for a more secure web experience.

Following are some easy steps to setup enviroment to use HTTPS on WAMP.

It is Important that you have already got WAMP installed, If not you can download WAMP from here.

After you've downloade and installed WAMP; the steps are as follows,

STEP 1: Download and Install OpenSSL.

Both 32 and 64-bit versions of OpenSSL are available. Make sure you're using the right installation for your Windows version.
The most recent version of OpenSSL may be found here. When Installing OpenSSL leave all settings default.

STEP 2: Generate Private Key and SSL certficate.

  • Load Command Prompt as an Administrator from your start menu and run the commands below. To begin, navigate to the directory where OpenSSL was installed.

cd c:/program files/openssl-win64/bin/

  • Generate your Private key by using follwing command.You will be asked for a passphrase. Make it anything you want just make sure you remember it for the next step.

openssl genrsa -aes256 -out private.key 2048

openssl rsa -in private.key -out private.key

  • Now, create your Certificate thorough following commad,You will be asked several questions on this step. You can put whatever you like or just hit enter to leave it at default.
    • The only one that really matters is Common Name (e.g. server FQDN) you will need to type β€œlocalhost” for this.

openssl req -new -x509 -nodes -sha1 -key private.key -out certificate.crt -days 36500

STEP 3: Move your KEY and Certificate.

  • Create a folder named "KEY" in the directory C:\wamp64\bin\apache\apache2.4.51\conf

  • Copy the generated private.key and certificate.crt files from C:\Program Files\OpenSSL-Win64\bin
    to the C:\wamp64\bin\apache\apache2.4.27\conf\key folder.

Step 4: Edit Your httpd.conf File

  • Open c:/wamp64/bin/apache/apache2.4.41/conf/httpd.conf and un-comment (remove the #) the 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

Step 5: Edit Your httpd-ssl.conf File

  • Open c:/wamp64/bin/apache/apache2.4.41/conf/extra/httpd-ssl.conf and change all the parameters to the ones shown below.
 DocumentRoot "c:/wamp64/www"
 ServerName localhost:443
 ServerAdmin admin@example.com
 ErrorLog "${SRVROOT}/logs/error.log"
 TransferLog "${SRVROOT}/logs/access.log"
 SSLSessionCache "shmcb:${SRVROOT}/logs/ssl_scache(512000)"
 SSLCertificateFile "${SRVROOT}/conf/key/certificate.crt"
 SSLCertificateKeyFile "${SRVROOT}/conf/key/private.key"
 CustomLog "${SRVROOT}/logs/ssl_request.log"
Enter fullscreen mode Exit fullscreen mode
  • The DocumentRoot folder is the location where the website files are located. The ServerName can be set as localhost" or the name set to access the website like "example.com"

Step 6: Restart WampServer

  • Everything should be set up now. Make sure you restart WampServer for the changes to take effect.
  • If there will be any syntax error, you can check it by navigating to c:/wamp64/bin/apache/apache2.4.41/bin in Command Prompt and run following command;

httpd -t

You should now be able to access your website with HTTPS / SSL enabled.

Public Gist URL: https://gist.github.com/iahtisham/5268b2391c674d758d0c2030dfbdb882

If you found this post helpful, consider buying me Coffee β˜•. Your support keeps me fueled to create more content!

Top comments (0)