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
Create the script php2chroot.sh with the following content (on the web server):
#!/bin/bash vhost_dir=/var/www/vhosts \cp -f /usr/bin/php $vhost_dir/chroot/bin/ \cp -Rf /usr/lib64/php/ $vhost_dir/chroot/lib64/ \cp -f /usr/lib64/libedit.so.0 $vhost_dir/chroot/lib64/ \cp -f /usr/lib64/libgmp.so.3 $vhost_dir/chroot/lib64/ \cp -f /usr/lib64/libxml2.so.2 $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.
Make it executable:
# chmod +x php2chroot.sh
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 (php2webspace.sh):
#!/bin/bash vhost_dir=/var/www/vhosts domain=$1 webspace=$vhost_dir/$domain if [ ! -d "$webspace" ]; then echo "Webspace does not exist" exit 1 fi 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 fi # 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) do ln $vhost_dir/chroot/lib64/php/modules/$i $webspace/lib64/php/modules/$i done # Create libs \ln -f $vhost_dir/chroot/lib64/libedit.so.0 $webspace/lib64/libedit.so.0 \ln -f $vhost_dir/chroot/lib64/libgmp.so.3 $webspace/lib64/libgmp.so.3 \ln -f $vhost_dir/chroot/lib64/libxml2.so.2 $webspace/lib64/libxml2.so.2 # Add terminal info if [ ! -d "$webspace/lib/terminfo" ]; then \cp -Rf /lib/terminfo $webspace/lib/ fi
this script will add PHP binaries and libs to existing chroot environment. Run it as follows:
# ./php2webspace.sh example.com