• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Question NodeJS and Yarn in chrooted environment

chapterjason

New Pleskian
Hey, I followed this instructions to configure my chrooted env for the domain user, like it is written here.

I currently use this script to configure the env.
Code:
echo reset
./update_chroot.sh --rebuild

echo add php
./update_chroot.sh --add /opt/plesk/php/7.1/bin/php
mkdir /var/www/vhosts/chroot/usr/share
cp -a /usr/share/zoneinfo /var/www/vhosts/chroot/usr/share
for i in /opt/plesk/php/7.1/lib/php/modules/*.so ; do ./update_chroot.sh --add $i ; done
cp -a /opt/plesk/php/7.1/etc/ /var/www/vhosts/chroot/opt/plesk/php/7.1/
sed -i.bkp 's/;date.timezone =/date.timezone = Europe\/Berlin/' /var/www/vhosts/chroot/opt/plesk/php/7.1/etc/php.ini

echo add composer
php -r "copy('https://getcomposer.org/installer ', 'composer-setup.php');"
php composer-setup.php
php -r "unlink('composer-setup.php');"
cp -a composer.phar /var/www/vhosts/chroot/usr/bin

echo add node
echo add yarn

echo apply to all
./update_chroot.sh --apply all

And I use this actions to update the project after deployment.
Code:
/opt/plesk/php/7.1/bin/php /usr/bin/composer.phar update

It's working great! Now I need Yarn and NodeJS to rebuild the assets after deployment. I already tried to add Yarn and NodeJS but it doesn't work. Is there any clean solution for this?
 
I made it work using the following updated script:

Bash:
echo reset
./update_chroot.sh --rebuild

echo add php
./update_chroot.sh --add /opt/plesk/php/7.2/bin/php
mkdir /var/www/vhosts/chroot/usr/share
cp -a /usr/share/zoneinfo /var/www/vhosts/chroot/usr/share
for i in /opt/plesk/php/7.2/lib64/php/modules/*.so ; do ./update_chroot.sh --add $i ; done
cp -a /opt/plesk/php/7.2/etc/ /var/www/vhosts/chroot/opt/plesk/php/7.2/
sed -i.bkp 's/;date.timezone =/date.timezone = Europe\/Amsterdam/' /var/www/vhosts/chroot/opt/plesk/php/7.2/etc/php.ini

echo add composer
wget https://getcomposer.org/composer-stable.phar
chmod +x composer-stable.phar
cp -a composer-stable.phar /var/www/vhosts/chroot/usr/bin/composer

echo add node
./update_chroot.sh --add /opt/plesk/node/8/bin/node

echo 'add env (necessary for gulp and composer)'
./update_chroot.sh --add env

echo 'add npm + gulp (assuming `/opt/plesk/node/8/bin/npm install -g gulp-cli` has been run) and other globally installed modules'
cp -a /opt/plesk/node/8/lib /var/www/vhosts/chroot/opt/plesk/node/8

echo make aliases
ln -s ../../opt/plesk/php/7.2/bin/php /var/www/vhosts/chroot/usr/bin
ln -s ../../opt/plesk/node/8/bin/node /var/www/vhosts/chroot/usr/bin
ln -s ../../opt/plesk/node/8/lib/node_modules/npm/bin/npm-cli.js /var/www/vhosts/chroot/usr/bin/npm
ln -s ../../opt/plesk/node/8/lib/node_modules/gulp-cli/bin/gulp.js /var/www/vhosts/chroot/usr/bin/gulp

echo apply to all
./update_chroot.sh --apply all

Now I can use npm, node, gulp, php, composer directly.

When I tried using node 12, I came across this error: node: ../deps/uv/src/unix/core.c:544: uv__close_nocheckstdio: Assertion `fd > -1' failed. · Issue #2099 · nodejs/help. Maybe it's fixed in node 14, I don't know.

I use this for the additional git deployment actions. Instead of using this script I feel like it would be better to be able to somehow start the same actions you can trigger in the ui by using the Plesk Composer plugin (to install) and the Plesk Nodejs plugin (to run scripts).
 
Back
Top