How to add SSL on Local PC | how to add https with SSL on wamp server

Step 1 – Install OpenSSL

OpenSSL is an open-source command-line tool that is used to generate the SSL certificate and private key. OpenSSL is available in both versions 32 and 64 bit. download the latest version of OpenSSL from here.

I hope you successfully installed OpenSSL on your machine. let’s take the next step

Step 2 – Create a Private key

Open your terminal as an Administrator otherwise you will get a permission denied error. Also, you can provide permission to the OpenSSL directory and run the terminal in normal mode.

Now, let go to where we installed OpenSSL

cd C:Program FilesOpenSSL-Win64bin

 

Let’s create a private key which is 2048 bits encryption. fire one by one the following two commands to create it.

openssl genrsa -aes256 -out private.key 2048

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

Your private.key is successfully generated here C:Program FilesOpenSSL-Win64bin

Step 3 – Create an SSL Certificate

Let’s create a certificate using the following command,

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

You need to enter a detail that looks like

You can verify this path  : 

Step 4 – Move both Private Key and a Certificate

Open a directory D:wamp64binapacheapache2.4.46conf (Based on where your wamp is installed) and create a key directory.

Now, move both files to the key directory.

Step 5 – Configure Your httpd.conf File

Open your D:wamp64binapacheapache2.4.46confhttpd.conf (the drive should be where your wamp is installed) and un-comment the following 3 lines one by one.

LoadModule ssl_module modules/mod_ssl.so

Include conf/extra/httpd-ssl.conf

LoadModule socache_shmcb_module modules/mod_socache_shmcb.so

Step 6 Configure Your httpd-ssl.conf File

Open your D:wamp64binapacheapache2.4.46confextrahttpd-ssl.conf (the drive should be where your wamp is installed) and change the following lines.

DocumentRoot “${INSTALL_DIR}/www”

ServerName localhost:443

ServerAdmin [email protected]

SSLCertificateKeyFile “${SRVROOT}/conf/key/private.key”

SSLCertificateFile “${SRVROOT}/conf/key/certificate.crt”

 

Make sure, these following all lines are set or not. if not, add it as well.

SSLSessionCache “shmcb:${SRVROOT}/logs/ssl_scache(512000)”

CustomLog “${SRVROOT}/logs/ssl_request.log”

          “%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x “%r” %b”

Step 7 Configure a Virtual Host

Hope you have created a virtual host. if not, create a virtual host using the virtual host manager which is provided by wamp.

Open an D:wamp64binapacheapache2.4.46confextrahttpd-vhosts.conf and update your virtual host

Change the port :80 to :443

add the following lines into the VirtualHost.

SSLEngine on

SSLCertificateFile “${SRVROOT}/conf/key/certificate.crt”

SSLCertificateKeyFile “${SRVROOT}/conf/key/private.key”

Now, the code of VirtualHost looks like,

<VirtualHost *:443>

  ServerName sam.local

  #ServerAlias localhost

  DocumentRoot “E:/wamp64/www/sam/”

  <Directory “E:/wamp64/www/sam/”>

    Options +Indexes +Includes +FollowSymLinks +MultiViews

    AllowOverride All

    Require all granted

  </Directory>

SSLEngine on

SSLCertificateFile “${SRVROOT}/conf/key/certificate.crt”

SSLCertificateKeyFile “${SRVROOT}/conf/key/private.key”

</VirtualHost>


Step 8 Configure to your hosts file

127.0.0.1 sam.local www.sam.local

::1       sam.local www.sam.local

Step 9 Final setup on WAMP 

Now, we are done. Let’s restart a wamp server.

If you see a green WAMP icon everything should be right. If the icon is orange there is a problem with your syntax somewhere.

Open terminal and go to the D:wamp64binapacheapache2.4.46bin and run httpd -t in the command prompt and if there are any syntax errors they will be listed.

if fine then open https://sam.local on the browser

Leave a Reply