Upgrading Magento from an old version is a headache. Due to poor community support, Magento is no fun to work with. Good for business, bad for average or beginner users.
It is certainly not a good idea to upgrade Magento from 1.3 to 1.7 directly as there might be some extensions that are compatible with 1.3 and not with 1.7. Try to upgrade from 1.3 to 1.5 and then upgrade from 1.5 to 1.6 and finally 1.6 to 1.7. Safest bet!
Anyhow, here’s how we do it!
1. First you have to login to your hosting environment using SSH.
Refer to Part-I of this article for details.
2. Make a Backup!
You can skip this step all together, however, please make a backup of everything prior to beginning the upgrade.
Create a test environment somewhere on your server (preferably away from your production installation).
I usually create a subdomain on another domain and put all the files there.
Create a new database for this sub-domain.
Make a backup of the current database in SSH via:
$ mysqldump -u user -p DB_NAME > DB-NAME.sql
Or you can make backup from phpmyadmin. While making backup from phpmyadmin check ‘Disable check foreign key checks’option.
Dump the backup you just made into your new database
$ mysql -u user -p DB_NAME < DB-NAME.sql
Or you can do the same from phpmyadmin.
Change the database settings to point to new database
$ vi app/etc/local.xml
Change your magento URLs:
In phpmyadmin go to table ‘core_config_data’ and change ‘web/unsecure/base_url’ and ‘web/secure/base_url’ to new location.
REMEMBER to update steps 5-6 after the upgrade is done and upgraded files and database are transferred to the production environment.
3. Download the latest version of Magento.
wget
http://www.magentocommerce.com/downloads/assets/1.7.0.1/magento-1.7.0.1.tar.gz
tar xvfz magento-1.5.1.0.tar.gz
4. Disallow access to your site if doing the upgrade on a production environment (Skip this step if performing on test environemnt)
1.
mv .htaccess .htaccess-bkp
2.
cp magento/.htaccess .
3. cp .htaccess .htaccess-new
In your new .htaccess change the Order Allow to (at the bottom of file):
#Order allow,deny
#Allow from all
Order deny,allow
Deny from all
Allow from YOUR IP ADDRESS
Also, up the memory usage (especially if your database backup is over 500MB–hopefully you’re running magento on a dedicated server.)
php_value memory_limit 1024M
php_value max_execution_time 45000
5. Flush all caches
rm -rf var/cache/*
rm -rf downloader/pearlib/cache/* downloader/pearlib/download/*
6. Remove the ‘downloader’ and ‘app/design/frontend/base’ directory
rm -rf downloader
rm -rf app/design/frontend/base
7. Copy ‘downloader’ and ‘app/design/frontend/base’ folder from magento-1.7.0.1
cp -a magento/downloader .
cp -a magento/app/design/frontend/base/ app/design/frontend/
8. Install/get ‘mage’.
cp magento/mage .
chmod 755 ./mage
We do this because the ‘pear’ method doesn’t work anymore–it only does an upgrade up to magento 1.4.2; it won’t work upgrading any higher than that.
9. Do the upgrade
** IMPORTANT: Make sure your Magento Connect Manager ‘Preferred State‘ is set to ‘Stable‘ **
It’s located here: https://www.YOURWEBSITE.com/downloader/index.php?A=settings
./mage mage-setup .
./mage sync --force
./mage install
http://connect20.magentocommerce.com/communityMage_All_Latest --force
rm -rf var/cache/* var/session/*
rm -rf downloader/pearlib/cache/* downloader/pearlib/download/*
chmod 755 mage
php shell/indexer.php reindexall
./mage upgrade-all --force
yes | cp -Rf magento/* . #this copies over all the magento files you extracted over your current installation
10. Visit the home page of your upgraded site. This will trigger the magento upgrade process.
This can take anywhere from 2-30minutes, so be patient. You’ll also likely get a browser error before the upgrade is done-don’t worry about it, it’s normal, and keep waiting…
Do the following and watch mysql process until it stops using up high cpu usage–once it does, you’ll know the database upgrade is done.
1. top
11. Login to the /admin section of your site and make sure the version number reflects the version you just upgraded to.
12. Change back your .htaccess to original value (if step-4 is performed)
cp .htaccess-new .htaccess
13. Set the proper file permissions
1.
find . -type f -exec chmod 644 {} \;
2. find . -type d -exec chmod 755 {} \;
3. chmod o+w var var/.htaccess app/etc
4. chmod -R o+w media
14. Fix magento URLs
php shell/indexer.php reindexall
Troubleshooting
If something went wrong (and it probably did) you have several options.
If a newer version 1.6.x-RC is showing then mage installer grabbed the release candidate stuff instead.
yes | cp -Rf magento/* .
This will copy the proper version of magento overwriting your current installation
The site just hangs after upgrade (keeps loading for minutes on end):
Be patient, use top
in SSH and wait for mysql high CPU usage to go down
PHP Fatal error: Call to a member function toHtml()
edit app/design/frontend/default/YOURTHEME/layout/page.xml
or edit app/design/frontend/default/default/layout/page.xml
Change from
<block type="core/profiler" output="toHtml"/>
to:
<block type="core/profiler" output="toHtml" name="core_profiler"/>
Fresh start: in case something went terribly wrong
Go into phpmyadmin and drop all the tables so your database is empty (you’ll get errors in phpmyadmin about foreign keys; that’s normal, just repeat till all tables are gone).I prefer this over the SSH method, cause it’s too easy to drop the wrong database by accident)
However, there’s a good chance phpMyAdmin may run out of resources when doing this, so you may want to checkout this post instead: Drop all tables in MySQL via SSH
Now re-dump your database backup:
mysql -u user -p DB_NAME < DB-NAME.sql
and copy over a fresh version of magento over your current install
yes | cp -Rf magento/* .
rm -rf var/cache/*
rm -rf downloader/pearlib/cache/* downloader/pearlib/download/*
Visit your site again…
Written by Masum
Comments
3 responses to “Installing and Upgrading Magento Using SSH : Part II”
I really appreciate your help, it is very useful for me,you will get good grades!
Pretty nice post. I just stumbled upon your blog and wanted to say that I’ve truly enjoyed browsing your blog posts. In any case I’ll be subscribing to your rss feed and I hope you write again soon!
I have read the Both upgrading system. I think i Can do it easily now.