Installing and Upgrading Magento Using SSH – Part I

In this article I will cover how to install Magento latest version and how to upgrade Magento step-by-step from an old to brand new version using secure shell!

 

Using SSH is the easiest and fastest way to install Magento, especially when you’re trying to setup a store with sample data. Normally, that requires you to download about 45 MB worth of data and then re-upload it to your website. But if you have SSH access to your hosting environment, you can take advantage of the connection of the server to grab the necessary files fast and directly.

 

1. First you have to be sure, that your hosting server is compatible with Magento.

– For this, first read the Magento Requirements page carefully, and make sure your server meets those.
– You can test your server for compatibility by following these simple steps:

 

  1. Download the magento-check file to your computer and unzip it.
  2. Upload the extracted magento-check.php file to the Magento directory on your server
  3. In your browser navigate to this page: magento/magento-check.php

 

2.  You have to login to your hosting environment using SSH.

You have to confirm following things before using SSH.

  1. SSH Server: Should be installed and enabled on the remote server you wish to login to (99.99% it is pre-installed on your Linux server). For windows server, there are several SSH servers available at market. Leadings are – Free SSHd, OpenSSH, copSSH for Windows (a modified build of OpenSSH) etc.
  2. SSH Client: Once you have your SSH Server running, you will most likely need a SSH Client. If you are installing from Windows environment, PuTTY is a free and popular SSH Client application which can be used to make an SSH connection to your server. For all latest Linux distributions, SSH is installed by default and you can access it simply starting up Terminal.
  3. SSH Login: You need host name or IP address, username and password in order to login to the server via SSH. You can grab your SSH login credentials from your server administrator.

The real power of Secure Shell comes into play when public/private keys are used. Unlike password authentication, public key access is done by performing a one-time creation of a pair of very long binary numbers which are mathematically related. If your server control panel have SSH management tool then you can easily generate your authentication keys. And if not, it’s a lil bit lengthy process to done.

 

– Using SSH is very simple. But if you need further assistance refer to following link as I am not going to elaborate on using SSH here.

 

http://kb.mediatemple.net/questions/1595/Using+SSH+in+PuTTY+%28Windows%29#gs

 

3. Copy and paste these commands into the SSH command line

 

– Installing on root directory: The web root directory simply means what immediately comes up when you access your domain, compared to a sub-directory install, which is how Magento is setup by default.

Please note that you have to change magento-1.7.0.2.tar.gz with the latest Magento version available.

 

wget http://www.magentocommerce.com/downloads/assets/1.7.0.2/magento-1.7.0.2.tar.gz
tar -zxvf magento-1.7.0.2.tar.gz
mv magento/* magento/.htaccess .
chmod -R o+w media var
chmod o+w app/etc

 

Optionally delete the download file and empty directory from the extracted files:

rm -rf magento/ magento-1.7.0.2.tar.gz

 

– Installing on sub directory: For this install you only need to replace SUBDIRECTORY below with the name of the subdirectory that you want Magento installed in.

mkdir SUBDIRECTORY
cd SUBDIRECTORY

 

After these two lines, rests of the commands are same as above 1-6.

 

– Installing Magento with sample data: For this install replace DBHOST, DBNAME, DBUSER, and DBPASS with your database host, database name, username and password.

wget http://www.magentocommerce.com/downloads/assets/1.7.0.2/magento-1.7.0.2.tar.gz
wget http://www.magentocommerce.com/downloads/assets/1.6.1.0/magento-sample-data-1.6.1.0.tar.gz
tar -zxvf magento-1.7.0.2.tar.gz
tar -zxvf magento-sample-data-1.6.1.0.tar.gz
mv magento-sample-data-1.6.1.0/media/* magento/media/
mv magento-sample-data-1.6.1.0/magento_sample_data_for_1.6.1.0.sql magento/data.sql
mv magento/* magento/.htaccess .
chmod o+w var var/.htaccess app/etc
chmod -R o+w media
mysql -h DBHOST -u DBUSER -pDBPASS DBNAME < data.sql
./mage mage-setup .
rm -rf magento/ magento-sample-data-1.6.1.0/
rm -rf magento-1.7.0.2.tar.gz magento-sample-data-1.6.1.0.tar.gz data.sql
 

4. Run the Web-Based Installer to Finish the Installation.

Now simply follow through with the web-based installation process in your web browser.

And this is it. Your Magento site is up and running.

Troubleshooting

 

404 Error On Sample Products

If you get a 404 error when clicking on a product from the main page, you’ll need to login the backend of Magento and go to:

System -> Cache Management

In the Catalog section, click on the Refresh button for Catalog Rewrites.

This will also fix the URL structure for the categories and rest of the products.

Permissions not correct/insufficient

 

In case not all permissions are set correctly, you can run these commands. The code highlighter is stripping the off the end. Should be {} backslash;

 

find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;

 

which will give files the 644 and directories the 755 permissions respectively. While you can change the directories to 777, this should never be done. It is a big security risk.

 

Written by Masum