Skip to content
  • Solutions
    By Role
    • For Developers
    • For Content Managers
    • For Agencies
    • For IT Admins
    • For Web Hosters
    • For Developers
    • For Content Managers
    • For Agencies
    • For IT Admins
    • For Web Hosters
    By Infrastructure
    • Overview
    • AWS
    • Microsoft Azure
    • Alibaba Cloud
    • Google Cloud Platform
    • Vultr
    • Overview
    • AWS
    • Microsoft Azure
    • Alibaba Cloud
    • Google Cloud Platform
    • Vultr
    • Digital Ocean
    • Linode
    • Upcloud
    • Oracle
    • OVH
    • Digital Ocean
    • Linode
    • Upcloud
    • Oracle
    • OVH
  • Product
    • Plesk Features
    • Plesk Editions
    • What’s new
    • Pricing
    • Roadmap
    • Lifecycle Policy
    • Extensions Catalogue
  • Pricing
  • Extensions
    Featured Extensions
    • SocialBee
    • WP Toolkit
    • Sitejet Builder for Plesk
    • SEO Toolkit
    • Joomla! Toolkit
    • Premium Email
    • Email Security
    • SocialBee
    • WP Toolkit
    • Sitejet Builder for Plesk
    • SEO Toolkit
    • Joomla! Toolkit
    • Premium Email
    • Email Security
    Bundles and packs:
    • Business and Collaboration Edition
    • WP pack
    • Hosting pack
    • Power pack
    • Language pack
    • Business and Collaboration Edition
    • WP pack
    • Hosting pack
    • Power pack
    • Language pack

    See all Extensions

  • For Partners
    • Plesk Contributor Program
    • Plesk Partner Program
    • Affiliate program
    • Plesk University
  • Help Center
    • Documentation
    • Professional Services
    • Support
    • Contact Us
    • Wiki
    • Forum
  • Plesk 360 login
  • Free Trial
  • Pricing
  • Solutions
    • By Role
      • For Developers
      • For Content Managers
      • For Agencies
      • For IT Admins
      • For Web Hosters
    • By Infrastructure
      • Overview
      • Plesk on Amazon Web Services (AWS & Lightsail)
      • Microsoft Azure
      • Alibaba Cloud
      • Google Cloud Platform
      • Vultr
      • DigitalOcean
      • Linode
      • UpCloud
      • Oracle
      • OVH
  • Products
  • Pricing
  • Extensions
    • Featured Extensions
      • SocialBee
      • WP Toolkit
      • Sitejet Builder for Plesk
      • SEO Toolkit
      • Joomla! Toolkit
      • Premium Email
      • Email Security
    • Bundles and packs:
      • Business and Collaboration Edition
      • WP pack
      • Hosting pack
      • Power pack
      • Language pack
      • See all Extensions
  • For Partners
    • Plesk Contributor Program
    • Plesk Partner Program
    • Affiliate Program
    • Plesk University
  • Help Center
    • Documentation
    • Professional Services
    • Support
    • Contact Us
    • Wiki
    • Forum
  • Plesk 360 login
  • Free Trial
  • Pricing
  • Solutions
    • By Role
      • For Developers
      • For Content Managers
      • For Agencies
      • For IT Admins
      • For Web Hosters
    • By Infrastructure
      • Overview
      • Plesk on Amazon Web Services (AWS & Lightsail)
      • Microsoft Azure
      • Alibaba Cloud
      • Google Cloud Platform
      • Vultr
      • DigitalOcean
      • Linode
      • UpCloud
      • Oracle
      • OVH
  • Products
  • Pricing
  • Extensions
    • Featured Extensions
      • SocialBee
      • WP Toolkit
      • Sitejet Builder for Plesk
      • SEO Toolkit
      • Joomla! Toolkit
      • Premium Email
      • Email Security
    • Bundles and packs:
      • Business and Collaboration Edition
      • WP pack
      • Hosting pack
      • Power pack
      • Language pack
      • See all Extensions
  • For Partners
    • Plesk Contributor Program
    • Plesk Partner Program
    • Affiliate Program
    • Plesk University
  • Help Center
    • Documentation
    • Professional Services
    • Support
    • Contact Us
    • Wiki
    • Forum
  • Plesk 360 login
  • Free Trial
Plesk 360 login
Free Trial

Knowledge Base

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

 
chrootcloudlinuxdomainsgohosting

Question

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

Answer

Note: To apply the solution described in this article it's required to connect to the server with the root user. If root access is not available via SSH, contact your hosting service provider.

By default, the php command calls the binary installed by the PHP version provided by the operating system repository. The binary path of the php command can be retrieved with the following command:

# which php
/usr/bin/php

Alternatively, it's possible to install other PHP versions from Plesk, and to execute those on the command line it's required to call the full binary path. For example:

# /opt/plesk/php/7.4/bin/php -v
PHP 7.4.11 (cli) (built: Oct 2 2020 14:09:37) ( NTS )

All binaries from the additional Plesk PHP versions installed on the server can be retrieved with the following command:

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

 

To modify the PHP binary called by the php command for a Plesk system user, apply one of the following options according to the SSH option configured on the subscription:

Click on a section to expand

Subscriptions configured with a chrooted environment

  1. Log in to Plesk GUI as Plesk Administrator

  2. Go to Domains > example.com > Web Hosting Access and set option Access to the server over SSH to /bin/bash (chrooted) > OK to apply the changes

  3. Connect to the server via SSH with the root user

  4. Add the necessary PHP version into the chroot template

  5. Create a symlink with the relative path:

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

  6. Apply chroot template to all the subscriptions:

    # ./update_chroot.sh --apply all

  7. Switch to the Plesk system user of the subscription:

    # su example_user

  8. Verify the PHP version running the following command:

    # bash-4.2$ php -v
    PHP 7.4.11 (cli) (built: Oct 2 2020 14:09:37) ( NTS )

    Note: If CageFS is enabled for user on CloudLinux OS, it is required to add PHP to CageFS instead

Subscriptions configured with a non-chrooted environment

  1. Log in to Plesk GUI as Plesk Administrator

  2. Go to Domains > example.com > Web Hosting Access and set option Access to the server over SSH to /bin/bash > OK to apply the changes

  3. Connect to the server via SSH with the root user

  4. Switch to the Plesk system user of the subscription:

    # su example_user

  5. Add the 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

  6. Add the following content to the .bash_profile file:

    # echo "if [ -f ~/.bashrc ]; then" >> ~/.bash_profile
    # echo ". ~/.bashrc" >> ~/.bash_profile
    # echo "fi" >> ~/.bash_profile

  7. Log out to reload the changes:

    # exit

  8. Verify the PHP version running the following command:

    # su example_user
    # php -v
    PHP 7.4.11 (cli) (built: Oct 2 2020 14:09:37) ( NTS )

Tweet
Share
Share
Email
0 Shares
Read the full article
Related Posts

Securing the WordPress Frontier with WP Guardian

Read More »

Introducing WP Guardian Vulnerability Protection: Now available for WP Toolkit

Read More »

How to Host a Go App on Plesk

Read More »
Knowledge Base

On Plesk for Linux server, curl command in chrooted shell or in scheduled task fails: curl: (77) error setting certificate verify locations

Read More »

How to install / remove additional PHP versions provided by Plesk

Read More »

 How to install ‘sqlsrv’ extension for Plesk PHP handlers?

Read More »

Chrooted directories are created in subscription directory on Plesk for Linux server even if SSH access for subscription is forbidden

Read More »

Hosting Wiki

  • Django
  • Cross Site Request Forgery (CSRF)
  • Cross-Origin Resource Sharing (CORS)
  • Server Redundancy
  • Postfix
  • Linux Containers
  • Google Cloud CDN
  • PostgreSQL
  • DDoS
  • Bare Metal Server
  • PhpMyAdmin
  • phpPgAdmin
  • Oracle VM Server
  • Server Virtualization Software
  • Windows Server
  • Linux
  • PHP
  • MongoDB
  • Domain
  • Hosting Control Panel
  • Plesk
  • NoSQL Database
  • Web Server
  • DNS Server
  • SSH
  • Colocation Hosting
  • Reseller Hosting
  • Cloud Hosting
  • VPS Hosting
  • Dedicated Hosting
  • Shared Hosting
  • Free Hosting
  • Managed Hosting
X-twitter Linkedin Youtube Reddit Github
  • Product
  • Login
  • Pricing
  • Editions
  • For Partners
  • Partner Program
  • Contributor Program
  • Affiliate Program
  • Plesk University
  • Company
  • Blog
  • Careers
  • Events
  • About Plesk
  • Our Brand
  • Resources
  • User and Admin guides
  • Help Center
  • Migrate to Plesk
  • Contact Us
  • Hosting Wiki
  • Forum
  • Legal
  • Legal
  • Privacy Policy
  • Imprint

© 2025 WebPros International GmbH

Part of the WebPros®  Family