ComposerLinuxWHM/cPanel

Composer issue on Linux with different users

By July 31, 2017 No Comments

While SSH’d into my Centos server recently, I kept getting strange errors when trying to run PHP Artisan and Composer commands.  I couldn’t figure out for the life of me what I had changed to cause the issue all of a sudden.

Of course it ended up being one of those things so simple it was over looked.  This site happened to be on a WHM/cPanel environment.  It also runs different versions on PHP based on the cPanel account.

When logging in as root I then switched users to my account:

su accountName

Then I ran:

composer update

It kept erroring with:

Warning: Composer should be invoked via the CLI version of PHP, not the cgi-fcgi SAPI

I then realized what the problem was.  When switching users I forgot the “-” dash, but didn’t think it made a difference.  Come to find out “su accountName” is different from “su – accountName”.

When using the dash in there it will read-in user-specific environmental variables, without the dash will not.

Simple solution.

Leave a Reply