admin管理员组

文章数量:1289832

I have an Ubuntu server, typical LAMP stack with default www-data as the user / group under which Apache serves files.

When updating with WP-CLI I always have to type --allow-root flag.

How do I avoid this?

If I do what the software suggests then sudo -u www-data -i -- wp <command> throws an error: "This account is currently not available."

I have an Ubuntu server, typical LAMP stack with default www-data as the user / group under which Apache serves files.

When updating with WP-CLI I always have to type --allow-root flag.

How do I avoid this?

If I do what the software suggests then sudo -u www-data -i -- wp <command> throws an error: "This account is currently not available."

Share Improve this question asked Aug 22, 2016 at 20:18 user658182user658182 6252 gold badges14 silver badges35 bronze badges
Add a comment  | 

5 Answers 5

Reset to default 5

All files and folders should be owned by www-data user and group if not then WordPress can't change files hence fails to update from dashboard. wp-cli says to use sudo -u www-data -i -- wp <command> but that gives This account is currently not available.

Why? See this answer: https://askubuntu/a/486661/695240

You're getting the This account is currently not available. error because the shell for the user www-data is set to /usr/sbin/nologin, and it's set for a very good reason. You should not log in as www-data, it's a special user/group used by the web server, not intended for regular shell use.

EDIT: It is an especially bad idea to give sudo rights to www-data. If Apache was intended to run with root permissions, it wouldn't have it's own group. By doing this, you are creating huge security holes. You have been warned.

What is the solution? Use sudo -u www-data wp<command>. So you don't have problem using wp-cli and is safe. All files create by wp-cli will be owned by www-data.

first of all you need to fix so you're allowed to login as www-data if that's what you want to do. Otherwise you can do this as root. If you're logged in as root, add to your shell (i.e. /root/.bash_aliases)

alias wp='wp --allow-root'

That's all.

I got the recommendation to use www-data too at first, but in another thread people were recommending against using the www-data user, because it's a special user that shouldn't be used for this purpose.

So then I figured out how to add a new user to SSH via a Digital Ocean tutorial. Run adduser exampleusername and then you can run su - exampleusername to switch to that user. Now wp will run without giving the root user error message.

It's baffling that I couldn't find that written down anywhere. The WP docs and most of the conversation about this assume that everybody already knows their way around a server.

You will need login into the user you will use for wordpress, I think the default user will admin, then you will need login in SSH with:

ssh admin@put-your-ip Add password

Then you can go now

If you are logged in as root, just become another user with the following command:

su [username]

Replace [username] with something like admin, or a user you know has privileges to run wp cli commands. (admin should be there in many cases).

When done, exit out of that user operation.

本文标签: apacheWhat39s the proper way to setup WPCLI on Ubuntu so that I don39t have to use the flag allowroot