Overview

Plesk introduced a new feature in Plesk 18.0.44 and above which syncronises the PHP version on the site with the PHP version available via SSH for utilities such as Composer and WP-CLI.

When attempting to run a WP-CLI command, you may see an error similar to:

PHP Warning:  Phar::mapPhar(): open_basedir restriction in effect. File(/usr/bin/wp) is not within the allowed path(s): (/var/www/vhosts/yourwebsite/:/tmp/) in /usr/bin/wp on line 3

By default, Plesk limits where PHP can access files for security reasons to temp files and the home directory of your server.

These instructions are for Virtual Private Server (VPS) customers only.

Fix

To allow WP-CLI, we need to explicitly allow the WP-CLI script to be run via PHP.

  1. Login into your Plesk VPS.
  2. Within the site you’re having issues with WP-CLI, go to PHP Settings:
    wp-cli not working via ssh with open_basedir error
  3. Scroll down to the open_basedir section and add :/usr/bin/wp (noting the colon at the front) to the end of the existing configuration:
    wp-cli not working via ssh with open_basedir error
  4. Save the settings and confirm you can now run the wp command within the website.
  5. Repeat for any other websites on your VPS which require WP-CLI access.
Was this article helpful?

Related Articles