4

Is there a way to make PHP and thttpd work together in CGI mode? There are some pieces of information here and there but our naive attempts failed so far as it seems like PHP doesn't understand the environment variables set by thttpd and therefore fails to find the script file.

Building php as thttpd module is not desirable due to custom build configuration (it's an embedded device) - but possible as a last resort. However, I'd like to avoid that using CGI approach if possible.

Rex Logan
  • 26,248
  • 10
  • 35
  • 48
Michael Pliskin
  • 2,352
  • 4
  • 26
  • 42
  • Did you do a custom build of php? If so, what switches did you use? Maybe http://stackoverflow.com/questions/3817685/cross-compiled-thttpd-server-with-php-runs-fine-but-no-php helps... – wimvds Jan 21 '11 at 16:12

2 Answers2

3

Wrap

/cgi-bin/php.cgi:
#!/bin/sh
export DOCUMENT_ROOT=/home/alex/thttpd/www
export SCRIPT_NAME=/cgi-bin/test.php
export SCRIPT_FILENAME=/home/alex/thttpd/www/cgi-bin/test.php
exec /usr/bin/php-cgi

or patch thttpd to export a suitable env for php-cgi

Alex
  • 31
  • 1
2

This may not be the answer you're hoping for, but there seem to be no development in thttpd. I'd recommend mongoose. MIT-licence, good for embedded and easy php setup,

Runs on windows as well.

php setup: go WindowsUsage and scroll down.

UPDATE: new link http://cesanta.com/docs/PhpWebsite.shtml

Teson
  • 6,644
  • 8
  • 46
  • 69
  • Do not sign your posts. It is [strictly forbidden in the FAQ](http://stackoverflow.com/faq#signatures). Additionally, [pseudo-signatures such as "thanks", "hope this helps", etc. are not considered helpful](http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be-removed-from-posts). Please refrain from doing either in the future, as it will draw flags on your posts which may result in further moderator action. – casperOne Jan 02 '12 at 01:55