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.zip
archive from the article and unpack it:# unzip update_chroot.zip
-
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/ - Create aliases for
/opt/plesk/php/7.4/bin/php
and/usr/lib64/plesk-9.0/composer.phar
files for chroot environment:# 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
-
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