Skip to content

Instantly share code, notes, and snippets.

@muthuishere
Last active July 2, 2022 22:59
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save muthuishere/c1ed5a59f92809b1b3d7ae293e52102b to your computer and use it in GitHub Desktop.
Save muthuishere/c1ed5a59f92809b1b3d7ae293e52102b to your computer and use it in GitHub Desktop.
Setup SSL on WAMP for virtual server Virtual hosts on wamp
set WAMP_INSTALL_LOCATION="c:\wamp" #modify
1. Open command prompt as admin Goto %WAMP_INSTALL_LOCATION%\bin\apache\apache2.x.x\bin>
2. Type => set OPENSSL_CONF=%WAMP_INSTALL_LOCATION%\bin\apache\apache2.x.x\conf\openssl.cnf
3. Create self signed certificate
Type => openssl req -nodes -new -x509 -keyout server.key -out server.crt
#Note if you get ordinal error , open ssl should be changed download it from http://slproweb.com/products/Win32OpenSSL.html based on 32 bit or 64 bit , select light version(Winxx OpenSSL v1.1.0b Light) and make sure to set libraries under install location rather than system32 folder
After installation copy openssl.exe & dlls from the installation folder and replace on %WAMP_INSTALL_LOCATION%\bin\apache\apache2.x.x\bin
Copy server.crt to folder %WAMP_INSTALL_LOCATION%\bin\apache\apache2.x.x\conf\cert\
Copy server.key to folder %WAMP_INSTALL_LOCATION%\bin\apache\apache2.x.x\conf\key\
4. Edit %WAMP_INSTALL_LOCATION%\bin\apache\apachex.x.x\conf\httpd.conf
Uncomment (remove #) => Ssl_module LoadModule modules / mod_ssl .so
uncomment (remove #) => LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
Uncomment (remove #) => Include conf/extra/httpd-ssl conf
5. Edit %WAMP_INSTALL_LOCATION%\bin\php\php5.x.x\php.ini
Uncomment(remove semicolon) => extension = php_openssl.dll
Edit %WAMP_INSTALL_LOCATION%\bin\apache\apache2.x.x\conf\extra\httpd-ssl.conf
Find the line: <VirtualHost _default_: 443> and comment whole mark and use the below syntax
<VirtualHost _default_:443>
DocumentRoot "{YOUR_VIRTUAL_HOST_FOLDER}"
ServerName virtual.local:443
ServerAdmin xxx@xxx.com
ErrorLog "%WAMP_INSTALL_LOCATION%/logs/sslerror.log"
TransferLog "%WAMP_INSTALL_LOCATION%/logs/sslaccess.log"
<Directory "{YOUR_VIRTUAL_HOST_FOLDER}">
AllowOverride All
Require local
</Directory>
SSLEngine on
SSLCertificateFile "%WAMP_INSTALL_LOCATION%/bin/apache/apache2.x.x/conf/cert/server.crt"
SSLCertificateKeyFile "%WAMP_INSTALL_LOCATION%/bin/apache/apache2.x.x/conf/key/server.key"
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory "%WAMP_INSTALL_LOCATION%/bin/apache/apache2.x.x/cgi-bin">
SSLOptions +StdEnvVars
</Directory>
BrowserMatch "MSIE [2-5]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
CustomLog "%WAMP_INSTALL_LOCATION%/logs/ssl_request.log" \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>
# to just add vhost for wamp
Uncomment from apache conf
Include conf/extra/httpd-vhosts.conf
Add two entries in conf/extra/httpd-vhosts.conf , one for existing localhost and other for new vhost order is important
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot "C:/wamp/www"
ServerName localhost
ServerAlias localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
</VirtualHost>
<VirtualHost xxx.local:80>
ServerAdmin webmaster@xxx.local
DocumentRoot "C:/muthu/gitworkspace/xxx/xxx-web"
<Directory "C:/muthu/gitworkspace/xxx/xxx-web">
Options Indexes FollowSymLinks
AllowOverride All
Require local
<IfModule mod_php5.c>
php_admin_flag engine on
php_admin_flag safe_mode off
php_admin_value open_basedir none
</ifModule>
</Directory>
ServerName xxx.local
ServerAlias xxx.local
ErrorLog "logs/xxx-web-error.log"
CustomLog "logs/xxx-web-access.log" common
</VirtualHost>
#end for adding virtual hosts
Verify all syntax from commandline
httpd -t
Add the below entry for server xxx.local at end of the hosts file ( %WINDIR%\system32\drivers\etc\hosts)
127.0.0.1 xxx.local
ReStart WAMP
Restart DNS client from services.msc
@mubassirhayat
Copy link

Awesome it helped me alot. Keep up the good work.

@garek007
Copy link

Had some trouble, but got it working. had problems in my httpd-ssl.conf file after editing. I'm on WAMP 3.0 and there is a syntax checker for that file which helped.

@dendihandian
Copy link

How to Restart DNS client from services.msc ?

@muthuishere
Copy link
Author

muthuishere commented Jun 19, 2020 via email

@Sir7lease
Copy link

After almost 4 years this thing is saving my sh*t <3

@eosobande
Copy link

which folder is "{YOUR_VIRTUAL_HOST_FOLDER}" ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment