Install Lighttpd web server in Ubuntu 18.04 LTS and CentOS

Lighttpd is an open source web server which is secure, fast, compliant, and very flexible and is optimized for high-performance environments. It uses very low memory compared to other web servers, small CPU load and speed optimization making it popular among the server for its efficiency and speed. Its advanced feature-set (FastCGI, CGI, Auth, Output-Compression, URL-Rewriting and many more) makes Lighttpd the perfect webserver-software for every server that suffers load problems.

Here are some simple easy setups on how we can setup Lighttpd web server on our machine running Ubuntu 18.04 LTS Bionic Beaver or CentOS 7.

Installing Lighttpd

Installing using Package Manager

Here, we’ll install Lighttpd using package manager as its the easiest method to install it. So, we can simply run the following command under sudo mode in a terminal or console to install Lighttpd.

CentOS 7

As Lighttpd is not available in the official repository of CentOS 7, we’ll need to install epel additional repository to our system. To do so, we’ll need to run the following yum command.

# yum install epel-release

Then, we’ll gonna update our system and proceed towards the installation of Lighttpd.

# yum update
# yum install lighttpd

Ubuntu 18.04 LTS

Lighttpd is available on the official repository of Ubuntu 18.04 LTS Bionic Beaver so, we’ll simply update our local repository index and then go for the installation of Lighttpd using apt-get command.

# apt-get update
# apt-get install lighttpd

install lighttpd ubuntu

Installing from Source

If we wanna install Lighttpd from the latest version of source code ie 1.4.51, we’ll need to compile the source code and install it into our system. First of all, we’ll need to install the dependencies required to compile it.

# cd /tmp/
# wget http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.51.tar.gz

After its downloaded, we’ll need to extract it the tarball by running the following.

# tar -zxvf lighttpd-1.4.51.tar.gz

Then, we’ll compile it by running the following commands.

# cd lighttpd-1.4.51
# ./configure
# make

Note: In this tutorial, we are installing Lighttpd with its standard configuration. If you wanna configure beyond the standard configuration and want to install more features like support for SSL, mod_rewrite, mod_redirect then you can configure.

Once, its compiled, we’ll install it in our system.

# make install

Configuring Lighttpd

If we need to configure our Lighttpd web server further as our requirements, we can make changes to the default configuration file ie /etc/Lighttpd/lighttpd.conf . As we’ll go with the default configuration here in this tutorial, we’ll not gonna make changes to it. If we had made any changes and we wanna check for errors in the config file, we’ll need to run the following command.

# lighttpd -t -f /etc/lighttpd/lighttpd.conf

On CentOS 7

If we are running CentOS 7, we’ll need to create a new directory for our webroot defined in our lighttpd’s default configuration ie /src/www/htdocs/ .

# mkdir -p /srv/www/htdocs/

Then, we’ll copy the default welcome page from /var/www/lighttpd/ directory to the above-created directory.

# cp -r /var/www/lighttpd/* /srv/www/htdocs/

Starting and Enabling Services

Now, we’ll gonna restart our database server by executing the following systemctl command.

# systemctl start lighttpd

Then, we’ll enable it to start automatically in every system boot.

# systemctl enable lighttpd

Allowing the Firewall

To allow our webpages or websites running Lighttpd web server on the internet or inside the same network, we’ll need to allow port 80 from the firewall program. As both CentOS 7 and Ubuntu 18.04 are shipped with systemd as the default init system, we will have firewalld installed as a firewall solution. To allow port 80 or http service, we’ll need to run the following commands.

# firewall-cmd --permanent --add-service=http

success

# firewall-cmd --reload

success

Accessing Web Server

As we have allowed port 80 which is the default port of Lighttpd, we should be able to access lighttpd’s welcome page by default. To do so, we’ll need to point our browser to the IP address or domain of our machine running Lighttpd according to our configuration. In this tutorial, we’ll point our browser to http://domain.com as we have pointed our sub-domain to its IP address. On doing so, we’ll see the following welcome page in our browser.

Further, we can add our website’s files to the webroot directory and remove the default lighttpd’s index file to make our static website live to the internet.

Conclusion

Finally, we have successfully installed the world’s lightweight, fast and secure web server Lighttpd in our machine running CentOS 7 and Ubuntu 18.04 Linux distributions. Once its ready, we can upload our website files into our web root, configure virtual host, enable SSL, connect the database, run web apps and much more with our Lighttpd web server. If you have any questions, suggestions, feedback please write them in the comment box below so that we can improve or update our contents. If you have any questions, suggestions, feedback please don’t hesitate to write them in the comment box below because it will help us to improve or correct our contents. Thanks, Happy FOSS Computing. ?

Read More: “How to Install XAMPP Stack on Ubuntu 18.04 LTS”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.