[WordPress] WP-CLI エラー対処方法

1 min read
hiroweb developer

以下の様な長文のエラーが表示される場合の話。

対処方法

エラーメッセージの理由

Error: YIKES! It looks like you're running this as root. You probably meant to run this as the user that your WordPress install exists under.

If you REALLY mean to run this as root, we won't stop you, but just bear in mind that any code on this site will then have full control of your server, making it quite DANGEROUS.

If you'd like to continue as root, please run this again, adding this flag: --allow-root

If you'd like to run it as the user that this site is under, you can run the following to become the respective user:

sudo -u USER -i -- wp &lt;command&gt;</pre>

きちんと読めばここに載っているのだけれども、行数が長いと読み飛ばしてしまう人もいるはず。
「root で実行すると危なくない?いいの?」って感じの内容。

対処方法は コマンドに--allow-rootを付けるだけ。
たぶん root 権限のユーザで実行しているんじゃないかしら。

実行するコマンド

wp core check-update --allow-root