Lighttpd logo

SSL is cryptographic protocol, which provides secure communications on the Internet for email, web etc.

An SSL certificate is a digital certificate that authenticates the identity of a Web site and encrypts information that is sent to the server using Secure Sockets Layer (SSL) technology. Encryption is the process of scrambling data into an undecipherable format that can only be returned to a readable format with the proper decryption key.

SSL is good if you run ecommerce site or accept payments via CC. It is a good choice to use SSL for user login or registration pages etc.

To purchase a digital certificate, you must first generate and submit a Certificate Signing Request (CSR) to the Certification Authority (CA). The CSR contains your certificate-application information, including your public key. The CSR is generated (using openssl command) with your web server software, which will also create your public/private key pair used for encrypting and decrypting secure transactions.


  • Lighttpd webserver with SSL support
  • Dedicated IP assign to your domain i.e. IP based hosting needed
  • SSL certificate from CA
  • Domain name – (for example purpose I am using domain)

Important files on your server

  • /etc/lighttpd/ – Directory to store SSL certificate and related files
  • /etc/lighttpd/ – Your private key file. Never ever, give this file to anybody. This is used by Lighttpd to encrypt the server traffic.
  • /etc/lighttpd/ – You need to cut/copy and paste this file into the CSR field on the SSL certificate-request page/application form. It includes your public key.
  • /etc/lighttpd/ – This file can contain all of private keys (RSA and DSA), public keys (RSA and DSA) and (x509) certificates. Usually your keys and certificate stored in this file.

Important files issued by CA

Usually a zip file contains following files

  • CA_issuing.crt – Your intermediate certificate or chained root certificate file. An intermediate certificate is a subordinate certificate issued by the trusted root specifically to issue end-entity server certificates. The result is a chain that begins at the trusted root CA, through the intermediate certificate, and ending with the Web Server SSL certificate issued to you. The usage of an intermediate certificate thus provides an added level of security as the Certification Authority (CA) does not need to issue certificates directly from its CA root certificate.
  • – Your domain certificate

Lighttpd SSL Tutorial

Following are steps to configure SSL under Lighttpd web server.

Step # 1: Generate a certificate signing request (CSR)

First, generate a certificate-signing request using openssl command for your domain
# mkdir -p /etc/lighttpd/ssl/
# cd /etc/lighttpd/ssl/

Create a RSA key:
# openssl genrsa -des3 -out 1024

Now create a CSR:
# openssl req -new -key -out

You will be promoted to enter your domain name and other information. Please note that if you are requesting a wild card certificate, prefix an asterisk (*) symbol i.e. * This will secure all subdomains. If you just use, it will only secure domain and note

Now, you need to submit your file to CA while ordering your certificate. Next, you need to verify your domain ownership. Once your request is approved, you can download the certificate to use with Lighttpd webserver.

Step # 2: Prepare certificate

Your CA will issue you signed Web Server Certificate. The final step in the certificate request process is the installation of the certificate on your Lighttpd Web server.

Now copy downloaded certificate ( to /etc/lighttpd/ssl/
# cp /etc/lighttpd/ssl/

Now create your final pem file and setup permission:
# cat >
# chmod 0600
# chown lighttpd:lighttpd /etc/lighttpd/ssl/ -R

Optional: How do I remove the password from key file?

Lighttpd will prompt for the password while starting at port 443. You can remove the password:
# cp
# cp
# openssl rsa -in -out
# cat >

Step #3: Make sure Lighttpd support SSL

Use following command to verify that Lighttpd support SSL:
[]$ /usr/sbin/lighttpd -v
lighttpd-1.4.11 (ssl) - a light and fast webserver
Build-Date: Jul 12 2006 13:47:40

Otherwise, follow these instructions to build Lighttpd with SSL support.

Step #4: Configure Lighttpd SSL support for your domain

Now open your lighttpd configuration file
# vi /etc/lighttpd/lighttpd.conf

Add config section:
$SERVER["socket"] == "" {
ssl.engine = "enable"
ssl.pemfile = "/etc/lighttpd/" = "/etc/lighttpd/" = ""
server.document-root = "/home/lighttpd/"
server.errorlog = "/var/log/lighttpd/"
accesslog.filename = "/var/log/lighttpd/"


  • ssl.engine = “enable” : Enable lighttpd SSL support
  • ssl.pemfile = “/etc/lighttpd/” – Your PEM file
  • = “/etc/lighttpd/” – Your intermediate certificate file

Save and close the file. Restart lighttpd webserver (please note that it will prompt you for SSL private key password):
# /etc/init.d/lighttpd restart



Open a web browser and type url ( to test SSL installation.

Further readings:

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 15 comments so far... add one
CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
15 comments… add one
  • jack Aug 31, 2006 @ 23:50


    Just wanted to say ‘thank you’ for excellent set of information.

  • Joe Jan 30, 2007 @ 18:45

    Good tutorials on doing some lighttpd tasks that would usually require a significant amount of reading.

    Simple, straight forward…keep it up!

  • sidh Apr 2, 2008 @ 8:01

    How to create can somebody please write down the syntax.

  • 🐧 nixCraft Apr 2, 2008 @ 9:02

    This file issued by CA for a small amount of feed. If you don’t need CA crt generate your own self signed SSL certificates

  • Adrian May 5, 2008 @ 3:59

    Nice howto, thanks! Only problem is lighttpd wont start on boot because it needs the pass phrase. I’ve written a little bit about that here if anyone is interested.

  • Maski May 18, 2008 @ 20:03

    When I restart Lighty, it always asks me for the phrase,.. Enter PEM pass phrase:

  • 🐧 nixCraft May 18, 2008 @ 21:02

    Backup the original key and recreate the key based off the original one without a password.

    openssl rsa -in -out new.your.key
    cat new.your.key ssl.crt > ssl.pem

  • webflier Aug 16, 2008 @ 10:05

    I translated this post into Chinese.
    Let me know if I am violated your copyrights.
    If so, I will delete the translated articles.

  • kunal Jan 6, 2009 @ 7:27

    Can we use name based virtual hosting with ssl with single certificate only if yes then how

  • Sergiy Feb 13, 2009 @ 13:01

    Thank you for the manual.

    2kunal certificates are issued for single domain only (or ones for all sub-domains exist). The only way I see for single certificate on multiple domains, is to redirect users to the domain with SSL (for example to the payment page) and than return to the virtual domain.

  • frspro Mar 24, 2009 @ 15:53

    Thanks, great article, very helpful…

    I keep on getting “chown: invalid user: `lighttpd:lighttpd’ ” on the last step does anyone have any idea?

    • 🐧 nixCraft Mar 24, 2009 @ 18:02

      Use your actual username:groupname combo.

  • dave Apr 24, 2009 @ 17:21

    Which would be www-data:www-data in ubuntu.

    • 🐧 nixCraft Apr 24, 2009 @ 18:06

      They are user:group name to run server.

  • j0k Aug 16, 2012 @ 11:44

    Thanks for the tutorial.
    Btw, you should talk about the BEAST attack and include the config to add in your file (the `ssl.cipher-list`):

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum