Today this article is all about,

“Create a Self-Signed SSL Certificate for Apache2 HTTP in Ubuntu 18.04”.

You don’t need publicly signed SSL/TLS certificates. However, recently I am working on one of my projects, and in that project, I need to work with a webcam. In that scenario, I need SSL/TLS certificates during internal testing in development environments.

I have only one option is to use self-signed certificates…

It’s a mechanism that allows private communication between two network devices. It creates a secure connection between web server and web clients and many others network services…

There are two types of certificates: A public and private certificates…

On a website, we are using public certificates and for internally private or self-signed for testing purpose.

STEP 1: Install APACHE2 HTTP Server

If you don’t have APACHE2 HTTP installed, Simply type below command in your terminal. This command helps you to install APACHE2 HTTP server on Ubuntu 18.04.

Step 2: Creating Self-Signed Certificates

When you can’t install or afford trusted certificates from a certificate authority, you may get by with self-signed certificates. Both trusted, and self-signed certificates are the same and use the same protocols… the only difference is, one is trusted by a third party, and the other is not.

When you’re ready, run the commands below to generate the private server key as well as the self-signed SSL/TLS certificate for the domain… you’ll be using.

Note: is my server name 


After running the commands above, you’ll be prompted to answer a few questions about the certificate you’re generating… answer them and complete the process.

Note: change red text according to your preferences

Step 3: Installing The Certificates

After generating the certificate, the next step will be to install it on an Apache2 server. To do that, open Apache2 SSL/TLS config file in Ubuntu and add the highlighted lines below…

Save and close it.

Next, open Apache2 default site config file and make sure the domain name is defined.

Or else you can create the separate file.

You will see, follow the instructions,

Create a Self-Signed SSL Certificate for Apache2 HTTP in Ubuntu 18.04

Create a Self-Signed SSL Certificate for Apache2 HTTP in Ubuntu 18.04

Step 4: Redirect


Add below a line,

Save and close the file.

Restart Apache2 and check again.

That’s it. cheers.

Happy Coding!


Please enter your comment!
Please enter your name here