Let’s say you have a website on you wamp server by name project. So there’s a directory
project in your C:\wamp\www directory. Also visiting http://localhost/project on the browser takes us to your project website. Now we want to set up a virtual host with self signed SSL certificate so that we can visit our website on https://project.localhost.com. Below are the steps to achieve this.
C:\Program Files\Common Files\SSL(Create SSL folder if it doesn’t exists)
Type the below command
openssl genrsa -des3 -out server.key 1024
It will ask you for a password and then later ask you verify it by reentering.
openssl req -new -x509 -nodes -sha1 -days 365 -key server.key -out server.crt -config C:\wamp\bin\apache\apache2.4.9\conf\openssl.cnf
In case you are having any other version than 2.4.9 of apache then change it in above command (Check the C:\wamp\bin\apache directory)
openssl rsa -in server.key -out servernopass.key
Since WAMP doesn’t support passphrase for key we’ll remove it
C:\wamp\bin\apache\apache2.4.9\conf\httpd.conffile in a text editor
#LoadModule ssl_module modules/mod-ssl.so
So it should now look like
LoadModule ssl_module modules/mod-ssl.so
Similary remove ‘#’ from below lines in same file
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
Move the last line
Include conf/extra/httpd_ssl.conf after the below line
C:\wamp\bin\apache\apache2.4.9\bin\php.iniin a text editor
C:\wamp\bin\apache\apache2.4.9\conf\extra\httpd_ssl.conffile. You can simply copy and paste it with a different name (httpd_ssl_original.conf) in the same folder. Now open the httpd_ssl.conf file, delete all the code inside it (we are assuming this is the first time you are setting up a SSL on your WAMP server) and paste the below code.
Listen 443 AddType application/x-x509-ca-cert .crt AddType application/x-x509-ca-cert .pem NameVirtualHost *:443
DocumentRoot "c:/wamp/www/project" ServerName project.localhost.com:443 ServerAdmin firstname.lastname@example.org AllowOverride All Require localSSLEngine on SSLCertificateFile "c:/wamp/ssl-certs/server.crt" SSLCertificateKeyFile "c:/wamp/ssl-certs/servernopass.key" SSLOptions +StdEnvVars SSLOptions +StdEnvVarsBrowserMatch "MSIE [2-5]" \ nokeepalive ssl-unclean-shutdown \ downgrade-1.0 force-response-1.0
C:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.conffile replace the code inside it with below one.
DocumentRoot "c:/wamp/www/" ServerName localhost ServerAlias localhost #AllowOverride All #Require local #Allow from All #Require local Options Indexes FollowSymLinks MultiViews AllowOverride all Order Allow,Deny Allow from all Require local DocumentRoot "c:/wamp/www/project" ServerName project.localhost.com ServerAlias project.localhost.com AllowOverride All Require local Allow from All Require local
That's it. Now in your browser visit https://project.localhost.com. You'll get a security warning which is because we are usign the self signed certificate. If you are using Chrome browser then click on the advanced link at the bottom and then Proceed unsafe. You'll now see the website over https.