Date updated: December 4, 2024
This page is intended for people who wish to use Lighttpd server with PHP and Sqlite3 database in a Linux system. The instructions below have been worded to match the latest version of Linux Mint 22, and version of PHP 8.3 that is included in the Software Manager of Linux. Some of the instructions have been adapted from a page at howtoforge. The installation employs PHP-FPM (FastCGI Process Manager).
STEP 1: Select and install programs that are already included in the Linux Software Manager
- Select Lighttpd and click the Install button to install it.
- Select Php8.3-fpm and click the Install button to install it.
- Select Php8.3-sqlite3 and click the Install button to install it.
- Optional: Select Sqlitebrowser and click the Install button to install it.
STEP 2: Configuring Lighttpd and PHP 8.3
Open a terminal window and edit the following file using nano.
sudo nano /etc/php/8.3/fpm/php.ini
Find the following line and uncomment it by deleting the ";" at the beginning of the line.
;cgi.fix_pathinfo=1
Save the file by pressing Ctrl-X, then Y and Enter.
Go to the directory of the configuration file 15-fastcgi-php.conf
.
cd /etc/lighttpd/conf-available/
Save a backup copy in the same directory by entering:
sudo cp 15-fastcgi-php.conf 15-fastcgi-php.conf.bak
Open the file using nano.
sudo nano 15-fastcgi-php.conf
Delete the content of the file and paste the following:
## Start a FastCGI server for php
fastcgi.server += ( ".php" =>
((
"socket" => "/var/run/php/php8.3-fpm.sock",
"broken-scriptfilename" => "enable"
))
)
Save the file by pressing Ctrl-X, then Y and Enter.
To enable the fastcgi configuration, run the following commands:
sudo lighttpd-enable-mod fastcgi
sudo lighttpd-enable-mod fastcgi-php
Before activating Lighttpd you may wish to modify the configuration file. For example, to specify the location of the localhost directory and default files. The definitions for these are in the configuration file:
sudo nano /etc/lighttpd/lighttpd.conf
Finally, after these changes, restart Lighttpd to activate the new configuration:
sudo /etc/init.d/lighttpd restart