Developing Websites Locally with mkcert
When developing websites locally, it's important to have a secure connection, even if the site isn't live yet. One way to do this is by using the mkcert tool to create SSL certificates for your domain. This article will show you how to use mkcert to create SSL certificates for your local development environment.
What is mkcert?
mkcert is a simple tool that can be used to create a local CA and generate locally-trusted SSL certificates. It is written in Go and can be used on Windows, Mac, and Linux.
Installing mkcert
To install mkcert, you can use the following command:
$ curl -L https://github.com/FiloSottile/mkcert/releases/download/v1.4.3/mkcert-v1.4.3-darwin-amd64 > mkcert
$ chmod +x mkcert
This will download the latest version of mkcert for Mac and make it executable. You can then move it to a location in your PATH, such as /usr/local/bin.
Creating SSL Certificates with mkcert
To create SSL certificates for your local development environment, you can use the following command:
$ sudo mkcert -install
$ mkcert project.local
This will create a root CA and install it on your system, and then create a new SSL certificate for the domain project.local. The new SSL certificate will be saved to the current working directory.
Pointing the Domain to Your Local Host
Once you have created the SSL certificate, you need to point the domain to your local host. On Mac, you can do this by editing the /private/etc/hosts file and adding the following line:
127.0.0.1 project.local
Using the SSL Certificate
Now that you have created the SSL certificate and pointed the domain to your local host, you can use the SSL certificate in your development environment. For example, if you are using Apache, you can add the following lines to your virtual host configuration:
SSLEngine on
SSLCertificateFile /path/to/cert.pem
SSLCertificateKeyFile /path/to/key.pem
- mkcert is a simple tool for creating locally-trusted SSL certificates
- It can be installed on Windows, Mac, and Linux
- To create SSL certificates for a local development environment, use the command
mkcert domain.local - Point the domain to your local host by editing the
/private/etc/hostsfile - Use the SSL certificate in your development environment by configuring your web server to use the certificate and key files