lighttpd

Installing PHP with the lighttpd web server.

Compiling and Installing
Configure PHP:

./configure \
--with-config-file-path=/usr/local/etc/ \
--enable-fpm \
--enable-pdo \
--enable-mbstring \
--with-curl \
--with-bz2 \
--with-zlib \
--enable-gd \
--with-jpeg \
--with-webp \
--with-openssl \
--enable-opcache \
--with-pdo-mysql=/usr/local/mysql

If it configures correctly, make and install the binaries:

make
make install

PHP configuration
Copy the included .ini file:

cp php.ini-production /usr/local/etc/php.ini

Edit /usr/local/etc/php.ini and add:

cgi.fix_pathinfo = 1

Enable the Opcache for Drupal 10/11 in /usr/local/etc/php.ini:

zend_extension=opcache
opcache.enable=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.enable_cli=1

PHP-FPM Configuration
Copy the default configuration files:

cp /usr/local/etc/php-fpm.conf.default /usr/local/etc/php-fpm.conf

https://ma.ttias.be/a-better-way-to-run-php-fpm/

Edit /usr/local/etc/php-fpm.conf to make it run in the foreground and log messages:

daemonize = no
error_log = /dev/stderr
listen = /var/run/php-fpm.pid
listen.owner = nobody
listen.group = nobody
listen.mode = 0660
pm.status_path = /.status.fpm

Daemontools startup
Assuming you have already installed
daemontools., create the directories to hold the lighttpd run and logging scripts:

mkdir -p /var/service
cd /var/service
mkdir -m 1755 php-fpm
cd php-fpm

Create the run script (/var/service/php-fpm/run), with the following:

#! /bin/sh
exec 2>&1
exec /usr/local/sbin/php-fpm -F

Once you have saved the file, change it's permissions to it can be executed:

chmod 700 run

Create the logging service:

mkdir -m 755 log
cd log
wget http://qmail.jms1.net/scripts/run.log
mv run.log run
chmod 700 run

Create the symbolic link to start the php-fpm service

ln -s /var/service/php-fpm /service/php-fpm

Make sure mod_fastcgi is loaded in your /service/lighttpd/root/lighttpd.conf:

server.modules += ( "mod_fastcgi" )
index-file.names += ( "index.php" )

fastcgi.map-extensions = (".fpm" => ".php")
fastcgi.server = (
  ".php" => (
    "localhost" => (
      "socket" => "/var/run/php-fpm.pid",
      "broken-scriptfilename" => "enable"
    )
  )
)

Restart the lighttpd server. Since we are running it under daemontools:

svc -t /service/lighttpd

Recent Updates

  • 4 days 23 hours ago
    1.27.2 update
  • 2 weeks 2 days ago
    Drupal 10/11 config
  • 2 weeks 3 days ago
  • PHP
    2 weeks 3 days ago
    PHP 8.3.11 and AlmaLinux
  • 2 weeks 4 days ago
    New version of Pound