Skip to content

POST a request to PHP-FPM

Without a webserver like nginx or Apache, a tool called cgi-fcgi can be used to query a PHP-FPM process.

Install cgi-fcgi

To send a POST request directly to PHP-FPM a fcgi tool is needed:

  • On macOS brew install fcgi
  • On Debian apt-get install libfcgi0ldbl

Send a POST request

echo '{"query": "{allCities { edges {node {id}}} }"}' | \
SCRIPT_NAME=/var/www/app/public/index.php \
SCRIPT_FILENAME=/var/www/app/public/index.php \
DOCUMENT_ROOT=/var/www/app/public \
REMOTE_ADDR=127.0.0.1 \
HTTP_HOST=api.some-domain.com \
HTTPS=true \
REQUEST_URI=/graphql/public \
REQUEST_METHOD=POST \
CONTENT_TYPE=application/json \
CONTENT_LENGTH=47 \
cgi-fcgi -bind -connect 127.0.0.1:8080

#published

Links to this note

These notes are unpolished collections of thoughts, unfinished ideas, and things I want to remember later. In the spirit of learning in public, I'm sharing them here. Have fun exploring, if you want!
© 2022 by Adrian Philipp