Not running Composer as root


When running Composer commands as root user (using "sudo") I get warnings telling me not to do so.

The operation still works, but those warnings seem pretty serious.

However I am installing my Yii2 project under my Apache document root. This is typically not writable without root privileges. I assume this is the case in most commercial environments.

What is the recommended way to use Composer without [size="2"]root privileges?[/size]

[size="2"](I assume this is a very common question and must have been asked before. But if I try to do a search on this forum, I get results from other parts of the [/size] website, not this forum. How can we just search this forum?)


Make Apache Document root writable without root permissions.You should Not run composer as root

OK, got it, thanks. I’ll do that on my own local development environment.

However what do people do in production environments, which they don’t have control and can’t make DocumentRoot writable without root permissions? Is this not a common issue for most people in commercial environments?

If you’re referring to Shared hosts, then you are wrong. They are writable.

By Shared hosts, do you mean commercial web hosting services (like Bluehost, GoDaddy, etc)?