1

I have a raspberry pi with Raspbian Version Linux RaspberryPi 4.19.97-v7+ #1294 SMP Thu Jan 30 13:15:58 GMT 2020 armv7l GNU/Linux and a lighttpd webserver installed.

$ sudo mkdir /var/www 
$ sudo groupadd www-data 
$ sudo adduser www-data www-data 
$ sudo usermod -a -G www-data www-data 
$ sudo chown -R www-data:www-data /var/www 
$ sudo apt-get update 
$ sudo apt-get install lighttpd
$ sudo apt-get install php7.3-fpm php7.3 
$ sudo lighty-enable-mod fastcgi 
$ sudo lighty-enable-mod fastcgi-php

I edit the configuration of /etc/lighttpd/conf-available/15-fastcgi-php.conf

fastcgi.server = ( ".php" => 
    ((
        "bin-path" => "/usr/bin/php-cgi7.3",  
        "socket" => "/var/run/php/php7.3-fpm.sock",
        "broken-scriptfilename" => "enable"
    ))
)

And my lighttpd.conf

server.modules = (
    "mod_access",
    "mod_alias",
    "mod_compress",
    "mod_redirect",
    "mod_fastcgi",
)

server.document-root    = "/var/www"
server.upload-dirs      = ("/var/cache/lighttpd/uploads")
server.error-log        = "/var/log/lighttpd/error.log"
server.pid-file         = "/var/run/lighttpd.pid"
server.username         = "www-data"
server.groupname        = "www-data"
server.port             = 80
server.indexfiles       = ("index.php", "index.html")

mimetype.assign   = ( ".png"  => "image/png",
                      ".jpg"  => "image/jpeg",
                      ".jpeg" => "image/jpeg",
                      ".html" => "text/html",
                      ".txt"  => "text/plain"
)

static-file.exclude-extensions = (".php", ".pl", ".fcgi")

dir-listing.encoding    = "utf-8"
server.dir-listing      = "enable"

$HTTP["url"] =~ "^/($|/)" { 
dir-listing.activate = "disable"
}

And also /etc/php/7.3/fpm/php.ini

cgi.fix_pathinfo=1

I reboot the Raspberry Pi and get the error 403 when I want to access my phpinfo() website.

The permissions for the directory /var/www are the following:

$ ls -l /var/www

-rwxr-xr-x 1 www-data www-data 2751 Mär 22 15:29 GPIO.html
drwxr-xr-x 2 root     root     4096 Mär 22 21:26 html
-rwxr-xr-x 1 www-data www-data   24 Mär 22 15:15 index.php

The PHP file is located under /var/www.

So what is wrong?

7
  • Can you post the permissions of the files under /var/www and check if the missing / at the beginning of "bin-path" => "usr/bin/php-cgi7.3", in /etc/lighttpd/conf-available/15-fastcgi-php.conf is a typo or intentional? Mar 23 '20 at 15:23
  • I have updated the question. The missing / doesn´t change anything.
    – Kampi
    Mar 23 '20 at 17:04
  • What does the error log tell you?
    – Bob Brown
    Mar 23 '20 at 19:08
  • There is no error log.
    – Kampi
    Mar 23 '20 at 19:44
  • 1
    From your question server.error-log = "/var/log/lighttpd/error.log" Have you looked there?
    – Bob Brown
    Mar 23 '20 at 20:42
0

Do not combine a PHP-FPM configuration with a php-cgi configuration.

If you run the PHP-FPM as an external service, you should omit the "bin-path" line using php-cgi from the lighttpd config, and leave the "socket" pointing to the PHP-FPM socket.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.