Running the Craft Console Command as Root

Craft 3.7 and higher will warn you if you try to run the craft console command as a system’s root user in an interactive environment:

Craft commands should not be run as the root user.

You’ll be prompted to proceed anyway, but please be aware that it’s generally a bad practice that should be avoided.

Be sure to SSH into any remote servers and execute commands as the appropriate user, and make sure your environment is configured properly with the appropriate permissions in the first place.

Normally Craft should be run as the web user, able to execute PHP files and read+write files it needs to work with. When you run the craft command as a root or super user, any files it creates get root permissions that could lead to more conflicts. (You can fix those as long as you find them and use chown to reassign them to www-data or whatever user and group your environment uses for web permissions.)

Composer issues a warning if it’s run as a root/super user for the same reason.

Further Reading #