Lighttpd is a web server that’s fast, flexible and built with security good practices. It’s designed for high performance environments and websites with very high traffic. Lighttpd allows you to run these powerful web applications with limited footprint — .
We’ve written a lot about other webservers on this blog including Nginx and Apache2. In fact this blog (liberiangeek.net) is powered by Nginx webserver. We initially had Apache2 running our WordPress site for over two years, and just little over a year ago, we switched to Nginx.
I personally think that switching to Ngjnx was a great move as our pages are loading faster without us adding more server resources. Apache2 was great but there were some issues we couldn’t resolve so we had to switch.
This brief tutorial is going to show you how to install Lighttpd webserver in CentOS 7 with PHP5 and MariaDB support. We’re installing MariaDB database server because MySQL is no long shipping with CentOS. MariaDB is not the default database server for CentOS.
When it comes to webservers, there’s Apache2, the #1 webserver powering most websites online today, Nginx the second place holder and others, including Lighttpd.
If you think your current webserver isn’t doing you any favors, you can switch to better webservers. We did switch to Nginx because we felt Nginx was going to serve us well and we were right.
Others may think Apache2 is the favorites and most supported webserver, which is true. Those who feel that way can also switch. So, there are many webservers out there that may be right for you and it won’t hurt to try them all in order to pick the one that works best for you.
If you wish to install and use Lighttpd in CentOS 7, continue below to learn how to.
- Installing Lighttpd in CentOS 7
To install Lighttpd you must enable additional repositories since it isn’t available in CentOS 7 default repository. One of the repositories Lighttpd is available in is EPEL repository.
To enable EPEL in CentOS, run the commands below to download the repository file.
cd /tmp/ && wget http://dl.fedoraproject.org/pub/epel/beta/7/x86_64/epel-release-7-1.noarch.rpm
Next, run the commands below to install the repository
sudo yum install epel-release-7-1.noarch.rpm
After that run the commands below to install Lighttpd
sudo yum install lighttpd
To start up Lighttpd webserver, run the commands below.
sudo systemctl start lighttpd.service
- Installing MariaDB In CentOS 7
Next, let’s install MariaDB in CentOS 7. We’re installing MariaDB because it’s the default database server in CentOS going forward. To install it in CentOS, run the commands below.
sudo yum install mariadb-server mariadb
To start the database, run the commands below.
sudo systemctl start mariadb.service
After installing the database, run the commands below to configure the database. This will allow you create a root password, remove the test database as well as remove the anonymous user.
sudo mysql_secure_installation
- Installing PHP5 Support in CentOS 7
Finally, install PHP5 support with other PHP modules. To do that, run the commands below.
sudo yum install php lighttpd-fastcgi php-gd php-mysql php-tidy php-xmlrpc php-common php-cli php-xml
Now that all the servers are installed, it now time to begin configuring each. First, lets configure Lighttpd so that it function properly. Right now, Lighttpd should work just fine. All you have to do is allow http traffic through the firewall.
To do that, run the commands below.
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
Reload the firewall and try connecting to the server.
sudo firewall-cmd –reload
Open your favorite web browser and connect to the server. You should see the default page for Lighttpd
The web server is working.
To verify if PHP is working, continue below.
First, open the file below and make sure the highlighted line is un-commented and value set to 1
sudo nano /etc/php.ini
Valude set as shown below.
;
cgi.fix_pathinfo=1
;
Next, open the file below and enable the fastcgi module.
sudo nano /etc/lighttpd/modules.conf
Then make sure to enable the module by un-commenting the line
##
include "conf.d/fastcgi.conf"
##
Finally, at the fine of this file, uncomment the lines as shown below.
sudo vi /etc/lighttpd/conf.d/fastcgi.conf
fastcgi.server = (
".php" => ((
"host" => "127.0.0.1",
"port" => "9000",
"broken-scriptfilename" => "enable"
))
)
Now create a test file in the root directory called phpinfo.php.
sudo vi /var/www/lighttpd/phpinfo.php
Then type the lines below into the file and save it.
<?php
phpinfo();
?>
Open your browser again and bring up the page and this time PHP test page should show.
Enjoy!
Frequently Asked Questions
What are the benefits of using Lighttpd webserver in CentOS 7?
Lighttpd is a fast and flexible web server designed for high performance environments with very high traffic. It allows you to run powerful web applications with a limited footprint, enabling faster page loading times.
How does Lighttpd compare to other popular webservers like Apache2 and Nginx?
Lighttpd offers a different approach to web serving compared to Apache2 and Nginx. While Apache2 is widely supported and used, Lighttpd is known for its speed, flexibility, and security good practices.
Why should I consider switching to Lighttpd from my current webserver?
If you feel that your current webserver is not meeting your needs in terms of performance or resource utilization, switching to Lighttpd may improve your website's speed and efficiency.
Is it possible to run PHP5 and MariaDB on Lighttpd in CentOS 7?
Yes, you can install Lighttpd with PHP5 and MariaDB support on CentOS 7. This combination allows you to create dynamic websites and leverage the power of a robust database server.
What are the steps to install Lighttpd webserver in CentOS 7?
To install Lighttpd in CentOS 7, you need to follow a series of steps that include configuring repositories, installing necessary packages, and setting up PHP5 and MariaDB support. A detailed tutorial can guide you through the process.
Why is MariaDB chosen as the default database server for CentOS 7 over MySQL?
MariaDB is preferred over MySQL in CentOS 7 due to licensing and compatibility reasons. Since MySQL is no longer shipped with CentOS, MariaDB serves as a suitable alternative for database management.
Can Lighttpd be a good choice for websites experiencing high traffic?
Yes, Lighttpd is well-suited for websites with high traffic volumes due to its efficient handling of requests and optimized performance. It can help maintain website responsiveness even under heavy loads.
What are the key features that make Lighttpd a recommended webserver for CentOS 7?
Lighttpd stands out for its speed, security practices, and low resource consumption, making it an ideal choice for CentOS 7 users looking to enhance their web server performance while ensuring a secure environment.