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.
Fix
To allow WP-CLI, we need to explicitly allow the WP-CLI script to be run via PHP.
- Login into your Plesk VPS.
- Within the site you’re having issues with WP-CLI, go to PHP Settings:
- 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:
- Save the settings and confirm you can now run the wp command within the website.
- Repeat for any other websites on your VPS which require WP-CLI access.