This was strange one. When calling simple magento command with PHP CLI I was getting error that allowed memory size was exhausted.
[root@machine ~]# php bin/magento module:status [root@machine ~]# PHP Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 32768 bytes) in /path/to/wwww/magentoshot.com/vendor/symfony/console/Application.php on line 951
I checked php.ini and it was set like this:
memory_limit = 2048M
I checked if there are different values for CLI version. It were the same.
Solution was simple. Change your php.ini value for memory_limit and define it in gigabytes instead in megabytes.
memory_limit = 2G
I restarted Apache and it started to work.