To configure and install Lighttpd with FastCGI support for PHP on FreeBSD, you will need to follow these steps:
sudo pkg install lighttpd
sudo pkg install lighttpd-mod_fastcgi
sudo pkg install php74
server.modules
section of the Lighttpd configuration file (/usr/local/etc/lighttpd/lighttpd.conf
):"mod_fastcgi",
fastcgi.server = ( ".php" => (( "bin-path" => "/usr/local/bin/php-cgi", "socket" => "/tmp/php.socket", "max-procs" => 1, "idle-timeout" => 20, "bin-environment" => ( "PHP_FCGI_CHILDREN" => "4", "PHP_FCGI_MAX_REQUESTS" => "10000" ), "bin-copy-environment" => ( "PATH", "SHELL", "USER" ), "broken-scriptfilename" => "enable" )) )
sudo service lighttpd restart
That's it! Lighttpd should now be configured to handle PHP scripts using FastCGI. To test it, you can create a file called test.php
in the Lighttpd document root (usually /usr/local/www/lighttpd/
) with the following contents:
<?php phpinfo(); ?>
Then, access http://localhost/test.php
in your web browser. You should see a page displaying information about your PHP installation.