Search Engine: Elastic

Article ID: 129963, created on Dec 6, 2016, last review on Dec 6, 2016

  • Applies to:
  • Plesk Automation 11.5


Scheduled task does not handle PHP script:

-: /usr/bin/php: No such file or directory


/usr/bin/php: bad interpreter: No such file or directory


php binary is not added to chroot environment


  1. Create the script with the following content (on the web server):

    \cp -f /usr/bin/php $vhost_dir/chroot/bin/
    \cp -Rf /usr/lib64/php/ $vhost_dir/chroot/lib64/
    \cp -f /usr/lib64/ $vhost_dir/chroot/lib64/
    \cp -f /usr/lib64/ $vhost_dir/chroot/lib64/
    \cp -f /usr/lib64/ $vhost_dir/chroot/lib64/
    cp -R /lib/terminfo /var/www/vhosts/chroot/lib/

    change the vhost_dir variable if you have a different path to vhosts.

  2. Make it executable:

    # chmod +x
  3. Run:

    # ./

After that go to a CCP for the webspace that does not have chroot environment enabled yet, go to CCP > Websites > Web Hosting Access and set up shell for the user as /bin/bash (chrooted). This will create all chroot directories and files from the skeleton, so PHP will work in chrooted environment after that. Please note that if you set shell back to "Forbidden" or change it to "/bin/bash", all chroot dirs and files will be removed automatically.

Another note: if there any scheduled task in CCP for the user, the chroot environment will not be removed even if you change shell to "Forbidden".

So the best way to set up the environment is to enable it in the CCP (set shell as /bin/bash (chrooted)). However, if you already have a user that have a scheduled task, changing shell in CCP will not take effect. So you can delete the tasks and disable login for the user and enable chrooted /bin/bash again, or update existing chroot environment with the following script (


    if [ ! -d "$webspace" ]; then
      echo "Webspace does not exist"
      exit 1

    if [ ! -d "bin" ] || [ ! -d "dev" ] || [ ! -d "etc" ] || [ ! -d "lib" ] || [ ! -d "lib64" ] || [ ! -d "tmp" ] || [ ! -d "usr" ] || [ ! -d "var" ]; then
      echo "Chroot environment does not exists or not complete."
      echo "Go to CCP > Websites > Web Hosting Access and set up shell for the user as /bin/bash (chrooted)."
      echo "No need to restart this script after that."
      exit 1

    # Create PHP binary
    mkdir $webspace/bin
    \ln -f $vhost_dir/chroot/bin/php $webspace/bin/php

    # Prepare dirs
    mkdir $webspace/lib64
    rm -rf $webspace/lib64/php
    mkdir -p $webspace/lib64/php/modules

    # Create PHP modules
    for i in $(ls $vhost_dir/chroot/lib64/php/modules)
    ln $vhost_dir/chroot/lib64/php/modules/$i $webspace/lib64/php/modules/$i

    # Create libs
    \ln -f $vhost_dir/chroot/lib64/ $webspace/lib64/
    \ln -f $vhost_dir/chroot/lib64/ $webspace/lib64/
    \ln -f $vhost_dir/chroot/lib64/ $webspace/lib64/

    # Add terminal info
    if [ ! -d "$webspace/lib/terminfo" ]; then
      \cp -Rf /lib/terminfo $webspace/lib/

this script will add PHP binaries and libs to existing chroot environment. Run it as follows:

# ./

33a70544d00d562bbc5b17762c4ed2b3 caea8340e2d186a540518d08602aa065 e0aff7830fa22f92062ee4db78133079

Email subscription for changes to this article
Save as PDF