Upgrade Magento 1.x to the latest version

This article shows how you can upgrade/update your Magento 1.x via both Browser GUI and Command Line.

Note:

– Magento/Adobe ended support for Magento 1.x software on June 30, 2020.
– After that day, the Magento 1 software repo was removed.
– All Magento 1 extensions were removed from the official extension site.

When you try to upgrade/update Magento 1.x then you will get error like “connect.magentocommerce.com” could not be found or something like that.
Hence, the instructions below will not work from now onwards.

SOLUTION

Openmage.org has come to rescue.

OpenMage LTS allows Magento 1.x EOL merchants to continue running a secure, stable Magento-based platform while remaining PCI compliant.

There are two main repositories in the OpenMage’s GitHub account:

magento-mirror: This repo contains official Magento 1.x releases done by Magento/Adobe. The latest version of Magento 1 (version 1.9.4.5) was released on May 4, 2020.

If you want to update your Magento 1.x site to Magento 1.9.4.5 then you can simply download the file from this repo and paste them into your Magento website. But, first, make sure to take backup of your Magento files and database before doing pasting the files to your site.

magento-lts: This is the official OpenMage LTS codebase. It’s new releases are the enhancement over the last Magento 1.x version released, i.e. 1.9.4.5. You can migrate easily from Magento Community Edition in minutes! The source code is free to download, modify and you can contribute to the Magento LTS code as well. This repo contains regular security vulnerability patches, bug fixes, performance improvements, etc. to the Magento 1.x software.

OLD CONTENT BELOW

BELOW INSTRUCTIONS ARE NOT WORKING AFTER JUNE 30, 2020

Before upgrading, we first have to create backup of our Magento site’s files and database so that we can restore the backed up files and database if by any problem the upgrade process fails.

Upgrade Magento 1.x via Browser (Magento Connect Manager)

Backup files and database

Before upgrading, you have to backup your Magento site’s files and database. To backup files and database via Browser GUI, you have to login to Control Panel (Cpanel) of your webhost.

In Control Panel, you have:

  • File Manager menu from where you can backup files (i.e. make a compress/zipped copy of your files)
  • PHPMyAdmin menu from where you can export your database tables and data in SQL file or in Zipped file format

Upgrade Magento

Upgrading Magento 1.x via browser GUI is simple and easy. Here are the steps to follow:

1) Login to your Magento Admin.

2) Disable Cache (System -> Cache Management) and Compilation (System -> Tools -> Compilation).

3) Go to System -> Magento Connect -> Magento Connect Manager

a) If you see a Login Form then move to Step 3) below.

b) If you see 403 Forbidden error then:

– Go to your Magento files directory
– After that, go inside folder downloader
– The magento_root/downloader/.htaccess file contains the following part of code:


order deny,allow
deny from all
allow from xx.xx.xx.xx

– Replace the above xx.xx.xx.xx with your IP address.
– You can get your IP address by simply googling what is my ip address.

4) Enter your Admin username and password, and click the Log In button.

5) After you login successfully, you will see the following page:

6) Click on the Check for Upgrades button present in that page.

7) After that, all the Magento modules and packages that have available upgrades will be highlighted in yellow color like in the below image:

8) Then, in the Action column, you can select the version to which you want to upgrade each package. You can select the latest version available in the select box.

9) After that, click on the Commit Changes button.

10) Then, it will take some time to complete the upgrade process.

11) After upgrade is complete, you can login to your Magento admin and enable Cache (System -> Cache Management) and Compilation (System -> Tools -> Compilation).

Upgrade Magento 1.x via Command Line

Backup files and database

Before upgrading, you have to backup your Magento site’s files and database. To backup files and database via Command Line, you have to follow the below steps:

1) Open Terminal/Command-prompt and Go to your Magento root directory with the following command:


cd /path/to/your/magento/folder
# example: cd /var/www/html/magento

2) Create files backup


tar -zcvf your-magento-site.tgz .

3) Create database backup


mysqldump -u your-database-username -p your-database-name | gzip > your-database-name.sql.gz

When you run the above command, it will ask for your database password. Enter your database password and then your database will be exported in the GZ file format.

Upgrade Magento

Here are the steps to follow while upgrading Magento 1.x via command line:

1) Open Terminal/Command-prompt and Go to your Magento root directory with the following command:


cd /path/to/your/magento/folder
# example: cd /var/www/html/magento

2) Enable Maintenance mode for your Magento site

For this, you have to create an empty file named maintenance.flag in your Magento root directory.


touch maintenance.flag

3) Clear Cache & Sessions


rm -rf var/cache/* var/session/*

4) Check Compilation & Disable it if Enabled

You can run the following command to see the available options for compilation:


php -f shell/compiler.php 

Output:


Usage:  php -f compiler.php -- [options]

  state         Show Compilation State
  compile       Run Compilation Process
  clear         Disable Compiler include path and Remove compiled files
  enable        Enable Compiler include path
  disable       Disable Compiler include path
  help          This help

So, to check the status of the compilation, we run the following command:


php -f shell/compiler.php -- state

If the Compiler Status is Disabled then you can move on to the next step.

If the Compiler Status is Enabled then you have to disable it with the following command:


php -f shell/compiler.php -- disable

5) Give write permission to all Magento files and folders


chmod -R 777 .

6) Give 550 permission mage file which is a shell script file. With 550 permission, we are just making the file non-writable + readable & executable by user and group only.


chmod 550 ./mage

7) List all the available commands with mage script


./mage mage-setup .

Output:


Connect commands available:
===========================
channel-add          Add a Channel       
channel-alias        Specify an alias to a channel name
channel-delete       Remove a Channel From the List
channel-info         Retrieve Information on a Channel
channel-login        Connects and authenticates to remote channel server
channel-logout       Logs out from the remote channel server
clear-cache          Clear Web Services Cache
config-get           Show One Setting    
config-help          Show Information About Setting
config-set           Change Setting      
config-show          Show All Settings   
convert              Convert old magento PEAR package to new format
download             Download Package    
info                 Display information about a package
install              Install Package     
install-file         Install Package Archive File
list-available       List Available Packages
list-channels        List Available Channels
list-files           List Files In Installed Package
list-installed       List Installed Packages In The Default Channel
list-upgrades        List Available Upgrades
package              Build Package       
package-dependencies Show package dependencies
package-prepare      Show installation information of package
sync                 Synchronize Manually Installed Packages
sync-pear            Synchronize already Installed Packages by pear
uninstall            Un-install Package  
upgrade              Upgrade Package     
upgrade-all          Upgrade All Packages

8) Change config settings to stable


./mage config-set preferred_state stable

9) List all installed packages in your Magento site


./mage list-installed

Output:


Installed package for channel 'community' :
Cm_RedisSession      1.8.0.0 stable      
Interface_Adminhtml_Default 1.9.1.0 stable      
Interface_Frontend_Base_Default 1.9.1.0 stable      
Interface_Frontend_Default 1.9.1.0 stable      
Interface_Frontend_Rwd_Default 1.9.1.0 stable      
Interface_Install_Default 1.9.1.0 stable      
Lib_Cm               1.8.0.0 stable      
Lib_Credis           1.8.0.0 stable      
Lib_Google_Checkout  1.9.1.0 stable      
Lib_Js_Calendar      1.51.1.1 stable     
Lib_Js_Ext           1.7.0.0 stable      
Lib_Js_Mage          1.9.1.0 stable      
Lib_Js_Prototype     1.7.0.0.5 stable    
Lib_Js_TinyMCE       3.5.11.0 stable     
Lib_LinLibertineFont 2.8.14.1 stable     
Lib_Mage             1.9.1.0 stable      
Lib_Magento          1.9.1.0 stable      
Lib_Pelago           1.9.1.0 stable      
Lib_Phpseclib        1.5.0.0 stable      
Lib_Varien           1.9.1.0 stable      
Lib_ZF               1.12.7.0 stable     
Lib_ZF_Locale        1.12.7.0 stable     
Mage_All_Latest      1.9.1.0 stable      
Mage_Centinel        1.9.1.0 stable      
Mage_Compiler        1.9.1.0 stable      
Mage_Core_Adminhtml  1.9.1.0 stable      
Mage_Core_Modules    1.9.1.0 stable      
Mage_Downloader      1.9.1.0 stable      
Mage_Locale_en_US    1.9.1.0 stable      
Magento_Mobile       1.9.1.0 stable      
Phoenix_Moneybookers 1.3.2.1 stable      

10) Skip this step if you get the above output of installed packages. If the packages are not listed then you can run the following command:


./mage install http://connect20.magentocommerce.com/community Mage_All_Latest --force

11) If the packages are listed properly, then you can see the list of upgradable packages (i.e. packages that need an upgrade) by running the following command:


./mage list-upgrades

Output:


Updates for community: 
  Cm_RedisSession: 1.8.0.0 => 1.9.3.6
  Interface_Adminhtml_Default: 1.9.1.0 => 1.9.3.6
  Interface_Frontend_Base_Default: 1.9.1.0 => 1.9.3.6
  Interface_Frontend_Default: 1.9.1.0 => 1.9.3.6
  Interface_Frontend_Rwd_Default: 1.9.1.0 => 1.9.3.6
  Interface_Install_Default: 1.9.1.0 => 1.9.3.6
  Lib_Cm: 1.8.0.0 => 1.9.3.6
  Lib_Credis: 1.8.0.0 => 1.9.3.6
  Lib_Google_Checkout: 1.9.1.0 => 1.9.3.6
  Lib_Js_Calendar: 1.51.1.1 => 1.51.1.12
  Lib_Js_Ext: 1.7.0.0 => 1.9.3.6
  Lib_Js_Mage: 1.9.1.0 => 1.9.3.6
  Lib_Js_Prototype: 1.7.0.0.5 => 1.9.3.6
  Lib_Js_TinyMCE: 3.5.11.0 => 3.5.11.11
  Lib_LinLibertineFont: 2.8.14.1 => 2.8.14.12
  Lib_Mage: 1.9.1.0 => 1.9.3.6
  Lib_Magento: 1.9.1.0 => 1.9.3.6
  Lib_Pelago: 1.9.1.0 => 1.9.3.6
  Lib_Phpseclib: 1.5.0.0 => 1.9.3.6
  Lib_Varien: 1.9.1.0 => 1.9.3.6
  Lib_ZF: 1.12.7.0 => 1.12.10.11
  Lib_ZF_Locale: 1.12.7.0 => 1.12.10.11
  Mage_All_Latest: 1.9.1.0 => 1.9.3.6
  Mage_Centinel: 1.9.1.0 => 1.9.3.6
  Mage_Compiler: 1.9.1.0 => 1.9.3.6
  Mage_Core_Adminhtml: 1.9.1.0 => 1.9.3.6
  Mage_Core_Modules: 1.9.1.0 => 1.9.3.6
  Mage_Downloader: 1.9.1.0 => 1.9.3.6
  Mage_Locale_en_US: 1.9.1.0 => 1.9.3.6
  Magento_Mobile: 1.9.1.0 => 1.9.3.6
  Phoenix_Moneybookers: 1.3.2.1 => 1.9.3.6

The above output shows that most of the packages are with version 1.9.1.0 and they can be upgraded to the latest version at the time of writing this article, which is 1.9.3.6.

12) Upgrade all packages


./mage upgrade-all

OR,


./mage upgrade-all --force

13) After completing the upgrade, we should reindex all data.


php shell/indexer.php reindexall

14) Then, clear cache and session again.


rm -rf var/cache/* var/session/*

15) Enable Compilation only if it was Enabled before upgrade

Check step 4) above.

If Compilation was not enabled in step 4) then you can skip this step and go to next step.

If Compilation was enabled for your website and you had disabled it at step 4) then you have to Enable it with the following command:


php -f shell/compiler.php -- enable

16) Before the upgrade, we have changed the permission of all files and folders to 777. You should also give proper permission to all files and folders of your Magento site.

  • Convert files permission to 644 and folders permission to 755

find . -type f -exec chmod 644 {} \; && find . -type d -exec chmod 755 {} \;
  • Give read-write full permission, i.e. 777 to var and media folders.

chmod -R 777 var media
  • Give 550 permission to mage shell script file

chmod 550 ./mage

17) Check the versions of the installed packages. The packages should show the latest version as they are already upgraded now.


./mage list-installed

18) List the upgradable packages (packages that need an upgrade). This should result in a message saying No upgrades available because all packages have been already upgraded to the latest version.


./mage list-upgrades 

19) Disable Maintenance mode to make the site Live.

rm -f maintenance.flag

This will delete the file maintenance.flag and then the site will be live again.

You can now login to Magento admin and see the Magento version displayed in the footer section. It should show the latest version number.

Hope this helps. Thanks.