The purpose of this technical document provide specialized information about how to Redirect http to https using the WAMP server.
All the steps are described with images and the commands. This is working 100% per-fectly.
All the configuration are done by manually and steps are mentioned clearly, In here I am going to install a fresh copy of the WAMP server. And configure it to redirect the http://localhost in to https://localhost. Then you can use your own web sites using se-cure http.
In this tutorial I am using X.509 Certificate to grant secure connection to the server. X.509 is widely used for defining digital certificates. It issues a certificate with binding public key to a particular distinguished name.
The video tutorial also available @ YouTube URL: http://www.youtube.com/watch?v=6MOBWNYy-kE&feature=youtu.be
Hi, Today I’m going to show you how to make the http://localhost to a secure connection. this is the task that I was given my Director – Systems and Operations. then I started searching on the internet as usually.
Normally I installed the Wampserver2.4-x86 on my Windows Server 2012 VMware machine. It was not in-stalled successfully because it said that MSVCR100.dll file is missing from your computer. So I downloaded the .dll file (http://www.dll-files.com/dllindex/dll-files.shtml?msvcr100) and dropped to the correct destination (C:\Windows\SysWOW64) then tried to load the http://localhost, it was loaded but loaded the IIS server which has been already installed on the Windows Server 2012.
The problem was on the port 80, it is already caught by the IIS, so I wanted to changed the port number in WAMP server. Let’s look at how to change the port number in WAMP server step by step.
- Open the httpd.conf file using the way that I have shown using the below image.
In httpd.conf file locate the line which says : #Listen 184.108.40.206:80 and comment it with a # mark and enter a new line to use port 8080 or something like that. As an example if you are using port 8080 you can use Listen 8080.
- Then restart the all services which are for WAMP server. You can take a guidance using the below image to how to restart the services instantly.
- Then try in a internet browser to load the http://localhost:8080/.
In my case now I can load the WAMP server using port 8080 and the phpmyadmin. Here is the screen-shot.
Now, let’s look at how to set a secure http (https://) connection on the WAMP server, that is something strange thing to do because it is not a GUI way to configure those things. The following steps are clearly men-tion about the conduct how to make a secure http connection with the localhost.
- First you need to download the open source SSL (Secure Socket Layer) program. So go the link given here https://code.google.com/p/openssl-for-windows/downloads/detail?name=openssl-0.9.8k_WIN32.zip&can=2&q=
- Then extract the openssl zip file and Copy following files to the destination given be-low.
openssl.cnf to C:\wamp\bin\apache\Apache2.4.4\conf
contents of the bin folder to C:\wamp\bin\apache\Apache2.4.4\bin
- Go to the bin folder and open the command prompt there (C:\wamp\bin\apache\Apache2.4.4\bin)
- Now we are going to create a server.key file using a command: openssl genrsa -des3 -out server.key 1024 then you will prompt to enter a pass-phrase so keep remembering this key that you are going to enter.
- Keep a copy of the server.key file that you created on step four using the following command.
copy server.key server.key.org
openssl rsa -in server.key.org -out server.key
- Now we need to generate a certificate for https so, we can use X.509 certificate structure in order to generate a X.509 certificate. It issues the certificate to bind with the public key. In the command the validation period is for 365 days.
openssl req -new -x509 -nodes -sha1 -days 365 -key server.key -out
- Now the certificate file has been generated already. I hope you have supplied the details while gener-ating the certificate. Sample is shown in the above image.
- Now the generated server.crt and server.key files need to be moved to the,
C:\wamp\bin\apache\Apache2.4.4\conf directory. Before that make two directories called ssl.crt and ssl.key.
Then copy the server.key and server.crt (C:\wamp\bin\apache\Apache2.4.4\bin) to the relevant fold-ers which have been created earlier.
- Now we need to configure the httpd.conf, php.ini, httpd_ssl.cnf files in order to set secure socket to the web server.
- Open the httpd.conf file and do the following changes to call to the particular modules that are need-ed to import SSL.
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
LoadModule ssl_module modules/mod_ssl.so
After find those lines you can see “#” beginning of the lines, so remove those # and save the current configuration.
- Open the http.ini file (C:\wamp\bin\php\php5.4.16) remove the comment “;” from the following line. extension=php_openssl.dll
- Open the httpd_ssl.conf file and change the following lines. (C:\wamp\bin\apache\Apache2.4.4\conf\extra)
DocumentRoot -> DocumentRoot “C:/wamp/www/”
ServerName -> ServerName localhost:443
ErrorLog -> ErrorLog “C:/wamp/bin/apache/Apache2.4.4/logs/sslerror.log”
TransferLog -> TransferLog “C:/wamp/bin/apache/Apache2.4.4/logs/sslaccess.log”
SSLCertificateFile -> SSLCertificateFile “C:/wamp/bin/apache/Apache2.4.4/conf/ssl.crt/server.crt”
SSLCertificateKeyFile -> SSLCertificateKeyFile “C:\wamp\bin\apache\Apache2.4.4\conf\ssl.key\server.key”
<Directory> ….. </DIrectory> -> <Directory “C:/wamp/www/”> Options Indexes FollowSymLinks MultiViewsAl-lowOverride All Order allow,deny allow from all SSLOptions +StdEnvVars </Directory>
- Now you can check Https is working, get the command window from the C:/wamp/bin/apache/ Apache2.4.4/ then type httpd -t and check if you are getting Sysntax is OK like the screenshot given below.
- Now restart all the services in WAMP server and try to load https://localhost/