Magento upgrade to 1.5.x or 1.6.x VIA SSH

1,962 人次阅读
没有评论

共计 4803 个字符,预计需要花费 13 分钟才能阅读完成。

As many magento users will know, Magento is no fun to work with– mainly due to poor community support (the developers help paying customers; i.e. Magento Enterprise … Only payed support there… Great for business but bad for the average or beginning user…)

Anyhow…

So here’s how we do it.

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)

    1. I usually create a subdomain on another domain and put all the files there.
    2. Create a new database for this sub-domain.
    3. Make a backup of the current database in SSH via:
      $ mysqldump -u user -p DB_NAME > DB-NAME.sql
    4. Dump the backup you just made into your new database
      $ mysql -u user -p DB_NAME < DB-NAME.sql
    5. Change the database settings to point to new database
      $ vi app/etc/local.xml
    6. 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
    7. REMEMBER to update steps 5-6 after the upgrade is done and upgraded files and database are transferred to the production environment.

Upgrade Magento from 1.4.x to 1.5.x

1. download the latest version of Magento

$ wget http://www.magentocommerce.com/downloads/assets/1.5.1.0/magento-1.5.1.0.tar.gz
(magento 1.6) $ wget http://www.magentocommerce.com/downloads/assets/1.6.0.0/magento-1.6.0.0.tar.gz
$ tar xvfz magento-1.5.1.0.tar.gz
(magento 1.6) $ tar xvfz magento-1.6.0.0.tar.gz

2. Disallow access to your site if doing the upgrade on a production environment (this is why you should do this on a test environment)

$ mv .htaccess .htaccess-bkp
$ cp magento/.htaccess .
$ 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

3. Flush all caches

$ rm -rf var/cache/*
$ rm -rf downloader/pearlib/cache/* downloader/pearlib/download/*

4. Remove the ‘downloader’ and ‘app/design/frontend/base’ directory

$ rm -rf downloader
$ rm -rf app/design/frontend/base

This is the safest bet so mage/pear doesn’t upgrade the wrong installation; trust me this happened to me a couple of times, EVEN after doing ‘ mage-setup’.

As for the ‘base’ directory, we remove that because deprecated files exist in there that may cause problems. E.g. One page checkout would not work for anon users, but would work for registered users–and this happened even when all the files were overwritten with magento 1.5.1; meaning magento was picking up deperectated files.

5. Copy ‘downloader’ and ‘app/design/frontend/base’ folder from magento-1.5.1.0

$ cp -a magento/downloader .
$ cp -a magento/app/design/frontend/base/ app/design/frontend/

6. Install/get ‘mage’.

$ cp magento/mage .
$ chmod 550 ./mage

or
$ chmod 750 ./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.

7. Do the upgrade

$ ./mage mage-setup .
$ ./mage sync --force
$ ./mage install http://connect20.magentocommerce.com/community Mage_All_Latest --force
$ rm -rf var/cache/*
$ rm -rf downloader/pearlib/cache/* downloader/pearlib/download/*
$ chmod 755 mage
$ ./mage upgrade-all --force

8. Visit the home page of your upgraded site. This will trigger the magento upgrade process.

9. Login to the /admin section of your site and mage sure the version number reflects the version you just upgraded to.

10. Change back your .htaccess to original value

$ cp .htaccess-new .htaccess

11. Set the proper file permissions

$ find . -type f -exec chmod 644 {} \;
$ find . -type d -exec chmod 777 {} \;
$ chmod -R 777 download
$ chmod 550 mage
$ chmod o+w var var/.htaccess app/etc
$ chmod -R o+w media

 

11. You’ll probably want to use a file comparison program to see the difference in template files

  • download the latest version from magento connect if possible
  • if not possible and you made your own template, then the best thing to do is to DELETE all the unecessary custom template files from your custom template directory, and only keep the crucial ones.
  • Following use something like Beyond Compare and file compare between the /base/default
    app/design/frontend/base/default
    and
    /app/design/frontend/default/CUSTOM

 

Troubleshooting

Now…

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.

The fix:

$ 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):

Blah… the database upgrade didn’t work…

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)

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…

Bonus:
Install Google Base (shopping) vis SSH

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

正文完
 0