FedoraRHEL Based

How To Install Lighttpd on Fedora 39

Install Lighttpd on Fedora 39

In this tutorial, we will show you how to install Lighttpd on Fedora 39. Lighttpd, pronounced “lighty” is an open-source web server known for its speed, security, and flexibility. It‘s designed to handle large numbers of concurrent requests with low system resource usage, making it suitable for high-traffic web applications.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Lighttpd web server on a Fedora 39.

Prerequisites

Before diving into the installation process, let’s ensure that you have everything you need:

  • A server running one of the following operating systems: Fedora 39.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • You will need access to the terminal to execute commands. Fedora 39 provides the Terminal application for this purpose. It can be found in your Applications menu.
  • You’ll need an active internet connection to download Lighttpd and its dependencies.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Lighttpd on Fedora 39

Step 1. First, update your system packages to the latest versions. Open the terminal and execute the following command:

sudo dnf clean all
sudo dnf update

Step 2. Adding the Lighttpd Repository.

To install Lighttpd, you need to add the EPEL (Extra Packages for Enterprise Linux) repository to your Fedora system. The EPEL repository contains additional packages, including Lighttpd, that are not included in the default Fedora repositories. Run the following command to add the EPEL repository:

sudo dnf install epel-release

Step 3. Installing Lighttpd on Fedora 39.

With the EPEL repository added, you can now install Lighttpd. Execute the following command:

sudo dnf install lighttpd

After the installation, start the Lighttpd service using the following command:

sudo systemctl start lighttpd

To ensure Lighttpd starts automatically at system boot, enable it with this command:

sudo systemctl enable lighttpd

Step 4. Configuration Lighttpd.

  • Basic Configuration

Lighttpd’s default configuration file is located at /etc/lighttpd/lighttpd.conf. This file contains various settings, such as the server port and document root. Open the file with a text editor of your choice, for example, nano:

sudo nano /etc/lighttpd/lighttpd.conf
  • Configuring Virtual Hosts

Virtual hosts allow you to host multiple websites on a single server. To set up virtual hosts in Lighttpd, you need to modify the configuration file. The following is an example of a virtual host configuration:

$HTTP["host"] == "www.example.com" {
  server.document-root = "/var/www/example.com"
}
  • Configuring SSL/TLS

SSL/TLS is essential for securing connections to your web server. To configure SSL/TLS in Lighttpd, you first need to obtain an SSL certificate. You can get a free SSL certificate from Let’s Encrypt. After obtaining the certificate, add the following lines to the configuration file:

$SERVER["socket"] == ":443" {
  ssl.engine = "enable"
  ssl.pemfile = "/etc/lighttpd/certs/example.com.pem"
}
  • Optimizing Performance

To optimize Lighttpd for high loads and maximum throughput, consider settings like:

  • Increasing server.max-fds to allow more open files/connections.
  • Enabling server.stat-cache-engine for improved caching.
  • Setting server.max-worker to handle more parallel connections.
  • Enabling server.event-handler and server.network-backend for better scalability.

For example:

server.max-fds = 8192
server.stat-cache-engine = "simple"
server.max-worker = 128
server.event-handler = "linux-sysepoll"
server.network-backend = "linux-sendfile"

Step 5. Configure Lighttpd to Use PHP-FPM.

First, you need to install PHP-FPM (FastCGI Process Manager) on your Fedora 39 system. You can do this using the DNF package manager:

sudo dnf install php-fpm

After installing PHP-FPM, you need to start the service and enable it to start on boot:

sudo systemctl start php-fpm
sudo systemctl enable php-fpm

Next, you need to configure Lighttpd to use PHP-FPM. This involves editing the Lighttpd configuration file, typically located at /etc/lighttpd/lighttpd.conf. First, make sure the fastcgi module is enabled in the server modules list:

server.modules = (
    "mod_fastcgi",
    # other modules...
)

Then, add a FastCGI server configuration for PHP-FPM. This tells Lighttpd to pass PHP requests to PHP-FPM. Replace "/run/php-fpm/www.sock" with the path to your PHP-FPM socket file, which is typically located at /var/run/php-fpm/www.sock or /run/php-fpm/www.sock:

fastcgi.server += ( ".php" =>
    ((
        "socket" => "/run/php-fpm/www.sock",
        "broken-scriptfilename" => "enable"
    ))
)

After making these changes, you need to restart Lighttpd for the changes to take effect:

sudo systemctl restart lighttpd

Finally, you should test that PHP processing is working correctly. You can do this by creating a PHP file in your web root directory (e.g., /var/www/html) with the following content:

<?php phpinfo(); ?>

Then, navigate to this file in your web browser. If PHP is configured correctly, you should see a page displaying information about your PHP configuration.

Congratulations! You have successfully installed Lighttpd. Thanks for using this tutorial for installing the Lighttpd web server on your Fedora 39 system. For additional or useful information, we recommend you check the official Lighttpd website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button