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.
View the following article for instructions on how to access your Shell.
The paths for the default DreamHost PHP-CLI installed binaries are as follows:
- PHP 5.6 – /usr/local/php56/bin/php
- PHP 7.0 – /usr/local/php70/bin/php
- PHP 7.1 – /usr/local/php71/bin/php
- PHP 7.2 – /usr/local/php72/bin/php
- PHP 7.3 – /usr/local/php73/bin/php
- PHP 7.4 – /usr/local/php74/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
lrwxrwxrwx 1 root root 16 Jul 26 19:28 php-7.1 -> ../php71/bin/php
lrwxrwxrwx 1 root root 16 Jan 30 19:28 php-7.2 -> ../php72/bin/php
lrwxrwxrwx 1 root root 16 Jan 30 19:28 php-7.3 -> ../php73/bin/php
lrwxrwxrwx 1 root root 16 Dec 4 00:04 php-7.4 -> ../php74/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.
Checking the version via SSH
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 PHP7.1 CLI binary as follows:
[server]$ php-7.2 -v PHP 7.2.24 (cli) (built: Nov 13 2019 04:08:16) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.24, Copyright (c) 1999-2018, by Zend Technologies
The default PHP CLI interface on DreamHost can be seen by running php -v
[server]$ php -v