create self signed certificate for website and use in linux

Within in 5 minutes you can can create self signed certificate on linux machine. First you need to open console and execute following command. Before executing following command first check openssl utility is installed on your linux machine.

# openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout mysitename.key -out mysitename.crt

Then open your apache configuration file and put following code in that file.

NameVirtualHost *:443

#purabtech.in

  ServerAdmin purabtech@gmail.com
  DocumentRoot /home/purab/public_html/purabtech.in/
  ServerName purabtech.in

  <Directory "/home/purab/public_html/purabtech.in/">
    Order Deny,Allow
    Allow from all
    AllowOverride All
  

  ErrorLog logs/purabtech.in-error_log
  CustomLog logs/purabtech.in-access_log combined
  RewriteLog logs/purabtech.in-rewrite_log

  SSLEngine on
  SSLCertificateFile /home/purab/projects/purabtech.in/self-sign/mysitename.crt
  SSLCertificateKeyFile /home/purab/projects/purabtech.in/self-sign/mysitename.key
  SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
  CustomLog logs/ssl_request_log "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

Additional:
For gettting pem certificate from ssl cert.
openssl x509 -in mysitename.crt -out mysitename.pem -outform PEM

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

Leave a Reply

Your email address will not be published.