PHP

How to setup and enable https with SSL on wamp server virtual host

How to setup and enable https with SSL on wamp server virtual host

Recently, I’ve started working on one project where we need to set up a virtual host with HTTPS because I need to run that project with expose and Shopify in my local development machine. I’ve wamp 3.2.3 on my local machine.

I spent a lot of time setting it. so, I thought I should write one article and video for a step-by-step guide. So, I will show you in this article how to set up HTTPS for a local machine.

You can watch the following video tutorial or follow the article.

Step 1 – Install Wamp

Install wamp server if not installed in your local machine. you can download the latest version of the wamp server from here. wamp server is available in 32 bit and 64 bit. make sure you select the correct version of the wamp server based on your operating system (window)’s version.

Step 2 – 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.

Step 2 - Install OpenSSL

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

Step 3 – 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 Files\OpenSSL-Win64\bin
				
			

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
				
			
Step 3 - Create a Private key

Your private.key is successfully generated here C:\Program Files\OpenSSL-Win64\bin

Step 4 – 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 need to enter a detail that looks like

You can verify here

You can verify here

Step 5 – Move both Private Key and a Certificate

Open a directory D:\wamp64\bin\apache\apache2.4.46\conf (Based on where your wamp is installed) and create a key directory.

Now, move both files to the key directory.

Step 6 – Configure Your httpd.conf File

Open your D:\wamp64\bin\apache\apache2.4.46\conf\httpd.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 7 Configure Your httpd-ssl.conf File

Open your D:\wamp64\bin\apache\apache2.4.46\conf\extra\httpd-ssl.conf (the drive should be where your wamp is installed) and change the following lines.

				
					DocumentRoot "${INSTALL_DIR}/www"
ServerName localhost:443
ServerAdmin admin@example.com
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 8 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:\wamp64\bin\apache\apache2.4.46\conf\extra\httpd-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 Virtual Host looks like,

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:\wamp64\bin\apache\apache2.4.46\bin and run httpd -t in the command prompt and if there are any syntax errors they will be listed.

if fine then open https://ladumor.test on the browser

Share On:

Related Posts