PHP 7.3 reached end of support in December 2021 and Adobe Commerce 2.3.x reaches end of support in September 2022. You may want to consider planning your upgrade now to Adobe Commerce 2.4.x and PHP 7.4.x to help maintain PCI compliance.

Uninstall or reinstall Commerce

First steps

  1. Log in to the Magento server as, or switch to, a user with permissions to write to the Magento file system. See switch to the file system owner.

    If you use the bash shell, you can use the following syntax to switch to the file system owner and enter the command at the same time:

    su <file system owner> -s /bin/bash -c <command>

    If the file system owner does not allow logins, you can do the following:

    sudo -u <file system owner>  <command>
  2. To run Magento commands from any directory, add <magento_root>/bin to your system PATH.

    Because shells have differing syntax, consult a reference like

    Sample bash shell for CentOS:

    export PATH=$PATH:/var/www/html/magento2/bin

    Optionally, you can run the commands in the following ways:

    • cd <magento_root>/bin and run them as ./magento <command name>
    • <magento_root>/bin/magento <command name>
    • <magento_root> is a subdirectory of your web server docroot.

In addition to the command arguments discussed here, see Common arguments.


Before you use these commands, you must install the Magento software.

Update the Magento software

To update the Magento software:

  • If you installed the software from an archive or if you used ‘composer-create-project’, see the Upgrade Guide.
  • If you are a contributing developer (that is, you used git clone), see Update the Magento application.

Reinstall the Magento software

The way you reinstall the Magento application from the command line depends on your role:

Uninstall the Magento software

Uninstalling the Magento software drops and restores the database, removes the deployment configuration, and clears directories under var.

To uninstall the Magento software, enter the following command:

bin/magento setup:uninstall

The following message displays to confirm a successful uninstallation:

[SUCCESS]: Magento uninstallation complete.

Optionally keeping generated files

By default, bin/magento setup:upgrade clears compiled code and the cache. Typically, you use bin/magento setup:upgrade to update components and each component can require different compiled classes.

However, in some situations (particularly, deploying Magento to production), you might wish to avoid clearing compiled code because it can take some time. (The cache is still cleared.) To update the Magento database schema and data without clearing compiled code, enter:

bin/magento setup:upgrade --keep-generated

The optional --keep-generated option should be used only in limited circumstances by experienced system integrators. This option should never be used in a development environment. Improper use of this optional parameter can cause errors during code execution.

Install the Magento software