How to Install Lighttpd on Ubuntu / Debian

setup Lighttpd on Ubuntu Debian

Lighttpd is a lightweight web server that is fast, efficient, and easy to configure. It is a good choice for small to medium-sized websites, and it can also be used as a reverse proxy for larger websites.

In this article, we will show you how to install Lighttpd on a Debian or Ubuntu server. We will also show you how to configure Lighttpd to serve a simple website.

Prerequisites

Before you can install Lighttpd, you will need to have the following prerequisites:

  • A Debian or Ubuntu server with a working internet connection
  • A user account with sudo privileges

Step 1: Update the system packages

The first step is to update the system packages. This will ensure that you have the latest versions of the software that Lighttpd depends on.

$ sudo apt update
$ sudo apt upgrade

Step 2: Install Lighttpd

Once the system packages are updated, you can install Lighttpd.

$ sudo apt install lighttpd

Step 3: Configure Lighttpd

The default configuration for Lighttpd is located in the /etc/lighttpd/lighttpd.conf file. You can edit this file to configure Lighttpd to serve your website.

For a simple website, you can use the following configuration:

server.document-root = /var/www/html

This tells Lighttpd to serve the website files from the /var/www/html directory.

You can also configure Lighttpd to use a different port than the default port 80. To do this, add the following line to the lighttpd.conf file:

server.port = 8080
  • Create a new directory for your website:
$ mkdir /var/www/html
  • Create a new file in the directory called index.html and paste the following code:
<!DOCTYPE html>
<html>
    <head>
        <title>My Website</title>
    </head>
    <body>
        <h1>Welcome to my website!</h1>
    </body>
</html>

Step 4: Start Lighttpd

Once you have configured Lighttpd, you can start the service.

$ sudo systemctl start lighttpd

Step 5: Test the website

Once Lighttpd is started, you can test the website by opening a web browser and navigating to the server’s IP address or domain name. For example, if the server’s IP address is 192.168.1.100, you would open a web browser and navigate to http://192.168.1.100.

If you have configured Lighttpd correctly, You should see the following page:

<!DOCTYPE html>
<html>
    <head>
        <title>My Website</title>
    </head>
    <body>
        <h1>Welcome to my website!</h1>
    </body>
</html>

Conclusion

In this article, we have shown you how to install Lighttpd on a Debian or Ubuntu server. We have also shown you how to configure Lighttpd to serve a simple website.

For more information about Lighttpd, you can visit Lighttpd official website: https://www.lighttpd.net/.

LEAVE A COMMENT