{"id":49,"date":"2024-09-27T14:36:20","date_gmt":"2024-09-27T14:36:20","guid":{"rendered":"https:\/\/blog.akbv.dev\/?p=49"},"modified":"2024-09-27T14:51:19","modified_gmt":"2024-09-27T14:51:19","slug":"how-to-generate-ssl-certificate-and-enable-https-in-wamp-server","status":"publish","type":"post","link":"https:\/\/blog.akbv.dev\/?p=49","title":{"rendered":"How to Generate SSL Certificate and Enable HTTPS in WAMP Server"},"content":{"rendered":"\n<p>In this guide, I will explain how to generate an SSL certificate using OpenSSL and enable HTTPS on your WAMP (Windows, Apache, MySQL, PHP) server. This will allow you to access your local websites securely over SSL.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-1-generate-ssl-certificate-using-openssl\"><a href=\"https:\/\/akbv.dev\/blog\/enable-https-in-wamp-server#step-1-generate-ssl-certificate-using-openssl\"><\/a>Step 1: Generate SSL certificate using OpenSSL<\/h2>\n\n\n\n<p>Make sure you have WAMP Server installed on your computer.<\/p>\n\n\n\n<p>Add the OpenSSL bin directory to the system&#8217;s PATH variable:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Open the system&#8217;s Environment Variables settings.<\/li>\n\n\n\n<li>Under the &#8220;System variables&#8221; section, find the &#8220;Path&#8221; variable and click on &#8220;Edit&#8221;.<\/li>\n\n\n\n<li>Add the path to the OpenSSL bin directory (e.g.,&nbsp;<code>C:\\wamp64\\bin\\apache\\apache2.4.27\\bin<\/code>) at the end of the &#8220;Variable value&#8221; field.<\/li>\n\n\n\n<li>Click &#8220;OK&#8221; to save the changes.<\/li>\n<\/ul>\n\n\n\n<p>Open a command prompt (CMD) and navigate to your user directory where you want to generate the SSL certificate. You can do this by running the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>cd C:\\Users\\%YOUR_USERNAME%<\/code><\/code><\/pre>\n\n\n\n<p>Create a new directory named&nbsp;<code>.openssl<\/code>&nbsp;by running the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>mkdir .openssl<\/code><\/code><\/pre>\n\n\n\n<p>Navigate to the newly created&nbsp;<code>.openssl<\/code>&nbsp;directory by running the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>cd .openssl<\/code><\/code><\/pre>\n\n\n\n<p>Generate the private key and the certificate files by running the following commands in the command prompt:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>openssl genrsa -aes256 -out private.key 2048 openssl rsa -in private.key -out private.key openssl req -new -x509 -nodes -sha1 -key private.key -out certificate.crt -days 36500 -config c:\\wamp64\\bin\\apache\\apache2.4.27\\conf\\openssl.cnf<\/code><\/code><\/pre>\n\n\n\n<p>This will generate a private key file named&nbsp;<code>private.key<\/code>&nbsp;and a certificate file named&nbsp;<code>certificate.crt<\/code>. Make sure to answer the questions during the certificate generation process, with &#8220;localhost&#8221; as the FQDN (Fully Qualified Domain Name).<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-2-configure-wamp-server-to-use-the-ssl-certificate\"><a href=\"https:\/\/akbv.dev\/blog\/enable-https-in-wamp-server#step-2-configure-wamp-server-to-use-the-ssl-certificate\"><\/a>Step 2: Configure WAMP Server to use the SSL certificate<\/h2>\n\n\n\n<p>Copy the generated&nbsp;<code>private.key<\/code>&nbsp;and&nbsp;<code>certificate.crt<\/code>&nbsp;files from the&nbsp;<code>.openssl<\/code>&nbsp;directory to the&nbsp;<code>C:\\wamp64\\bin\\apache\\apache2.4.27\\conf\\key\\<\/code>&nbsp;directory. If the&nbsp;<code>key<\/code>&nbsp;directory doesn&#8217;t exist, create it.<\/p>\n\n\n\n<p>Open the&nbsp;<code>httpd.conf<\/code>&nbsp;file located in the&nbsp;<code>C:\\wamp64\\bin\\apache\\apache2.4.27\\conf\\<\/code>&nbsp;directory.<\/p>\n\n\n\n<p>Uncomment the following lines by removing the&nbsp;<code>#<\/code>&nbsp;character at the beginning of each line:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>LoadModule ssl_module modules\/mod_ssl.so Include conf\/extra\/httpd-ssl.conf LoadModule socache_shmcb_module modules\/mod_socache_shmcb.so<\/code><\/code><\/pre>\n\n\n\n<p>Open the&nbsp;<code>httpd-ssl.conf<\/code>&nbsp;file located in the&nbsp;<code>C:\\wamp64\\bin\\apache\\apache2.4.27\\conf\\extra\\<\/code>&nbsp;directory.<\/p>\n\n\n\n<p>Update the following configuration parameters based on your setup:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>DocumentRoot<\/code>: Set it to the directory where your web files are located (e.g.,&nbsp;<code>c:\/wamp64\/www<\/code>).<\/li>\n\n\n\n<li><code>ServerName<\/code>: Set it to&nbsp;<code>localhost:443<\/code>.<\/li>\n\n\n\n<li><code>ServerAdmin<\/code>: Set it to your email address.<\/li>\n\n\n\n<li><code>SSLCertificateFile<\/code>: Set it to the path of the&nbsp;<code>certificate.crt<\/code>&nbsp;file.<\/li>\n\n\n\n<li><code>SSLCertificateKeyFile<\/code>: Set it to the path of the&nbsp;<code>private.key<\/code>&nbsp;file.<\/li>\n<\/ul>\n\n\n\n<p>If you have multiple virtual hosts, you can add them in the&nbsp;<code>httpd-ssl.conf<\/code>&nbsp;file using the provided configuration template.<\/p>\n\n\n\n<p>Save the changes and close the file.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-3-test-and-restart-wamp-server\"><a href=\"https:\/\/akbv.dev\/blog\/enable-https-in-wamp-server#step-3-test-and-restart-wamp-server\"><\/a>Step 3: Test and Restart WAMP Server<\/h2>\n\n\n\n<p>Open a command prompt and navigate to the directory where WAMP Server is installed (e.g.,&nbsp;<code>C:\\wamp64\\bin\\apache\\apache2.4.27\\bin<\/code>).<\/p>\n\n\n\n<p>Run the following command to test the configuration:<code>httpd -t <\/code>This command will check if there are any syntax errors in the Apache configuration files. If everything is fine, you will see a &#8220;Syntax OK&#8221; message.<\/p>\n\n\n\n<p>Restart the WAMP Server from the system tray icon to apply the configuration changes.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-4-access-your-local-websites-over-https\"><a href=\"https:\/\/akbv.dev\/blog\/enable-https-in-wamp-server#step-4-access-your-local-websites-over-https\"><\/a>Step 4: Access your local websites over HTTPS<\/h2>\n\n\n\n<p>Open a web browser and enter&nbsp;<code>https:\/\/localhost<\/code>&nbsp;or&nbsp;<code>https:\/\/example.com<\/code>&nbsp;(replace&nbsp;<code>example.com<\/code>&nbsp;with your virtual host&#8217;s ServerName or ServerAlias) in the address bar.<\/p>\n\n\n\n<p>You may see a warning in the browser indicating that the certificate is not valid. This is because the certificate is self-signed. Add an exception for the certificate in your browser to proceed.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><\/li>\n<\/ol>\n\n\n\n<p>Congratulations! You have successfully generated an SSL certificate and enabled HTTPS on your WAMP Server. Now you can access your local websites securely over SSL.<\/p>\n\n\n\n<p>Please note that this certificate is self-signed and will not be trusted by browsers. It is intended for local development purposes only. In a production environment, you should obtain a valid SSL certificate from a trusted certificate authority (CA).<\/p>\n\n\n\n<p>If you found this guide helpful, consider&nbsp;<a target=\"_blank\" rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/sponsors\/a-kbv\">buying me a coffee<\/a>. Thank you!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this guide, I will explain how to generate an SSL certificate using OpenSSL and&hellip;<\/p>\n","protected":false},"author":1,"featured_media":60,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[52,34],"tags":[48,51,10,50],"class_list":["post-49","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ssl","category-windows","tag-guide","tag-https","tag-ssl","tag-wamp"],"_links":{"self":[{"href":"https:\/\/blog.akbv.dev\/index.php?rest_route=\/wp\/v2\/posts\/49"}],"collection":[{"href":"https:\/\/blog.akbv.dev\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.akbv.dev\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.akbv.dev\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.akbv.dev\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=49"}],"version-history":[{"count":2,"href":"https:\/\/blog.akbv.dev\/index.php?rest_route=\/wp\/v2\/posts\/49\/revisions"}],"predecessor-version":[{"id":61,"href":"https:\/\/blog.akbv.dev\/index.php?rest_route=\/wp\/v2\/posts\/49\/revisions\/61"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.akbv.dev\/index.php?rest_route=\/wp\/v2\/media\/60"}],"wp:attachment":[{"href":"https:\/\/blog.akbv.dev\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=49"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.akbv.dev\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=49"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.akbv.dev\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=49"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}