lighttpd gives 403 Forbidden with PHP file

349 Views Asked by At

I have a lighttpd server in a container running the sebp/lighttpd image (lighttpd on Alpine Linux). It can serve HTML files with no problems.

I am trying to set up PHP for this server. However, when I try to access a PHP file, it sends back a 403 Forbidden response.

In php.ini, force_redirect is set to 1.

In lighttpd.conf, mod_fastcgi.conf is included.

In mod_fastcgi.conf, the following configuration is used:

server.modules += ("mod_fastcgi")
fastcgi.server = ( ".php" =>
                    ( "localhost" =>
                        (
                            "socket" => "/tmp/php-cgi.socket" + var.PID,
                            "bin-path"  =>      "/usr/bin/php-cgi"
                        )
                    )
                )
fastcgi.debug = 1

I set the access log to "/var/log/lighttpd/access.log", and the error log to /var/log/lighttpd/error.log, but nothing shows up in that folder. lighttpd is set as the owner of the folder.

/usr/bin/php-cgi -v returns PHP 8.0.28 (cgi-fcgi).

1

There are 1 best solutions below

1
gstrauss On

Something else might be rejecting the response, such as including "mod_staticfile" in server.modules list before "mod_fastcgi"

View your complete config as lighttpd sees it with

lighttpd -f /etc/lighttpd/lighttpd.conf -p