admin管理员组文章数量:1130349
I installed this package on WP-CLI. When I run wp login create in bash it works fine, but when I run exec("wp login create") in PHP script WP-CLI return this error:
Error: 'login' is not a registered wp command. See 'wp help' for available commands.
Did you mean 'plugin'?
I checked the user from exec("whoami") and it's the same. How can I find the problem?
EDIT
when I run wp package list in PHP it returns:
Error: Composer directory '/.wp-cli/packages' for packages couldn't be created: mkdir(): Permission denied
I installed this package on WP-CLI. When I run wp login create in bash it works fine, but when I run exec("wp login create") in PHP script WP-CLI return this error:
Error: 'login' is not a registered wp command. See 'wp help' for available commands.
Did you mean 'plugin'?
I checked the user from exec("whoami") and it's the same. How can I find the problem?
EDIT
when I run wp package list in PHP it returns:
Share Improve this question edited Oct 23, 2018 at 6:36 Ali Sh asked Oct 22, 2018 at 12:33 Ali ShAli Sh 665 bronze badges 4 |Error: Composer directory '/.wp-cli/packages' for packages couldn't be created: mkdir(): Permission denied
1 Answer
Reset to default 1According to Alain Schlesser in wordpress slack:
The folder that the packages are installed into is set to use your server user's home folder. When you try to execute this command from PHP, however, it is being executed by the webserver's user, which probably has a different home folder, and the package is not installed in there.
You can either load the package manually as part of the system (requiring it in the site's Composer stack, for example), or set the package folder to a location that is shared by both your user and your webserver (and reinstall it afterwards).
You can set the packages folder with the WP_CLI_PACKAGES_DIR environment variable: https://make.wordpress/cli/handbook/config/#environment-variables
I installed this package on WP-CLI. When I run wp login create in bash it works fine, but when I run exec("wp login create") in PHP script WP-CLI return this error:
Error: 'login' is not a registered wp command. See 'wp help' for available commands.
Did you mean 'plugin'?
I checked the user from exec("whoami") and it's the same. How can I find the problem?
EDIT
when I run wp package list in PHP it returns:
Error: Composer directory '/.wp-cli/packages' for packages couldn't be created: mkdir(): Permission denied
I installed this package on WP-CLI. When I run wp login create in bash it works fine, but when I run exec("wp login create") in PHP script WP-CLI return this error:
Error: 'login' is not a registered wp command. See 'wp help' for available commands.
Did you mean 'plugin'?
I checked the user from exec("whoami") and it's the same. How can I find the problem?
EDIT
when I run wp package list in PHP it returns:
Share Improve this question edited Oct 23, 2018 at 6:36 Ali Sh asked Oct 22, 2018 at 12:33 Ali ShAli Sh 665 bronze badges 4Error: Composer directory '/.wp-cli/packages' for packages couldn't be created: mkdir(): Permission denied
- 1 You might get different result because you are running the commands under different user. – Thomas Commented Oct 22, 2018 at 12:40
-
but I run the command in bash with a user named admin@server and when I run
exec("whoami")in PHP it says admin. can you explain how are they different? – Ali Sh Commented Oct 23, 2018 at 4:57 - is the group also the same? – Thomas Commented Oct 23, 2018 at 7:31
-
yes it is the same. I checked with
hostnamecommand. – Ali Sh Commented Oct 23, 2018 at 8:17
1 Answer
Reset to default 1According to Alain Schlesser in wordpress slack:
The folder that the packages are installed into is set to use your server user's home folder. When you try to execute this command from PHP, however, it is being executed by the webserver's user, which probably has a different home folder, and the package is not installed in there.
You can either load the package manually as part of the system (requiring it in the site's Composer stack, for example), or set the package folder to a location that is shared by both your user and your webserver (and reinstall it afterwards).
You can set the packages folder with the WP_CLI_PACKAGES_DIR environment variable: https://make.wordpress/cli/handbook/config/#environment-variables
本文标签: wp cliDifferent output from WPCLI in bash vs PHP exec()
版权声明:本文标题:wp cli - Different output from WP-CLI in bash vs PHP exec() 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749239740a2337879.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


exec("whoami")in PHP it says admin. can you explain how are they different? – Ali Sh Commented Oct 23, 2018 at 4:57hostnamecommand. – Ali Sh Commented Oct 23, 2018 at 8:17