cd /etc/apache2
sudo ssh-keygen -f server.key
sudo openssl req -new -key server.key -out request.csr
sudo openssl x509 -req -days 365 -in request.csr -signkey server.key -out server.crt

The field “CommonName” of the certificate must match the ServerName directive in the Apache configuration file /etc/apache2/httpd.conf

Add the fol­low­ing to your httpd-ssl.conf to use the new certificate:

SSLCertificateFile “/etc/apache2/server.crt”
SSLCertificateKeyFile “/etc/apache2/server.key”