setup:upgrade and setup:di:compile not working

setup:upgrade and setup:di:compile not working

September 9, 2026 · Illustrated author avatarBy Stefan Bogdanescu
setup:upgrade and setup:di:compile not working

Resolving “setup:upgrade” and “setup:di:compile” Errors in Magento 2

Understanding the Issue

You’re encountering errors while trying to run bin/magento setup:upgrade and bin/magento setup:di:compile commands on your Magento 2.1 installation hosted on Plesk Onyx 17.8 running CentOS 7 with PHP 7.0.33. The memory exhaustion error during the DI compilation process is particularly challenging.

Root Cause Analysis

The primary issue lies in the compatibility between the Magento version, PHP version, and your server environment:

  1. PHP Version Mismatch: You’re using PHP 5.4.16 for CLI which is not compatible with Magento 2.1.
  2. Memory Limitations: The memory allocated to PHP (134217728 bytes or 128MB) is insufficient for the DI compilation process.
  3. Plesk Environment: Plesk manages multiple PHP versions and environments, which can lead to conflicts.

Step-by-Step Solution

1. Update PHP Version

To resolve the initial error about Magento supporting only specific PHP versions, you need to update your CLI PHP version:

  • Log in to your Plesk control panel.
  • Navigate to “Subscriptions” and select your domain.
  • Go to the “PHP Settings” tab.
  • Ensure that the PHP version for the /opt/plesk/php folder matches the one required by Magento (7.0.2 or later).

2. Increase Memory Limit for CLI

To address the memory exhaustion issue during DI compilation:

  1. Open the cli.ini file located in your PHP’s directory (/opt/plesk/php/7.0/lib/php.ini).

    sudo nano /opt/plesk/php/7.0/lib/php.ini
    
  2. Add or modify the following line to increase the memory limit:

    memory_limit = 512M
    
  3. Save and close the file.

3. Clear Cache and Recompile DI

After updating PHP and increasing the memory limit, run the commands again with additional parameters to clear cache first:

/opt/plesk/php/7.0/bin/php bin/magento cache:flush
/opt/plesk/php/7.0/bin/php bin/magento setup:upgrade -vvv

Then recompile the DI:

/opt/plesk/php/7.0/bin/php bin/magento setup:di:compile -vvv

4. Troubleshooting Additional Errors

If you still face issues due to class file dependencies or other errors, ensure that all PHP extensions required by Magento are enabled in the php.ini file.

Conclusion and Best Practices

  • Always match your CLI PHP version with the one set for your webserver when working with Magento.
  • Ensure sufficient memory is allocated for PHP when performing heavy tasks like DI compilation.
  • Regularly update your PHP version to the latest stable release compatible with your Magento version.
  • Consult the official Magento DevDocs and our LaravelCompany Guide on Magento 2 Troubleshooting for comprehensive solutions.

By following these steps, you should be able to successfully run setup:upgrade and setup:di:compile commands without encountering the errors described in your post. If issues persist after implementing these changes, please refer to the official Magento support resources or contact a professional developer.

Magento 2 Configuration Deployment Errors

Our network