How to upgrade Magento version 1.4.1.1 to 1.7.0.2 through SSH command line

This tutorial will explain how to upgrade and old magento version 1.4.1.1 to latest version (1.7.0.2 at the time of writing). Since Magento database structure has major changes from version 1.4.1.1 to 1.4.2 the best approach would be to first upgrade to version 1.4.2 and then directly to 1.7.0.2. 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 1.4.1.1 to 1.4.2. According to some board discutions from stackoverflow.com, you should substitute the file downloader/pearlib/php/Archive/Tar.php with the patched version available here: Tar.zip

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 "connect.magentocommerce.com/community" 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://connect.magentocommerce.com/core/Mage_All_Latest-1.4.2.1

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: http://connect20.magentocommerce.com/community

Next:

./mage sync

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

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 1.7.0.2:

Page 2 - Upgrading to version 1.7.0.2

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

  1. Kaushal on

    Hi All, Me using magento version 1.3.2.3 & 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 "connect.magentocommerce.com/core" retrieved another channel's name for download! ("pear.php.net")
    Cannot initialize 'channel://connect.magentocommerce.com/core/Mage_All_Latest-stable', invalid or missing package file
    Package "channel://connect.magentocommerce.com/core/Mage_All_Latest-stable" 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 1.4.1.1 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 1.4.1.1 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 1.4.1.1 to 1.4.2 and then from 1.4.2 to 1.7.0.2

  2. Antoine on

    Hi
    Thanks for the tutorial.
    I was trying to upgrade from 1.4.1.1 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...
    Success
    Success
    Error:
    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>