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:
- Open Your SSH Client-
- Use an SSH client like PuTTY (for Windows) or Terminal (for macOS/Linux).
- Connect to Your Server-
- Launch your SSH client and join to your server using the subsequent command-
ssh username@your-server-ip
- Substitute ‘username’ with your actual server username and your-server-ip with your server’s IP address.
- Launch your SSH client and join to your server using the subsequent command-
- Enter Your Password-
- When prompted, enter your password. You won’t see the password as you type for security reasons.
- Check PHP Version-
- Once connected, you can check your PHP version by running:
php -v
- 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
- Once connected, you can check your PHP version by running:
- Verify the PHP Version-
- 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-
- 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
- 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.
- 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:
<?php phpinfo(); ?>
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.