Install Lighttpd with PHP7 and MySQL Support on Ubuntu 17.04

Lighttpd is a secure, fast and event-based web server alternative to Nginx. It can be used to serve up pages for high-traffic websites. It also has very small memory footprint which makes it a great webserver for busy websites on low-end systems.

This brief tutorial is going to show you how to install Lighttpd with support for PHP7 and MySQL (LLMP) on Ubuntu 17.04. After the configurations are done, you should then be able to serve up pages very fast from your Ubuntu machine using Lighttpd.

To get the server installed and configured correctly, please follow the steps below:

Step 1: Install Lighttpd on Ubuntu

To get Lighttpd installed on Ubuntu, please run the commands below

sudo apt-get update
sudo apt-get install lighttpd

After installing, run the commands below to stop, start and enable the webserver to always start up when the computer boots up.

sudo systemctl stop lighttpd.service
sudo systemctl start lighttpd.service
sudo systemctl enable lighttpd.service

Step 2: Install PHP7 and Related Modules

Next, run the commands below to install PHP7 and related modules on Ubuntu. These are required modules to enable Lighttpd to support dynamic PHP based applications.

sudo apt-get install php7.0 php7.0-cgi php7.0-mysql

After running the above commands, other PHP-based dependencies will also be installed.

Step 3: Enabling PHP modules for Lighttpd

After installing PHP modules, run the commands below to enable the basic PHP modules.

sudo lighty-enable-mod fastcgi
sudo lighty-enable-mod fastcgi-php

Finally, restart Lighttpd to load the configurations.

sudo systemctl restart lighttpd.service

Step 4: Installing MySQL

After installing PHP, run the commands below to install MySQL database server. MySQL can be installed by running the commands below

sudo apt-get install mysql-server mysql-client

During the installation, you’ll be prompted to create and confirm a MySQL root user password. Please do.

You’ll always need the password to manage MySQL server so don’t forget.

You can also stop, start and enable MySQL server by running the commands below.

sudo systemctl stop mysql.service
sudo systemctl start mysql.service
sudo systemctl enable mysql.service

Step 5: Verify Lighttpd and PHP

The final step is to validate that Lighttpd and PHP are both functioning. To do a test, run the commands below to create a file in Lighttpd default root directory on Ubuntu.

sudo nano /var/www/html/phpinfo.php

Then type the line below in the file and save it.

<?php phpinfo(); ?>

Now, open your browser and browse to the Ubuntu server hostname or IP address followed by /phpinfo.php.

Example:  http://localhost/phpinfo.php

You should see something like the one below.

PHP default test page for Apache2


This post shows you how to install Lighttpd with support for PHP7 and MySQL (LLMP) on Ubuntu 17.04 systems. If the above steps are followed properly, in no time you should be serving web pages over Lighttpd, including PHP based applications , like WordPress.

You may also like the post below:


  1. Thanks for the tutorial. I had an error, that required me to ‘sudo apt-get install libterm-readline-gnu-perl’, before enabling fastcgi for lighty. Not entirely sure why I had this issue when I haven’t in the past. But should anyone else get this error ‘
    Can’t locate Term/ in @INC …..’ this may be a helpful comment.

  2. this did not work, ran all commands as asked and navigated to the localhost page and just got a 404 error.

Leave a Comment

Your email address will not be published.