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."
5 Answers
Reset to default 5All 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.
版权声明:本文标题:apache - What's the proper way to setup WP-CLI on Ubuntu so that I don't have to use the flag --allow-root? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741451884a2379531.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论