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-openssl \
--enable-opcache \

The --with-apxs2 and --with-apxs configuration options are not required. Add any other PHP options that you need.
MySQL, add:

--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \

If you want to include LDAP support, add:

--with-ldap

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

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

  • 3 weeks 6 days ago
  • 3 weeks 6 days ago
  • 1 month 24 min ago
    php 8.x
  • 1 month 1 day ago
    10.6.7
  • 1 month 2 days ago
    Drop Centos 5/6 stuff