In this tutorial, we will show you how to install Lighttpd on a Centos 7 VPS as well as set up MariaDB and PHP.
Lighttpd is a secure, open-source, fast, flexible and more optimized web server. Lighttpd has a high-speed infrastructure that allows for better performance with the same hardware when compared to other alternative web-servers. Lighttpd supports the FastCGI, SCGI and CGI interfaces and allows web applications that are written in any programming language to be used with the server.
Lighttpd’s FastCGI can be configured to support PHP with opcode caches and also has received attention within the Perl, Python, and Ruby communities.
Let’s get started with the installation.
Table of Contents
Prerequisites
- For the purposes of this tutorial, we will use a Centos 7 VPS.
- Full SSH root access or a user with sudo privileges is also required.
Step 1: Connect via SSH and Update
Connect to your server via SSH as the root user using the following command:
Remember to replace “IP_ADDRESS” and “PORT_NUMBER” with your server’s respective IP address and SSH port number.
Before starting with the installation, you will need to update your system packages to their latest versions. It’s easy to do, and it won’t take more than a few minutes.
You can do this by running the following command:
Once the updates are completed, we can move on to the next step.
Step 2: Install Lighttpd
Before installing Lighttpd we need to enable the EPEL repository on our system and update our software packages once again using the following commands:
Once the EPEL repository has been enabled, we can install the Lighttpd web server by running the following command:
Once the Lighttpd packages have been installed, we can start and enable the service to automatically start at boot.
To check the status of the service run the following command:
If everything is fine you should get the following output:
If you see any network errors in the status, open the /etc/lighttpd/lighttpd.conf
configuration file and change the line that says server.use-ipv6
from enable
to disable
.
Now, we need to restart the Lighttpd web server and everything should work fine.
Next, you can open your favorite web browser and enter your server’s IP Address. It will load the default Lighttpd web page.
The default document root for Lighttpd is /var/www/lighttpd/
and the main configuration file is at /etc/lighttpd/lighttpd.conf
.
Step 3: Installing MariaDB support for Lighttpd
If you need database support with your Lighttpd setup, this step can be very useful.
We can install the MariaDB database server using the following commands:
Once the installation has been completed, we can start and enable the service with these following commands:
We can then check the status of the service by running the following command:
If everything is fine you should get the following output:
We can connect to the MariaDB command line with the following command:
If you logged in successfully, you will get the following output:
We have successfully installed and connected to the MariaDB database server. You can type ‘exit’ to exit the interface.
Step 4: Installing PHP and PHP-FPM with FastCGI
To install PHP along with all of its necessary extensions, run the following command:
Once PHP has been installed we can enable PHP-FPM and FastCGI support for Lighttpd by running the following command:
Next, open the following file /etc/php-fpm.d/www.conf
using your preferred text editor. For our tutorial, we’ll be using ‘nano’:
Once the file is open, change the next two lines:
Now, we can start PHP-FPM service and enable it to start automatically at boot with the following commands:
To check the status of the service, run this:
You should get the following output:
That’s all there is to it – in this tutorial, we learned how to install Lighttpd on Centos 7, as well as how to enable MariaDB, PHP and PHP-FPM with FastCGI in Lighttpd.
Of course, you don’t have to install Lighttpd on CentOS 7 if you use one of our CentOS VPS Hosting Services, in which case you can simply ask our expert Linux admins to install and set up Lighttpd on CentOS 7 for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post on how to install Lighttpd on CentOS 7, please share it with your friends on the social networks using the share shortcuts below, or simply leave a comment down in the comments section. Thanks.