How to check PHP Version In plesk?

Introduction

Why is the exact PHP version of your server important to know? Well, the incompatible PHP version can create performance issues and downtime. It is important to keep your web environment in optimal condition and error-free. In this article, we will discuss in detail how to check PHP Version In Plesk. Also, know the steps to change PHP version and install the new one.

Thus, this guide will help you manage your server’s PHP settings with confidence. It will further save you time in case you are handling multiple websites and domains. Also, you can check PHP Version in no time when getting any technical issues resolved.

How to configure a specific command line PHP version for an SSH user on a Plesk for Linux server?

Before we know the steps to check current PHP version with a login to Plesk, we first need to understand how to set a specific PHP version for an SSH user on a Plesk for Linux server. This is important to know because the right version of PHP is to be used when running scripts via SSH to avoid errors. The compatibility between your command-line operations and the PHP version for your applications is essential. 

All in all, you need to know which PHP versions are available and currently in use on your server before you configure a specific PHP version for SSH so that everything runs smoothly. You need to connect the server to the root user before you get into the below steps. Your hosting provider can help you with the root access in case it is not available.

You can use the below command to retrieve the PHP command’s binary path. The PHP command uses the PHP version that is installed by the operating system’s repository by default.

which php

/usr/bin/php

Or, using Plesk install PHP version and call the full binary path as below to get php version command line.

/opt/plesk/php/7.4/bin/php -v

The below Example Output for the above means PHP version 7.4.11 is being used in the command-line interface (CLI):
PHP 7.4.11 (cli) (built: Oct 2 2020 14:09:37) ( NTS )

Further, the below command makes it possible to get every binary from other Plesk PHP versions on the server.

find /opt/plesk/php/*/bin/php

As per the SSH settings configured for the subscription, you can change the PHP binary that the php command uses for a Plesk system user.

With chrooted environment

  • Login to Plesk GUI (Plesk Administrator)
  • Click Domains. Under example.com (your domain), click on Web Hosting Access. Then, change ‘Access to the server over SSH’ to /bin/bash (chrooted). Lastly, click on ‘OK’
  • Next, connect to the server via SSH as the root user. Then, add the required PHP version to the chroot template. Further, create a symlink with the relative path.

ln -s /opt/plesk/php/7.4/bin/php /var/www/vhosts/chroot/bin/php

  • Apply the chroot template across all subscriptions:

./update_chroot.sh –apply all

  • Switch to subscription’s Plesk system user:

su example_user

  • Next, below command is to verify the PHP version:

bash-4.2$ php -v

PHP 7.4.11 (cli) (built: Oct 2 2020 14:09:37) ( NTS )

[Add PHP to CageFS in case CageFS is enabled for user on CloudLinux OS]

With non-chrooted environment

  • Login to Plesk GUI (Plesk Administrator)
  • Click Domains. Under example.com (your domain), click on Web Hosting Access. Then, change ‘Access to the server over SSH’ to /bin/bash (chrooted). Lastly, click on ‘OK’
  • Next, connect to the server via SSH as the root user. 
  • Switch to subscription’s Plesk system user:

su example_user

  • Further, run below to insert PHP binary path on the .bashrc file:

echo “alias php=’/opt/plesk/php/7.4/bin/php'” >> ~/.bashrc

* Where /opt/plesk/php/7.4/bin/php is the necessary PHP binary path

  • Additionally, add the below content to the .bash_profile file:

echo “if [ -f ~/.bashrc ]; then” >> ~/.bash_profile

# echo “. ~/.bashrc” >> ~/.bash_profile

# echo “fi” >> ~/.bash_profile

  • Lastly, log out with the below to reload the changes:

exit

  • Check PHP Version with below command:

su example_user

# php -v

PHP 7.4.11 (cli) (built: Oct 2 2020 14:09:37) ( NTS )

How to check PHP Version In Plesk

Check current PHP version of the domain with the below easy steps:

  • Login to Plesk
  • Click Websites and Domains (on the left side)
  • Get the domain the one you want to check PHP version for.
  • The PHP version appears with the ‘PHP Settings’(see the below image). 

How to check PHP version command line

You can configure PHP command in Plesk to check the PHP version in Plesk interface after connecting to your server via SSH.

To check the PHP version cmd:

php -v

In case of multiple PHP versions installation, check a specific version and use the full path to the PHP binary. For example:

/opt/plesk/php/7.4/bin/php -v

[Replace ‘7.4’` with the version you want to check. This PHP version check command will show PHP version Linux installed at that path.]

How to Change the PHP Version in Plesk

  • Login to Plesk
  • Click Websites and Domains (on the left side)
  • Get the domain and Click on PHP Settings.
  • Click on the PHP versions drop-down. (You will see the PHP versions available there). Click on the one that you want to keep.
  • Then, scroll down & click on ‘Apply’ to save the changes.

Plesk Change PHP Version Command Line Is:

plesk bin php_handler –add -displayname “PHP 7.4” -path /opt/plesk/php/7.4/bin/php -phpini /opt/plesk/php/7.4/etc/php.ini

This command adds a new PHP handler for version 7.4. You can then set this version as the default for your domains through the Plesk interface or command line.

How to Install a PHP version in Plesk

If you do not have the required PHP version, you can install it with the Plesk panel’s root access. Follow the below steps for installation:

  • Click on ‘Tools and Settings’ (on the left side).
  • Go to ‘Updates and Upgrades’ under Plesk.
  • Click on Add/Remove Components.
  • Expand the ‘+ Web Hosting’ by clicking on it. Further, expand ‘+ PHP interpreter versions’. Click on the PHP version that you want to install and click on ‘Install’. 
  • After the required version is added to the install list, scroll and click Continue below.
  • Thus, with Plesk install PHP version that you selected; it will take time depending on size and packages. Once the installation is done, click on ‘OK’.

Conclusion

Using Plesk makes it easy to manage PHP versions and we can get smoothly running web applications with it. In this guide, we learned how to check PHP version in Plesk. Also, it outlined how to configure PHP for SSH users and handle version changes via the Plesk interface and command line. This will help you manage your server’s PHP settings efficiently.

Was this article helpful?

Related Articles