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.
-
Connect to the server via SSH
-
Download the latest
update_chroot.tar.gz
archive from the article and unpack it:# tar xf update_chroot.tar.gz
-
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
-
Add PHP Composer with the data files to the template:
# ./update_chroot.sh --add 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/ -
Add programs required for the Composer functioning to the template:
# ./update_chroot.sh --add env
-
Apply template changes to all domains:
# ./update_chroot.sh --apply all
Comments
5 comments
To add composer to a chrooted shell.
Follow the download instructions from https://getcomposer.org/download/:
While logged in as root
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.
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.
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.
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.
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
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-
Please sign in to leave a comment.