• Applies To: All Services
  • Difficulty: Medium
  • Time Needed: 10 minutes
  • Tools Needed: SSH Client
  • Reading Time: 9 minutes

This article will outline a couple different ways to install the latest version of Magento—with or without sample data—using the Command Line Interface (CLI).

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. With SSH, we can take advantage of the connection of the server to grab the necessary files.

With Sample Data

This is typically how Magento is installed, especially if you want to familiarize yourself with Magento and see how they setup categories and products.

For this install, there are four things you will need to know before you copy and paste the SSH commands:

  1. The database host name, localhost works for most
  2. The name of the database that Magento will use
  3. The username that has privileges to use the database
  4. The password for the database user

Once you have that information, you'll want to copy and paste the commands for the type of install you want and replace what's there with the information from above. It's best to copy this into notepad or something similar.

So that means you'll be replacing DBHOST, DBNAME, DBUSER, and DBPASS with the appropriate information.

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 xvf magento-1.7.0.2.tar.gz
tar xvf 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 .
mysql -h DBHOST -u DBUSER -pDBPASS DBNAME < data.sql
rm -rf *.sample 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

Without Sample Data

You'll choose this method to install Magento when you're ready to start developing your store and adding your own products.

For this install there's nothing that needs to be replaced. You can just copy and paste the the SSH commands:

wget http://www.magentocommerce.com/downloads/assets/1.7.0.2/magento-1.7.0.2.tar.gz
tar xvf magento-1.7.0.2.tar.gz
mv magento/* magento/.htaccess .
rm -rf *.sample magento/ magento-1.7.0.2.tar.gz

Installing Magento

Wait, I thought we already just installed Magento? Well, not really. The above commands just prepared everything so we can actually install Magento using the command line or web-based installer.

Command Line Installer

Please follow the instructions in this article, and return back here once you've finished.

Web-Based Installer

If you want to use the web-based installer, just point your browser to the address where Magento's files are located and follow the instructions. Return back here once you've finished.

Automated SSH Installer

Alternatively, there's a Bash script you can use that automates both the main steps of this article, the command line installer, and the commands below.

Finishing Up

Once you've gone through the command line or web-based installer, run the following SSH commands:

./mage mage-setup .
./mage config-set preferred_state stable
./mage install http://connect20.magentocommerce.com/community Mage_All_Latest --force
php -f shell/indexer.php reindexall

This will install the core Magento extensions so they'll show up in Magento Connect, which will allow you to install extensions and easily upgrade Magento in the future.