How to upgrade Magento version to through SSH command line

This tutorial will explain how to upgrade and old magento version to latest version ( at the time of writing). Since Magento database structure has major changes from version to 1.4.2 the best approach would be to first upgrade to version 1.4.2 and then directly to This tutorial assumes that you have SSH access to your Magento server.

Page 1 - Upgrading to version 1.4.2

As mentioned above we will first update Magento version to 1.4.2. According to some board discutions from, you should substitute the file downloader/pearlib/php/Archive/Tar.php with the patched version available here:

Before starting the upgrade procedures make sure you have a backup of your Magento files and database, just in case something goes wrong and the site gets broken. Next connect to your server SSH and go to your store folder to execute the following commands. It is possible that you will see warnings about some deprecated functions (nothing to worry about).

If you work on SSH with root user you will have to chown the upgraded files to correct user:group, otherwise you will see 500 server error.

Make folder lib/PEAR writable (recursively):

chmod -R 777 lib/PEAR

Prepare Magento for upgrade (first set the appropriate permissions on the pear file):

chmod 550 pear
./pear mage-setup

If the pear file was last saved from a Windows system you most likely will get an error like: ./pear: /bin/sh^M: bad interpreter: No such file or directory. That's because of the Miscrosoft-style line feeds, which sometimes causes issues on unix type servers. To fix it run the following command (perl must be installed on the server):

perl -pi -e 's/\r\n/\n/g' pear

The result of the above command will most likely be:
Channel "" is already initialized

Execute Magento upgrade:

./pear upgrade -f magento-core/Mage_All_Latest-stable

Output of the command will show the upgrated packages, something like:
upgrade ok: channel://

Next run these commands:

chmod 550 ./mage
./mage mage-setup .
* notice the dot after mage-setup command

Output (Magento connect 2.0 channel was added to the channels list):
Successfully added:


./mage sync

Output, something like:
Successfully added: community/Mage_Core_Modules-

To complete the upgrade to version 1.4.2 do the following:

  1. Empty var/cache
  2. Empty var/session
  3. Empty browser cache
  4. Visit your website to trigger the upgrade (the site will take some time to open for the first time, so don't close the page until the homepage has loaded)

If you see 500 Internal Server Error on your website you need to chown the site files to correct user:group (this usually happens when working on SSH with a root account):

chown -R your_user:your_group .
* notice the dot at the end

If the above command didn't fixed 500 Internal Server Error, some of your files might have wrong permissions. Fix it by setting 644 to all files:

find . -type f -print0 | xargs -0 chmod 644

If everything worked fine you should now have Magento version 1.4.2 (you can see the version in admin panel's footer). We can proceed now to upgrade to version

Page 2 - Upgrading to version

7 thoughts on “How to upgrade Magento version to through SSH command line

  1. Kaushal on

    Hi All, Me using magento version & would like to migrate to 1.7 the latest one. I followed the instructions but an error comes as follow :-

    # ./pear upgrade -f magento-core/Mage_All_Latest-stable
    SECURITY ERROR: package in channel "" retrieved another channel's name for download! ("")
    Cannot initialize 'channel://', invalid or missing package file
    Package "channel://" is not valid
    upgrade failed

    The first 2 commands worked well that is :-
    chmod -R 777 lib/PEAR
    ./pear mage-setup

    • Hello Kaushal,
      The article is only for so it may not work on older versions. However i can offer my services to help you to make the upgrade. I have your email in admin, so let me know if you would like to contact you directly to discuss more about it.

      • Akbar on

        Could you please advise of how to migrate from to 1.7 without losing frontend, backend and database.
        Can I just click to upgrade on hosting/cpanel under Softculious, where the original installer have a option to click to upgrade.
        What happens when I click to Upgrade. Does this upgrade straight away from 1.4 to 1.7 without much hassle.
        I have backed up the whole cpanel and database.
        Can you please advise.

        • Lucian on

          Hi Akbar,
          I don't think Softaculous is able to automatically upgrade magento (at least not without breaking it). But if you have a very recent backup you can give it a try, in the worst case you restore everything.

          Otherwise you should follow the above article. The key here is to update first from to 1.4.2 and then from 1.4.2 to

  2. Antoine on

    Thanks for the tutorial.
    I was trying to upgrade from on a test folder and after going through all steps successfully, when hitting the " ./mage mage-setup " I got this error from the terminal:

    Running initial setup...
    channel-add: Channel 'community' already exist!

    Any thoughts on what this error might be and how to prevent it next time?

    • nytros on

      Hi Paul,
      Yes, i can help you. I just sent you an email with the details to the email address you provided in your comment.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>