Setting up SSL on a local xampp/apache server

To set up SSL on a local XAMPP/Apache server, you will need to generate a self-signed certificate, configure the Apache server to use the certificate, and then access the server using https. Here are the general steps:

  1. Generate a self-signed certificate: You can use the OpenSSL tool to generate a self-signed certificate. The command would be something like:
openssl req -x509 -out localhost.crt -keyout localhost.key \
  -newkey rsa:2048 -nodes -sha256 \
  -subj '/CN=localhost' -extensions EXT -config <( \
   printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")

Watch a course Learn object oriented PHP

  1. Configure the Apache server to use the certificate: In the Apache configuration file (httpd.conf or apache2.conf), you will need to specify the location of the certificate and key files, and enable the SSL module. You can do this by adding the following lines:
Listen 443

<VirtualHost _default_:443>
    DocumentRoot "C:/xampp/htdocs"
    ServerName localhost:443
    SSLEngine on
    SSLCertificateFile "C:/xampp/ssl/localhost.crt"
    SSLCertificateKeyFile "C:/xampp/ssl/localhost.key"
</VirtualHost>
  1. Restart the Apache server and access the server using https:
httpd.exe -k restart

Now you should be able to access your local server using https.

Note: This is just a simple example, for production, you will want to use a CA-signed certificate and configure Apache accordingly.