Command line PHP overview

DreamHost offers command line interface versions of PHP that are useful for developing shell applications. There are quite a few differences between the CLI (Command Line Interface), SAPI (Server Application Programming Interface), and other SAPIs (such as PHP-CGI). It's worth mentioning that CLI and CGI are different SAPIs even though they share many of the same behaviors. To learn more about these differences, you can begin by reviewing the PHP Manual's chapter, Using PHP from the command line.

The paths for the default DreamHost PHP-CLI installed binaries are as follows:

  • PHP 5.6 – /usr/local/php56/bin/php
  • PHP 7    – /usr/local/php70/bin/php   

For convenience, DreamHost maintains shortcuts for all PHP versions in the ‘/usr/local/bin/’ directory:

lrwxrwxrwx  1 root root     16 Mar 16 07:22 php-5.6 -> ../php56/bin/php
lrwxrwxrwx  1 root root     16 May 11 11:57 php-7.0 -> ../php70/bin/php

‘/usr/local/bin’ is included in the shell PATH for users by default, so you can use the shortcuts instead of the full path to the binaries.

You can confirm the exact version numbers in use by executing the binary from within the shell using the "-v" option. For example, you can check the version of the PHP5.6 CLI binary as follows:

[server]$ php-5.6 -v
PHP 5.6.19 (cli) (built: Mar 16 2016 14:21:36)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

The default PHP CLI interface on DreamHost can be seen by running php -v

[server]$ php -v

See also

Did this article answer your questions?

Article last updated .