try to run the failing command with the -vvv
switch (for very verbose output).
/usr/bin/php7.0 -f /var/www/magento2/bin/magento setup:di:compile -vvv
with this command you should at least get a better error message than "an error occurred..."
very likely, it's just the memory_limit being too low. You can increase the memory limit for a php process by adding the -d parameter to the php command:
/usr/bin/php7.0 -d memory_limit=1G -f /var/www/magento2/bin/magento setup:di:compile
if you run deploy:mode:set production, the compilation will be startet as a sub process and you can't increase the memory limit like this (since the parameter is not passed to the sub command)
in this case, you have to increase the memory limit in your php configuration
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…