How to enable https (localhost) url in WAMP server (v2.5)?

73,371

You have to set up your WAMP first with key and a certificate:

  1. Download openssl choose the appropriate version according to your Operating system from here.
  2. Install it, than run the cmd and get where you've installed it: cd 'C:\OpenSSL-Win**' be sure be in the appropriate folder

  3. run these commands :

    • C:\OpenSSL-Win..\bin>openssl genrsa -aes256 -out private.key 2048
    • C:\OpenSSL-Win..\bin>openssl rsa -in private.key -out private.key
    • C:\OpenSSL-Win..\bin>openssl req -new -x509 -sha1 -key private.key -out certificate.crt -days 36500 -config C:\OpenSSL-Win..\bin\openssl.cfg

    You will be asked to enter a pass phrase for private.key, Country Name and so on.

  4. Once you are done, the files will be generated: private.key and certificate.crt, create a folder, name it key in this path C:\wamp...bin\apache\apache2.*.**\conf .

  5. Open this file httpd.conf. You'll find it in C:\wamp...bin\apache\apache2.*.**\conf uncomment these lines by removing # at the beginning of the line, than save the file.

    LoadModule ssl_module modules/mod_ssl.so
    LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
    Include conf/extra/httpd-ssl.conf
    
  6. Open httpd-ssl.conf file you'll find it also in C:\wamp...bin\apache\apache2.*.**\conf\extra and change the default value by these lines, pay attention to the path, I ve created a folder ssl inside C:/wamp../bin/apache/apache2.*.**/logs/

    <VirtualHost _default_:443>
    #   General setup for the virtual host
    DocumentRoot "C:/wamp../www"
    ServerName localhost:443
    ServerAdmin [email protected]
    ErrorLog "C:/wamp../bin/apache/apache2.*.**/logs/ssl/error.log"
    TransferLog "C:/wamp../bin/apache/apache2.*.**/logs/ssl/access.log"
    ....
    CustomLog "C:/wamp../bin/apache/apache2.*.**/logs/ssl/ssl_request.log" \
    ....
    SSLCertificateFile "C:/wamp../bin/apache/apache2.*.**/conf/key/certificate.crt"
    SSLCertificateKeyFile "C:/wamp../bin/apache/apache2.*.**/conf/key/private.key"
    

    once done save your file.

  7. I copied ssleay32.dll & libeay32.dll from C:\wamp..\bin\php\php7.0.10 folder to c:\windows\system32.

  8. finaly check the configuration get in cd C:\wamp64\bin\apache\apache2.4.23\bin and run this command httpd -t if everything is okay you will get .

    C:\wamp64\bin\apache\apache2.4.23\bin>httpd -t
    Syntax OK
    
  9. https://localhost/ will work for you :)

Share:
73,371
appsntech
Author by

appsntech

A passionate web developer, blogger, artist. I spend hours in front of the computer to learn something new, help people and apply wherever it is possible. Currently I am working on building modern toolkit- Cygnite PHP Framework. You can find me here - Website: http://www.appsntech.com/ http://www.cygniteframework.com/ GITHUB - https://github.com/cygnite/cygnite-application https://github.com/cygnite/framework https://github.com/sanjoydesk/

Updated on July 05, 2022

Comments

  • appsntech
    appsntech almost 2 years

    I am using wamp server and running php project in localhost. I would like to test my project using "https" based url.

    I tried with "https://localhost/myproject/" and it redirecting me to "This webpage is not available" page.

    I have enabled "php_openssl" and "ssl" module into apache config. But still unable to access https based url.

  • Kundan
    Kundan over 7 years
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
  • David Peicho
    David Peicho over 7 years
    That's right, I will make it when I have some free time
  • Sikshya Maharjan
    Sikshya Maharjan over 7 years
    Having just arrived here from a cursory Google search, could I check if you're able to update this answer to include the essential pars of the external (linked) tutorial? Also, given the time since posting, it might be worth updating the chosen tutorial in case of outdated practices (though I've not yet read that tutorial, so I'm unsure if it's necessary as yet).
  • wpcoder
    wpcoder over 6 years
    +2, Excellent Tutorial, just two things, A) in step 1, version 1.0.2 seems to be working for 64bit wamp. B) I needed to restart wamp after step 8. Thank you. Note: if its 64bit wamp, Can't load ssl mod error
  • Mateus Leon
    Mateus Leon over 6 years
    This is correct and should be marked as is. @appsntech, could you please make the honors? =)
  • Ali Hesari
    Ali Hesari over 6 years
    This not work for Virtual host and custom localhost domain such as: https://project.dev
  • T.Todua
    T.Todua over 5 years
    this is very old tutorial and not valid for current releases.
  • Marko Francekovic
    Marko Francekovic over 5 years
    @AliHesari Don't use the .dev domain for local domains, as Google bought the top level domain and dns servers will mess things up for you. I suggest using .local -cheers
  • Swen
    Swen over 5 years
    To anyone having problems with generating the certificate.crt file, try wrapping the path in quotes like so: openssl req -new -x509 -sha1 -key private.key -out certificate.crt -days 36500 -config "C:\OpenSSL-Win..\bin\openssl.cfg"
  • pankaj kumar
    pankaj kumar about 3 years
    not working i use like this way c:\........ bin>openssl genrsa -aes256 -out private.key 2048 genrsa: Can't open "private.key" for writing, Permission denied
  • GogromaT
    GogromaT over 2 years
    if you are running GitBash and get stuck when running openssl genrsa ... on Windows, change to winpty openssl genrsa ...
  • Bhargav Variya
    Bhargav Variya about 2 years
    @azdoud I have followed your step, It's open with HTTPS but with red color not secure and the certificate is not valid on the chrome browser. Please help me to solve this.