Enabling https (SSL) on LAMPP (XAMPP) at ubuntu 18.04 (Linux)

To enable the https e.g. SSL request on XAMPP/LAMPP at ubuntu 18.04 linux system please follow the instructions below.

  • Stop the server if running.
  • Create SSL files for 10 years:

sudo openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout Documents/https_ssl.key -out Documents/https_ssl.crt

  • Enter some of the SSL certificate information to create the SSL files.
  • Open the file to add vhost for the https host:

sudo nano /opt/lampp/etc/extra/httpd-vhosts.conf

  • Write the following scripts and save the file:

# Non-SSL or http hosts<VirtualHost *:80>       DocumentRoot “/opt/lampp/htdocs/”       ServerName localhost</VirtualHost>
<VirtualHost *:80>       DocumentRoot “/opt/lampp/htdocs/test/”       ServerName test.localhost</VirtualHost>
# SSL or https Hosts<VirtualHost *:443>       DocumentRoot “/opt/lampp/htdocs/test/”       ServerName test.localhost       SSLEngine on       SSLCertificateFile “/home/user_name/Documents/https_ssl.crt”       SSLCertificateKeyFile “/home/user_name/Documents/https_ssl.key”</VirtualHost>

  • Open the file to uncomment the Include etc/extra/httpd-vhosts.conf line and save it:

sudo nano +488 /opt/lampp/etc/httpd.conf

Note: Please remember, you have to add the exception for self signed certificates.

Similar Posts