Configure HTTPS using SSL certificate on WAMP local server
In this blog you will learn step by step how to configure HTTPS using SSL certificate on WAMP local server at any of your project.
Here you will also learn how to serve your local websites with domains names like project1.com project2.com or for detailed virtual-host configuration go to my another blog create-virtual-hosts-apache-wamp-xamp
lets start HTTPS SSL configuration.
-
Requirements for SSL configuration
You should have below 2 certificate files
- Certificate.cer or certificate.crt
- private.key
If you already have certificate files then skip steps [2,3,4] and just to step#5 .
-
Install openSSL
Install open SSL from Here
-
Generate Private key
Open terminal as an Administrator and goto openssl installation path by typing below commad
1cd C:\Program Files\OpenSSL-Win64\bin1openssl genrsa -aes256 -out private.key 20481openssl rsa -in private.key -out private.key -
Create SSL Certificate
Enter below command and enter real or dummy company information
1openssl req -new -x509 -nodes -sha1 -key private.key -out certificate.crt -days 36500You have to provide below information
1234567Country Name (2 letter code) [AU]:AEState or Province Name (full name) [Some-State]:Abu DhabiLocality Name (eg, city) []:Madinat ZayedOrganization Name (eg, company) [Internet Widgits Pty Ltd]:alampk.comOrganizational Unit Name (eg, section) []:ITCommon Name (e.g. server FQDN or YOUR name) []:alampk.comEmail Address []:alamnaryab@gmail.com -
Move SSL Certificate files
copy both certificate files to D:\wamp64\bin\apache\apache2.4.46\conf
-
Changes in httpd.conf
open httpd.conf file from D:\wamp64\bin\apache\apache2.4.46\conf\httpd.conf and uncomment below lines
123LoadModule ssl_module modules/mod_ssl.soInclude conf/extra/httpd-ssl.confLoadModule socache_shmcb_module modules/mod_socache_shmcb.so -
Changes in httpd-ssl.conf
Open httpd-ssl.conf file from D:\wamp64\bin\apache\apache2.4.46\conf\extra\httpd-ssl.conf and update the following linkes as per path where you have pasted 2 certificate files.
12345678910DocumentRoot "${INSTALL_DIR}/www"ServerName localhost:443ServerAdmin alamnaryab@gmail.comSSLCertificateKeyFile "${SRVROOT}/conf/key/private.key"SSLCertificateFile "${SRVROOT}/conf/key/certificate.crt"SSLSessionCache "shmcb:${SRVROOT}/logs/ssl_scache(512000)"CustomLog "${SRVROOT}/logs/ssl_request.log" \"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" -
Make a virtual host
123456789101112131415<virtualhost *:443>SSLEngine onSSLCertificateFile "${SRVROOT}/conf/key/certificate.crt"SSLCertificateKeyFile "${SRVROOT}/conf/key/private.key"ServerName mydomain.comServerAlias mydomain.comDocumentRoot "D:\wamp64\www\myproject"<directory "d:\wamp64\www\myproject">Options +Indexes +Includes +FollowSymLinks +MultiViewsAllowOverride AllRequire all granted</directory></virtualhost> -
Changes in Host file
Open notepad with Run as Administrator and open host file from C:\WINDOWS\System32\drivers\etc
add below line, note domain name must be same as you mentioned in vhosts file1127.0.0.1 mydomain.com -
Restart WAMP Server
-
Test websites
try opening your website in browser with https protocol eg
https://mydomain.com -
Errors Handling
If there is any error you can find it by any of below methods
- In CMD goto D:\wamp64\bin\apache\apache2.4.46\bin and run httpd -t
- Check log files
- I faced an issue that was because of forward-slash instead of back-slah as path separator. So use (/ instead of \) in certificate paths in vhost file
- Google or commenting your error in this blog
Comments