LoginSignup
0
0

More than 5 years have passed since last update.

AMIMOTO AMIのrootユーザーで–allow-rootオプションを使わずにWP-CLIを使用する

Posted at

前提

WP-CLI の –allow-root オプションは非推奨です! - firegoby

# wp core version
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 <command>

--allow-rootじゃなく、sudo -u USER -i -- wpでroot以外のユーザーとして実行してくれ」とメッセージが出るようになっています。

ただEC2 System ManagerのRun CommandやUserDataなど、rootユーザーでコマンドを実行するケースも少なからずあります。

AMIMOTO AMI(セルフホスティング)でrootユーザーからWP-CLIを実行する

AMIMOTOの場合は以下のようにすることで、rootユーザーでのコマンド実行時にも問題なく動作させることができます。

# sudo -u nginx /usr/local/bin/wp core update
Updating to version 4.7.3 (en_US)...
Downloading update from https://downloads.wordpress.org/release/wordpress-4.7.3-new-bundled.zip...
Unpacking the update...
Cleaning up files...
No files found that need cleaned up.
Success: WordPress updated successfully.

run-httpd-as-ec2-user(SFTP接続対応など)を実行している場合

AMIMOTO AMI で作成したインスタンスへ ec2-user で SFTP 接続をする方法 – FAQ & SUPPORTなどで紹介されている方法で、PHP-FPMやNginxをec2-userで動作させている場合は以下のようになります。

# sudo -u ec2-user /usr/local/bin/wp core update
Updating to version 4.7.3 (en_US)...
Downloading update from https://downloads.wordpress.org/release/wordpress-4.7.3-new-bundled.zip...
Unpacking the update...
Cleaning up files...
No files found that need cleaned up.
Success: WordPress updated successfully.
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0