How to add Composer to a chrooted environment in Plesk?

Follow

Comments

5 comments

  • Avatar
    Adam

    To add composer to a chrooted shell.

    Follow the download instructions from https://getcomposer.org/download/:

    While logged in as root

    • sudo su root
    • cd /var/www/vhosts/chroot
    • php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
    • If you wish to verify composer is valid, copy the "if (hash_file('SHA384'" line from the website above
    • php composer-setup.php
    • php -r "unlink('composer-setup.php');"

    Now you'll may noticed that when you access the a user that is chrooted, composer is still missing.
    There are a few
    extra commands to update the bin directories of the chrooted user/domain.

    • /usr/local/psa/admin/sbin/chrootmng --remove --source=/var/www/vhosts/chroot --target=/var/www/vhosts/<domain name>
    • /usr/local/psa/admin/sbin/chrootmng --create --source=/var/www/vhosts/chroot --target=/var/www/vhosts/<domain name>

    It's worth noting that if you have a bunch of chrooted users, you may want to write a script to execute the commands all in one go so it will save you a head-ache.

    Good luck.

     

    0
    Comment actions Permalink
  • Avatar
    Alexandr Redikultsev

    Hello, @Adam!

     

    Thank you very much for sharing, I am sure this information will come in handy for anyone else who would like to add a composer without using update_chroot.sh.

    0
    Comment actions Permalink
  • Avatar
    Fouad Ahmed Fouad

    Doen but had an error,

    bash-4.4$ /opt/plesk/php/7.2/bin/php /usr/lib64/plesk-9.0/composer.phar

    Fatal error: Uncaught Error: Class 'Phar' not found in /usr/lib64/plesk-9.0/composer.phar:23
    Stack trace:
    #0 {main}
    thrown in /usr/lib64/plesk-9.0/composer.phar on line 23

    I searched online and seems many people had the same on chroot bash on plesk, would you recommend a fix.

    0
    Comment actions Permalink
  • Avatar
    Fouad Ahmed Fouad

    After doing the steps many times I still have this error

    bash-4.4$ /opt/plesk/php/7.2/bin/php /usr/lib64/plesk-9.0/composer.phar

    Fatal error: Uncaught Error: Class 'Phar' not found in /usr/lib64/plesk-9.0/composer.phar:23
    Stack trace:
    #0 {main}
    thrown in /usr/lib64/plesk-9.0/composer.phar on line 23

    0
    Comment actions Permalink
  • Avatar
    Alexey Lapshin

    Hello @Fouad Ahmed Fouad,

    In case you are using CloudLinux on the server, enable the same modules as under LVE Manager > PHP Selector for the native PHP:  Tools & Settings > PHP Settings > alt-php > Extensions.

    In case another OS is in use - please submit ticket to us for deeper investigation: https://support.plesk.com/hc/en-us/articles/213608509-How-to-submit-a-request-to-Plesk-support-

    0
    Comment actions Permalink

Please sign in to leave a comment.

Have more questions? Submit a request