Contents
See one of the following sections:
- First steps
- Prerequisites
- Update the Magento software
- Reinstall the Magento software
- Uninstall the Magento software
- Optionally keeping generated files
First steps
-
Log in to the Magento server as, or switch to, a user who has permissions to write to the Magento file system. One way to do this is to switch to the Magento file system owner.
If you use the bash shell, you can also use the following syntax to switch to the Magento file system owner and enter the command at the same time:
su <Magento file system owner> -s /bin/bash -c <command>
-
To run Magento commands from any directory, add
<your Magento install dir>/bin
to your systemPATH
.Because shells have differing syntax, consult a reference like unix.stackexchange.com.
bash shell example for CentOS:
export PATH=$PATH:/var/www/html/magento2/bin
You can also run the commands in the following ways:
cd <your Magento install dir>/bin
and run them as./magento <command name>
php <your Magento install dir>/bin/magento <command name>
<your Magento install dir>
is a subdirectory of your web server's docroot. Need help locating the docroot? Click here.
In addition to the command arguments discussed here, see Common arguments.
Prerequisites
Before you use this command, 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’, use the Component Manager or System Upgrade utilities.
- If you are a contributing developer (that is, you used
git clone
), see Contributing developers—update, reinstall Magento.
Reinstall the Magento software
This section discusses how to uninstall and then reinstall the Magento software with the latest version.
The way you reinstall the Magento application from the command line depends on your role:
- If you installed the software from an archive or if you used ‘composer-create-project’, see Reinstall as a system integrator.
- If you’re a contributing developer (that is, you started using
composer clone
), see Contributing developers—update, reinstall Magento.
Reinstall as a system integrator
To reinstall the Magento software as a system integrator:
- Log in to your Magento server as a user with permissions to modify files in the Magento file system (for example, the switch to the Magento file system owner).
-
Enter the following commands in the order shown:
cd <your Magento install dir> git pull origin develop php bin/magento setup:uninstall
- If
git pull origin develop
fails, see troubleshooting. - To use your existing Magento software version , omit the
git pull origin develop
command.
- If
-
Install the Magento software:
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:
magento setup:uninstall
The following message displays to confirm a successful uninstallation:
[SUCCESS]: Magento uninstallation complete.
Optionally keeping generated files
By default, magento setup:upgrade
clears compiled code and the cache. Typically, you use 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:
magento setup:upgrade --keep-generated
The optional --keep-generated
option should be used only in limited circumstances by experienced system integrators. --keep-generated
should never be used in a development environment.
Improper use of this optional parameter can cause errors during code execution.
-
Install the Magento software:
Find us on