Articles in this section

How to add Composer to a chrooted environment in Plesk?

kb: how-to Plesk for Linux ABT: Group A

Applicable to:

  • Plesk for Linux

Question

How to add Composer to a chrooted environment in Plesk?

Answer

Note: Such kind of setup is not possible to be done through Plesk Interface.

  1. Connect to the server via SSH

  2. Download the latest update-chroot.zip archive and unpack it:

    # wget https://raw.githubusercontent.com/plesk/kb-scripts/master/update-chroot/update-chroot.sh
    # chmod u+x ./update-chroot.sh

  3. Add PHP to the chrooted template. Use the following article for detailed steps: How to add new programs to a chrooted shell environment template?

    Note: If Plesk PHP is intended to be used instead of OS PHP, use solution from the following article to set it as default: How to specify PHP version for command line php for user on Plesk server

    Click here to proceed with instructions for CentOS/RHEL/CloudLinux/Almalinux 
    1. Add PHP Composer with the data files to the template:

      # ./update-chroot.sh --add /usr/bin/composer
      # mkdir -p /var/www/vhosts/chroot/usr/lib64/plesk-9.0/
      # cp -a /usr/lib64/plesk-9.0/composer.phar /var/www/vhosts/chroot/usr/lib64/plesk-9.0/

    2. Create aliases for /opt/plesk/php/7.4/bin/php and /usr/lib64/plesk-9.0/composer.phar files for chroot environment:

      Note: Change /opt/plesk/php/7.4/bin/php with the required PHP version

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

      # ln -s /usr/lib64/plesk-9.0/composer.phar /var/www/vhosts/chroot/composer

    3. Add programs required for the Composer functioning to the template:

      # ./update-chroot.sh --add env

    4. Apply template changes to all domains:

      # ./update-chroot.sh --apply all

    Click here to proceed with instructions for Debian/Ubuntu
    1. Add PHP Composer with the data files to the template:

      # ./update-chroot.sh --add /usr/bin/composer
      # mkdir -p /var/www/vhosts/chroot/usr/lib/plesk-9.0/
      # cp -a /usr/lib/plesk-9.0/composer.phar /var/www/vhosts/chroot/usr/lib/plesk-9.0/

    2. Create aliases for /opt/plesk/php/7.4/bin/php and /usr/lib/plesk-9.0/composer.phar files for chroot environment:

      Note: Change /opt/plesk/php/7.4/bin/php with the required PHP version

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

      # ln -s /usr/lib/plesk-9.0/composer.phar /var/www/vhosts/chroot/composer

    3. Add programs required for the Composer functioning to the template:

      # ./update-chroot.sh --add env

    4. Apply template changes to all domains:

      # ./update-chroot.sh --apply all

Additional information

How to run Composer with Plesk PHP

Was this article helpful?

Comments

3 comments
Date Votes
  • I finished all the steps from above, but I am getting:

    bash-5.1$ composer
    '/opt/psa/var/modules/composer/composer.phar' not found

    but it works when I start it like this:

    bash-5.1$ ./composer 
       ______
      / ____/___  ____ ___  ____  ____  ________  _____
     / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
    / /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
    \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                        /_/
    Composer version 2.6.6 2023-12-08 18:32:26

    Usage:
    command [options] [arguments]

    Is there a step missing in the instructions?

    0
  • I'm having the same issue after adding composer:

    bash-5.0$ composer
    '/usr/lib/plesk-9.0/composer.phar' not found
    bash-5.0$ ./composer 
    bash: ./composer: No such file or directory
    0
  • It works after you change SSH access type from '/bin/bash chrooted' to '/bin/bash'. But that's not what we want..

    0

Please sign in to leave a comment.