Command line PHP overview

 

Overview

You can use the command line over SSH to find the PHP versions installed on your DreamHost server, their binary paths, and the modules each one includes. This article covers the default PHP-CLI binary locations, the /usr/local/bin shortcuts, and the commands to check the PHP version and installed modules.

Prerequisites

To run the commands in this article, you must configure a Shell user and log into your server via SSH.

Where are the PHP binaries located?

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

  • PHP 8.1 — /usr/local/php81/bin/php
  • PHP 8.2 — /usr/local/php82/bin/php
  • PHP 8.3 — /usr/local/php83/bin/php
  • PHP 8.4 — /usr/local/php84/bin/php
  • PHP 8.5 — /usr/local/php85/bin/php

DreamHost maintains convenient shortcuts for all PHP versions in the /usr/local/bin/ directory:

lrwxrwxrwx  1 root root    16 Apr 12 13:11 php-8.1 -> ../php81/bin/php
lrwxrwxrwx  1 root root    16 Apr 13 11:11 php-8.2 -> ../php82/bin/php
lrwxrwxrwx  1 root root    16 Apr 12 11:33 php-8.3 -> ../php83/bin/php
lrwxrwxrwx  1 root root    16 Apr 13 13:11 php-8.4 -> ../php84/bin/php
lrwxrwxrwx  1 root root    16 Apr 13 11:33 php-8.5 -> ../php85/bin/php

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

How do I obtain PHP version information?

This section explains how to view the specific versions of PHP and the modules installed with it.

How do I check the PHP version?

Run this command to view the default PHP-CLI version running on your server:

[server]$ php -v

You can view the exact version number by executing a specific binary. For example:

[server]$ php-8.4 -v

How do I check the installed modules?

You can determine which PHP modules are installed for a specific version of PHP by running the following command:

[server]$ /usr/local/php84/bin/php -m

See also

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?