How to Check Your PHP Version via SSH

July 3, 2024 / Security and Backup

This article explains how to check your PHP version via SSH. It is essential for ensuring compatibility with your applications and for security purposes.

Follow the systematic guide:

  1. Open Your SSH Client-
    1. Use an SSH client like PuTTY (for Windows) or Terminal (for macOS/Linux).
  2. Connect to Your Server-
    1. Launch your SSH client and join to your server using the subsequent command-
      ssh username@your-server-ip
    2. Substitute ‘username’ with your actual server username and your-server-ip with your server’s IP address.
  3. Enter Your Password-
    1. When prompted, enter your password. You won’t see the password as you type for security reasons.
  4. Check PHP Version-
    1. Once connected, you can check your PHP version by running:
      php -v
    2. This command will output the PHP version installed on your server. For example:
      PHP 7.4.21 (cli) (built: Jul 1 2021 15:15:44) (NTS)
      Copyright (c) The PHP Group
      Zend Engine v3.4.0, Copyright (c) Zend Technologies
  5. Verify the PHP Version-
    1. Verify that the displayed version matches your expectations. If it does not, you may need to update your PHP version or contact your hosting provider for assistance.

Additional Tips-

  1. Multiple PHP Versions If your server supports multiple PHP versions, you may need to specify the path to the PHP binary. For example:
    /usr/local/php7.4/bin/php -v
  2. PHP Configuration File- You can also check the configuration file used by running:
    php –ini

    This command will display the loaded configuration files and directories.

  3. PHP Information Page: For a more comprehensive view of your PHP configuration, you can create a phpinfo.php file in your web directory with the following content:

    Access this file via your web browser to see detailed PHP information.

This way, you can check your PHP version via SSH. Knowing your PHP version via SSH is a valuable skill for managing your server and ensuring your applications run smoothly. Regularly checking and updating your PHP version can help maintain security and compatibility with the latest features.

Learn how to set the PHP version for individual domains in cPanel with our detailed guide: How to Set the PHP Version per Domain in cPanel.

Spread the love