In many cases, you’re going to see webmasters using Apache2 or Nginx with PHP and MariaDB to create a LAMP or LEMP stack… Well, this post shows you how to use an alternative HTTP server called Lighttpd HTTP server instead…
Lighttpd is a secure, fast and flexibly HTTP server with a small memory footprint compared to other web-servers… Its event-driven architecture is optimized for a large number of parallel connections (keep-alive) which is important for high performance dynamic applications..
Also, if you’re going to be developing any PHP based application, you’re mostly going to need PHP server scripts installed. PHP is an open source server scripting language for creating dynamic, powerful web applications and websites.
PHP is a widely-used, free, and efficient alternative to competitors such as Microsoft’s ASP.
This brief tutorial is going to show students and new users how to setup Lighttpd HTTP server environment with PHP 7.1 and MariaDB support. With this setup, you can run WordPress, Drupal or Joomla CMS platforms easily…
When you’re ready to setup Lighttpd environment with PHP 7.1 support, follow the steps below:
Step 1: Install Lighttpd HTTP Server
sudo apt install lighttpd
After installing Lighttpd, the commands below can be used to stop, start and enable Lighttpd service to always startup when the server boots up.
After that, run the commands below to install PHP7.1-FastCGI and related PHP modules. PHP-FastCGI is a version for Lighttpd web servers while PHP is Apache2. Nginx is PHP-FPM. There are many PHP modules that perform different functions.. however, there are some important ones that are always needed when developing PHP based websites.
If the commands above fail, install the package below.
sudo apt install libterm-readline-gnu-perl
Then run the commands to enable the modules again, this time they should work.
sudo /etc/init.d/lighttpd force-reload
Step 4: Configure Lighttpd PHP-FastCGI Settings
Now that Lighttpd and PHP0-FastCGI are installed, you may want to configure Lighttpd to use PHP server scripting properly. The default Lighttpd PHP-FastCGI configuration file is located at /etc/php/7.1/cgi/php.ini
Open PHP Lighttpd configuration file by running the commands below
sudo nano /etc/php/7.1/cgi/php.ini
Then edit the file to suit your environments. Some important lines to consider:
file_uploads = On
allow_url_fopen = On
memory_limit = 256M
upload_max_filesize = 100M
Next, open the Lighttpd site configuration file… by default it’s stored at /etc/lighttpd/lighttpd.conf
Use the main configuration file to setup advanced server global settings..
Lighttpd PHP-FastCGI configuration file is stored at /etc/lighttpd/conf-available/15-fastcgi-php.conf
Run the commands below to open Lighttpd PHP-FastCGI default site configuration file