floof.org

Pippin friendica

While trying to debug a new bit of nginx config to connect to a PHP-FPM instance, I looked through my other site config files and found this at the bottom of one. I must have worked this out a year or two ago while debugging all this, and it certainly shows how nonsensical this stuff is. I wonder how it ended up like this.

Posting this in case it's useful to others trying to debug configs intended to interface with PHP-FPM. It is probably accurate for PHP 7.3 or 7.4, not 100% sure which was installed when I wrote it. Might also be accurate for more recent versions, who knows!

# The following parameters are required to get PHP-FPM to execute a
# script: REQUEST_METHOD, SCRIPT_FILENAME and SCRIPT_NAME.

# If REQUEST_METHOD is not present, PHP-FPM will check SCRIPT_FILENAME
# but not do anything more. If REQUEST_METHOD is present and its
# value is HEAD, PHP-FPM will also check SCRIPT_NAME but not run it.
# Otherwise it will check both and run the script.

# SCRIPT_FILENAME must be a pathname that PHP-FPM can stat(). It does
# not need to be a plain file and its permissions and ownership don't
# matter. If relative, it's interpreted relative to FPM's "chdir"
# (which is in turn ends up interpreted relative to FPM "chroot").
# security.limit_extensions is checked against SCRIPT_FILENAME, not
# SCRIPT_NAME. If anything goes wrong at this stage the error message
# logged is "Primary script unknown".

# SCRIPT_NAME is always interpreted relative to PHP's doc_root config
# parameter even if it starts with a "/". PHP-FPM must be able to open
# and read it or it'll log the error message "Unable to open primary
# script: FILENAME (ERROR)" where FILENAME is the value of SCRIPT_FILENAME
# (*not* SCRIPT_NAME, so not necessarily the file it can't open!) and
# ERROR is an error message, e.g. "Permission denied" or "No such file or
# directory". This is the file that is actually interpreted as PHP code.

1
Krishean Draconis mastodon (AP)
i use php-fpm with apache, and this may be useful to me for debugging as well since apache passes all the same parameters to php-fpm
This entry was edited (7 hours ago)
1
Pippin friendica
@Krishean Draconis Yeah, this is just about PHP-FPM and how it interprets FCGI parameters to find a script to run, and should apply regardless of what web server is passing the requests to it. Nginx just happens to be the one I'm using at the moment (but I will probably have to do the same with Apache too at some point so I can offer a choice of either to web hosting customers.) I think most people just use a prepackaged config that comes with their web server so they won't need to know the details, but I'm hacking together configs from scratch and trying to do more "strange" things with it, so knowing exactly what's going on helps!
1
Krishean Draconis mastodon (AP)
years ago when i ran windows i had a stripped down/minimal standalone nginx+php server config with all the binaries run through upx that fit in about 36mb of disk space that i used for testing random things locally, but that was so long ago that i don't remember any of what i did lol. i'm pretty sure it was using fastcgi, but i don't know if it was using php-fpm
1