1

We want to build a simple web frontend to configure some parts of our application on a embedded platform. The configuration file is stored as json and the frontend is written in js. For the backend we use php. The backend should be as simple as it can get (receiving data and verifying the sanity to some extend).

The web server in use is lighttpd version 1.4.45 and php version 7.1.9. PHP is being run as cgi module.

First of all, the very basic configuration works as verified by running:

<?php
phpinfo():
?>

This shows me that the web server does work and the php script is being executed correctly. The output can be found here.

Next I tried to send some raw data using postman and read it inside the script:

<?php
echo file_get_contents("php://input");
?>

The result is an empty page.

I get a similar result when I tried to send data via POST (x-www-form-urlencoded tab in postman):

<?php
echo $_POST['foo'];
?>

Output:

Notice: Undefined index: foo in /www/pages/index.php on line 2

To verify the very basic functionality I tried to pass some data via GET:

192.168.3.11/index.php?foo=bar

Trying to echo the $_GET['foo'] array entry results in undefined reference although REQUEST_METHOD is correct and QUERY_STRING does contain the data:

<?php

echo $_SERVER['REQUEST_METHOD'];
echo $_SERVER['QUERY_STRING'];
echo "Get:\n";
echo $_GET['foo'];
?>

Output:

GET
foo=bar
Get:

Notice: Undefined index: foo in /www/pages/index.php on line 10

Somehow the requests doesn't reach the script. Lighttpd only loads mod_access, mod_cgi and mod_accesslog. Also, php.ini does allow post-data reading and cgi.fix-pathinfo is set to 1. (I put the links to both config file at the end of the post).

In contrast to the suggestions here I don't access the web server via a domain name and I don't have the rewrite module enabled or any rules set. Also the content length I see in the server logs correspond to the information I try to pass.

I suspect either a config error in php or lighttpd or a missing compiler option. Sadly I can't find anything on this topic except the cgi.fix-pathinfo parameter in the php.ini file. Also as far as I understand the php://input stream always should contain the raw data passed to the script, right?

The last time I configured a web server manually and used php was over 15 years ago, so I'm quite bit rusty on this topic.

The next step I can think of is to compile php with debug symbols enabled and debug the executable.

Could someone please point me to topics I should investigate?

I uploaded the lighttpd.conf and php.ini on pastebin.

EDIT: On a x86 machine lighttpd and php work fine with the current config files copied from the embedded target.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Stanislav
  • 155
  • 2
  • 9
  • Apparently, the problem somehow relates to the cgi binding of php. I couldn't get fastcgi configured with php-fpm and lighttpd so for now I switched to apache2 and modphp, now everything works as expected. – Stanislav Dec 19 '19 at 07:59

0 Answers0