cancel
Showing results for 
Search instead for 
Did you mean: 

magento must be run as a CLI application

magento must be run as a CLI application

I'm installing Magento 2.2.2 on  Centos 7 using Litespeed PHP 7.1.14 and after the install, it appeared no CSS was applied. I found this solution to that problem:

 

php bin/magento setup:static-content:deploy
php bin/magento indexer:reindex
rm -rf var/cache/*
chown -R nobody:nobody

 

but when I run "php bin/magento setup:static-content:deploy" I get this error:

 

#!/usr/bin/env php
bin/magento must be run as a CLI application

 

On the server, other non-Magento php scripts launch without any problems from the command line.

 

PHP Info:

PHP 7.1.14 (litespeed) (built: Feb 5 2018 15:38:16)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.1.14, Copyright (c) 1999-2018, by Zend Technologies

 

 

 

I solved this by removing:

if (PHP_SAPI !== 'cli') {
echo 'bin/magento must be run as a CLI application';
exit(1);
}

from /bin/magento

1 REPLY 1

Re: magento must be run as a CLI application

You'll want to make sure that you're using the CLI version of PHP. Check https://mage2.pro/t/topic/2318

----
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution" as appropriate. Thanks!