Lighttpd, often pronounced as “lighty”, is a popular open-source web server, known for its speed, flexibility, and security. It’s particularly well-suited for high-demand environments, managing a large number of parallel connections with minimal memory usage. In this article, we’ll guide you through the step-by-step process of installing Lighttpd on openSUSE, a Linux-based operating system.

Installing Lighttpd on openSUSE

Step 1: System Update

First, keep your system updated for optimal security and performance. Refresh your package repository list to access the latest software versions.

sudo zypper refresh
sudo zypper update

Step 2: Lighttpd Installation

With the system updated, proceed to install Lighttpd using the ‘zypper’ package manager.

sudo zypper install lighttpd

Post-installation, verify if Lighttpd is installed successfully by checking its version.

lighttpd -v

Step 3: Lighttpd Configuration

Now, configure Lighttpd to function as intended. Open the main configuration file using your preferred text editor.

sudo nano /etc/lighttpd/lighttpd.conf

In this file, adjust server modules, set your document root, and configure other crucial settings. If you’re hosting multiple websites, consider setting up virtual hosting by defining separate blocks for each domain within the configuration file.

Step 4: Configuring PHP

With PHP 8’s optimizations and new features, it’s a good idea to install it along with FastCGI to handle PHP processing.

sudo zypper install php8 php8-fastcgi

Verify the installation by checking the PHP version.

php -v

To integrate PHP with Lighttpd, enable the FastCGI module and configure it to use PHP.

sudo nano /etc/lighttpd/conf.d/fastcgi.conf

Ensure the following configuration is present to use PHP through FastCGI.

fastcgi.server += ( ".php" =>
(( 
"bin-path" => "/usr/bin/php-cgi",
"socket" => "/tmp/php.socket"
))
)

Apply the changes by restarting Lighttpd.

sudo systemctl restart lighttpd

Step 5: Firewall Configuration

Ensure that ‘firewalld’ is installed on your system. If not, install it using the following command.

sudo zypper install firewalld

Start the ‘firewalld’ service and enable it to start on boot.

sudo systemctl start firewalld
sudo systemctl enable firewalld

To check the active zones, use:

sudo firewall-cmd --get-active-zones

Allow traffic to ports 80 (HTTP) and 443 (HTTPS) by adding the ‘http’ and ‘https’ services to your active zone.

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

Reload ‘firewalld’ to apply the changes.

sudo firewall-cmd --reload

Step 6: Testing the Configuration

To verify your setup, create a PHP info file.

echo "<?php phpinfo(); ?>" > /srv/www/htdocs/info.php

Access this file from a web browser by navigating to http://your_server_ip/info.php. You should see the PHP information page, indicating successful setup.

You have successfully installed Lighttpd on openSUSE. For additional information or useful resources, visit the officialLighttpd website.

If you’re looking for a reliable hosting service for your openSUSE server, consider using Shape.host. They offer Linux SSD VPS, providing high performance and security for your applications.