Installing Lighttpd, PHP 7, and MySQL on Debian 11

In this guide, we are going to explain the steps in installing Lighttpd, PHP, and MySQL on Debian 11

Deploying your cloud server

If you have not already registered with Cloudwafer, you should begin by getting signed up. Take a moment to create an account after which you can quickly deploy your cloud servers.

Once you have signed up, log into your Cloudwafer Client Area with the password provided in your mail and deploy your Cloudwafer cloud server.

Updating System Packages

It is recommended that you update the system to the latest packages before beginning any major installations. Issue the command below:

sudo apt-get update && sudo apt-get upgrade

Step 1: Install Lighttpd
sudo apt install lighttpd
sudo systemctl start lighttpd
sudo systemctl enable lighttpd
sudo systemctl status lighttpd

Step 2: Install MySQL

apt-get install mariadb-server mariadb-client

Ensure that MySQL server is running by checking the status with the following command:

sudo systemctl status mysql

Step 3: Install PHP

Issue the command below to install PHP and its related packages from the apt repositories:

sudo apt-get -y install php-fpm php

Step 4: Configure Lighttpd

After installing Lighttpd, PHP 7 and MySQL, there are some configurations which we have to carry out to correctly combine the packages to produce the desired results.

First, we must modify /etc/php/7.0/fpm/php.ini and uncomment the line cgi.fix_pathinfo=1:

sudo nano /etc/php/7.0/fpm/php.ini

Next, make the following changes:

cd /etc/lighttpd/conf-available/
sudo cp 15-fastcgi-php.conf 15-fastcgi-php.conf.bak
sudo nano 15-fastcgi-php.conf
Comment out the following lines:

"bin-path" => "/usr/bin/php-cgi",
"socket" => "/var/run/lighttpd/php.socket",

Add the following line:

"socket" => "/var/run/php/php7.0-fpm.sock",

debian 8 Add the following line:

"socket" => "/var/run/php5-fpm.sock",

Lastly, to enable the fastcgi configuration, run the following commands:

sudo lighttpd-enable-mod fastcgi
sudo lighttpd-enable-mod fastcgi-php

Next, reload Lighttpd:

sudo service lighttpd force-reload
The next step is to check that Lighttpd and PHP are working correctly. We can test this using a PHPInfo file.

sudo nano /var/www/html/phpinfo.php
Enter the following content:

Next, visit your server's IP address on the browser or your domain name if you have one followed by /phpinfo.php


您的电子邮箱地址不会被公开。 必填项已用 * 标注