> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.weltpixel.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# How to upgrade Magento 2 to a newer version and install latest security patches

# How to upgrade Magento 2 to a newer version and install latest security patches

**Note:** Make sure to back up your store and database before performing a Magento upgrade.

**Note 2:** Backup your `.htaccess` file, as it will be overwritten when you upgrade.

---

### Step 1: Run upgrade commands via SSH

Connect to your server via SSH and run the following commands from the root of your Magento installation:

```bash
php bin/magento deploy:mode:set developer

composer require magento/product-community-edition 2.2.5 --no-update

composer update

rm -Rf var/cache/ var/generation/ var/page_cache/ var/view_preprocessed/ var/di;

php bin/magento setup:upgrade
```

---

### Step 2: Restore your `.htaccess` file

After the upgrade, restore your `.htaccess` file from the backup you created earlier.

---

For more details about the upgrade process, please refer to the [Official Magento 2 Documentation](https://devdocs.magento.com/guides/v2.2/comp-mgr/bk-compman-upgrade-guide.html).