Install Lighttpd on Rocky Linux 8 | Best Web Server

Posted on

Install Lighttpd on Rocky Linux 8 | Best Web Server

Install Lighttpd on Rocky Linux 8 | Best Web Server

In this guide from Orcacore, we aim to demonstrate how to Install Lighttpd on Rocky Linux 8. Lighttpd is a lightweight, open-source web server software renowned for its efficiency. It’s specifically designed for environments where resources are constrained, consuming minimal CPU and RAM. Moreover, it’s compatible with both Windows and Linux Operating Systems (OSs).

Lighttpd is engineered for security, speed, standards compliance, and flexibility, making it ideal for speed-critical applications. Its small memory footprint (compared to other web servers), low CPU usage, and emphasis on speed make Install Lighttpd on Rocky Linux 8 an attractive option for servers experiencing load issues.

Easy Steps To Install Lighttpd on Rocky Linux 8

To successfully install the Lighttpd web server, you need to access your server as a non-root user with sudo privileges and configure a basic firewall. For guidance on this, refer to our article on Initial Server Setup with Rocky Linux 8.

Now, proceed with the following steps to complete the installation of Install Lighttpd on Rocky Linux 8.

Install Lighttpd Web Server on Rocky Linux 8

You can install Lighttpd by enabling the EPEL repository on your Rocky Linux 8 system. First, update your local package index using the following command:

sudo dnf update -y

Next, install the EPEL repository by executing the command below:

sudo dnf install epel-release

Now, install Lighttpd using the following command:

sudo dnf install lighttpd -y

Start and Enable Lighttpd Service

Once the installation is complete, start the Lighttpd service with the command:

sudo systemctl start lighttpd

Then, enable the service to start automatically on boot:

sudo systemctl enable lighttpd

Verify that the Lighttpd service is active and running on Rocky Linux 8 by running the following command:

sudo systemctl status lighttpd

The output should resemble:

**Output**
lighttpd.service - Lightning Fast Webserver With Light System Requirements
Loaded: loaded (/usr/lib/systemd/system/lighttpd.service; enabled; vendor pr>
Active: **active** (**running**) since Sat 2022-01-08 08:13:18 EST; 1min 46s ago
Main PID: 88659 (lighttpd)
Tasks: 1 (limit: 11409)
Memory: 1.1M
CGroup: /system.slice/lighttpd.service
└─88659 /usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf

To check the Lighttpd version on Rocky Linux 8, use the following command:

lighttpd -v

The output will be similar to:

**Output**
lighttpd/1.4.55 (ssl) - a light and fast webserver

Configure Firewall Rules for Lighttpd

Assuming firewalld is enabled, you need to allow HTTP and HTTPS traffic through the Rocky Linux firewall:

# sudo firewall-cmd --permanent --zone=public --add-service=http
# sudo firewall-cmd --permanent --zone=public --add-service=https

Reload the firewall to apply the new rules:

sudo firewall-cmd --reload

Now, access the Lighttpd default page by entering your server’s IP address in a web browser:

http://Your-IP-addr

You should see the Lighttpd default page.

Install Lighttpd on Rocky Linux 8

Configure Lighttpd Web Server

By default, Lighttpd is configured via the /etc/lighttpd/lighttpd.conf file. The configuration options are explained in detail within the file itself.

The content of the server is the "Document root", which is where the HTML files reside. In Apache, this directory is:

/var/www/html/

Saving a file there allows access using the server’s IP address:

http://localhost/
Or
http://SERVER-IP_Address/

For more information, visit the Lighttpd Documentation page.

Remove Lighttpd from Rocky Linux 8

If you no longer require Lighttpd, you can remove it. First, stop the Lighttpd service:

sudo systemctl stop lighttpd

Then, remove it using the command:

sudo dnf remove lighttpd -y

Conclusion

This guide has walked you through the steps to Install Lighttpd on Rocky Linux 8. The installation process is straightforward using dnf, and with minimal configuration, Lighttpd can be rapidly deployed. It’s a suitable choice for developers or system administrators who need a lightweight alternative to more resource-intensive web servers like Apache or Nginx.

We hope you found this helpful. You might also be interested in:

Alternative Installation Methods for Lighttpd on Rocky Linux 8

While using dnf and the EPEL repository is a common and straightforward method to Install Lighttpd on Rocky Linux 8, alternative approaches exist. Here are two different methods, along with explanations and code examples:

1. Compile from Source:

This method provides the most control over the installation process and allows for customization and optimization. However, it requires more technical expertise and can be more time-consuming.

  • Explanation: Compiling from source involves downloading the Lighttpd source code, configuring the build process, and then compiling and installing the software. This allows you to specify compile-time options and choose specific versions of dependencies.

  • Steps:

    1. Install Development Tools: You’ll need a C compiler (like GCC), make, and other development tools.
    sudo dnf groupinstall "Development Tools"
    1. Install Dependencies: Identify and install the necessary dependencies for Lighttpd. This may include libraries like pcre, zlib, and openssl-devel. Consult the Lighttpd documentation for the complete list for your desired configuration.
    sudo dnf install pcre-devel zlib-devel openssl-devel bzip2-devel
    1. Download Source Code: Download the latest Lighttpd source code from the official website (lighttpd.net).
    wget https://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.69.tar.gz
    tar -xvzf lighttpd-1.4.69.tar.gz
    cd lighttpd-1.4.69
    1. Configure the Build: Use the ./configure script to set up the build process. You can specify installation directories and enable/disable features.
    ./configure --prefix=/opt/lighttpd --with-openssl --with-pcre
    1. Compile and Install: Run make to compile the code, and then make install to install Lighttpd.
    make
    sudo make install
    1. Create a Systemd Service File: Because it was installed outside of the dnf package manager, you’ll need to create a systemd service file. Create a file named /etc/systemd/system/lighttpd.service with the following content (adjust paths as needed):
    [Unit]
    Description=Lightning Fast Webserver With Light System Requirements
    After=network.target
    
    [Service]
    ExecStart=/opt/lighttpd/sbin/lighttpd -f /opt/lighttpd/etc/lighttpd.conf
    ExecStop=/opt/lighttpd/sbin/lighttpd -k stop -f /opt/lighttpd/etc/lighttpd.conf
    Restart=on-failure
    User=root
    Group=root
    
    [Install]
    WantedBy=multi-user.target
    1. Enable and Start the Service:
    sudo systemctl enable lighttpd
    sudo systemctl start lighttpd

2. Using a Container (Docker/Podman):

This method provides isolation and portability, making it easier to manage Lighttpd and its dependencies.

  • Explanation: Containerization involves packaging Lighttpd and its dependencies into a self-contained unit called a container. This container can then be easily deployed and run on any system with a container runtime (like Docker or Podman).

  • Steps (using Docker):

    1. Install Docker: If you don’t have Docker installed, install it using the official Docker documentation for Rocky Linux.

    2. Create a Dockerfile: Create a file named Dockerfile in an empty directory with the following content:

    FROM rockylinux:8
    
    RUN dnf update -y && dnf install -y lighttpd
    
    EXPOSE 80 443
    
    CMD ["/usr/sbin/lighttpd", "-D", "-f", "/etc/lighttpd/lighttpd.conf"]
    • Explanation of Dockerfile:
      • FROM rockylinux:8: Specifies the base image (Rocky Linux 8).
      • RUN dnf update -y && dnf install -y lighttpd: Updates the package index and installs Lighttpd.
      • EXPOSE 80 443: Exposes ports 80 and 443 for HTTP and HTTPS traffic.
      • CMD ["/usr/sbin/lighttpd", "-D", "-f", "/etc/lighttpd/lighttpd.conf"]: Specifies the command to run when the container starts (starts Lighttpd in daemon mode).
    1. Build the Docker Image: Build the Docker image using the docker build command.
    docker build -t lighttpd-rocky .
    1. Run the Docker Container: Run the Docker container using the docker run command. Map ports 80 and 443 on the host to the container.
    docker run -d -p 80:80 -p 443:443 lighttpd-rocky
    1. Access Lighttpd: Access Lighttpd by browsing to your server’s IP address (same as the original instructions).

These alternative methods offer different levels of control and complexity. Choosing the right method depends on your specific needs and technical expertise. Compiling from source provides the most customization, while using a container simplifies deployment and management. Remember to consult the official Lighttpd documentation for detailed information and troubleshooting.

Leave a Reply

Your email address will not be published. Required fields are marked *