19

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.

Vao Tsun
  • 47,234
  • 13
  • 100
  • 132
appsntech
  • 722
  • 1
  • 6
  • 21
  • You can't simply replace `http://` with `https://` - HTTPS is a **secure** connection, and thus requires an [SSL certificate](https://en.wikipedia.org/wiki/SSL_certificate). – GoBusto Mar 14 '15 at 08:56
  • @GoBusto I am not trying to replace url. I want to enable the ssl for wamp server to test my project. – appsntech Mar 14 '15 at 09:18
  • You can see also this video tutorial: https://www.youtube.com/watch?v=TH6evGKgy20 – Ali Hesari Dec 10 '17 at 19:52

3 Answers3

47

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 admin@example.com
    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 :)

Sᴀᴍ Onᴇᴌᴀ
  • 8,218
  • 8
  • 36
  • 58
azdoud
  • 1,229
  • 9
  • 17
  • 2
    +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](https://stackoverflow.com/a/40051366/7735285) – wpcoder Oct 19 '17 at 14:31
  • This is correct and should be marked as is. @appsntech, could you please make the honors? =) – Mateus Leon Nov 23 '17 at 15:05
  • 3
    This not work for Virtual host and custom localhost domain such as: `https://project.dev` – Ali Hesari Dec 10 '17 at 20:10
  • 1
    @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 – Marko Francekovic Nov 19 '18 at 10:06
  • 2
    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"` – Swen Nov 28 '18 at 15:59
  • 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 – pankaj Feb 23 '21 at 15:09
  • if you are running `GitBash` and get stuck when running `openssl genrsa ...` on `Windows`, change to `winpty openssl genrsa ...` – GogromaT Nov 10 '21 at 19:03
  • @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. – Bhargav Variya May 17 '22 at 10:30
0

By default, you can't use https protocol for your wamp connections. What you need to do is to set up a self-signed certificate on wamp.

Follow this tutorial for more information.

David Peicho
  • 453
  • 4
  • 16
  • 18
    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](/review/low-quality-posts/14366683) – Kundan Nov 22 '16 at 11:35
  • That's right, I will make it when I have some free time – David Peicho Nov 22 '16 at 11:44
  • 4
    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). – David Thomas Jan 30 '17 at 17:37
  • 1
    this is very old tutorial and not valid for current releases. – T.Todua Oct 15 '18 at 16:46
0

Edit: I've moved my answer to the original topic - How to enable SSL in WAMP Server?

T.Todua
  • 53,146
  • 19
  • 236
  • 237