Command-line PHP on QNAP hardware

QNAP network-attached storage devices run a lightweight Linux derivative. It’s not a fully-functional Linux (specifically, it can’t update itself from the command line), but a lot of “Linuxy” things are possible nevertheless. Specifically, it is possible to run PHP from the command line, as long as you take care to either refer to the PHP executable by its full path or add its location to $PATH.

On my HS-210, the PHP executable resides inĀ /mnt/ext/opt/apache/bin. To verify which executable it is, I ran the following command:

/mnt/ext/opt/apache/bin/php -r "echo php_sapi_name();"

which returned

cli

This signifies that the executable is the command-line (CLI) executable rather than the CGI executable.

Leave a Reply

Your email address will not be published. Required fields are marked *