Installing Magento Via SSH

Last modified by matt1237 on Wed, August 22, 2012 19:05
Source|Old Revisions  

This is an old revision of the document!


This article will outline a few different approaches to installing the latest version of Magento using the command-line shell via SSH.

We will cover how to install Magento with and without sample data, and how to install Magento in a subdirectory or the web 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.

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.

Latest Stable Release

The latest stable version of Magento is 1.7.0.2 (26.6 MB)

http://www.magentocommerce.com/downloads/assets/1.7.0.2/magento-1.7.0.2.tar.gz

The latest stable version of Magento Downloader (not Magento itself!) is 1.7.0.0 (45.6 KB)

http://www.magentocommerce.com/downloads/assets/1.7.0.0/magento-downloader-1.7.0.0.tar.gz

(The downloader will install the latest stable release of Magento Commerce.)

Installing Magento With The Full Download

Installing Into The Website Document Root

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

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

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

Then simply follow through with the web-based installation process.

Installing Magento With The PEAR Downloader

Using the PEAR downloader is a convenient way to ensure that you install the latest version of Magento, as it provides a simple mechanism to install the latest stable version that is available. It is a small download and is updated less frequently than the full Magento package.

Installing Into The Website Document Root

  1. wget http://www.magentocommerce.com/downloads/assets/1.7.0.0/magento-downloader-1.7.0.0.tar.gz
  2. tar -zxvf magento-downloader-1.7.0.0.tar.gz
  3. rm -rf magento-downloader-1.7.0.0.tar.gz

Now load http://www.yourwebsite.com/downloader.php in your web browser.

Installing into a Subdirectory

For this install you only need to replace SUBDIRECTORY below (two times) with the name of the subdirectory that you want Magento installed in.

  1. mkdir SUBDIRECTORY
  2. cd SUBDIRECTORY
  3. wget http://www.magentocommerce.com/downloads/assets/1.7.0.0/magento-downloader-1.7.0.0.tar.gz
  4. tar -zxvf magento-downloader-1.7.0.0.tar.gz
  5. rm -rf magento-downloader-1.7.0.0.tar.gz

Now load http://www.yourwebsite.com/SUBDIRECTORY/downloader.php in your web browser.

Installing Magento With The PEAR Downloader & Sample Data

Installing Magento with sample data is useful if you want to familiarize yourself with Magento and see how categories and products are set up.

Installing into the Root Web Directory

This is almost the same as above, except you don’t need to know the directory name. You will only have to replace DBHOST, DBNAME, DBUSER, and DBPASS.

WARNING! Following code is not correct anymore! Please change!

  1. wget http://www.magentocommerce.com/downloads/assets/1.7.0.0/magento-downloader-1.7.0.0.tar.gz
  2. wget http://www.magentocommerce.com/downloads/assets/1.6.1.0/magento-sample-data-1.6.1.0.tar.gz
  3. tar -zxvf magento-downloader-1.7.0.0.tar.gz
  4. tar -zxvf magento-sample-data-1.6.1.0.tar.gz
  5. mv magento-sample-data-1.6.1.0/media/* magento/media/
  6. mv magento-sample-data-1.6.1.0/magento_sample_data_for_1.6.1.0.sql magento/data.sql
  7. mv magento/* magento/.htaccess .
  8. chmod -R o+w media
  9. mysql -h DBHOST -u DBUSER -pDBPASS DBNAME < data.sql
  10. ./pear mage-setup .
  11. ./pear install magento-core/Mage_All_Latest-stable
  12. touch var/.htaccess | mkdir app/etc
  13. chmod o+w var var/.htaccess app/etc
  14. rm -rf downloader/pearlib/cache/* downloader/pearlib/download/*
  15. rm -rf magento/ magento-sample-data-1.6.1.0/
  16. rm -rf magento-downloader-1.7.0.0.tar.gz magento-sample-data-1.6.1.0.tar.gz data.sql

Installing into a Subdirectory

For this install, there are five things you will need to know before you copy and paste the SSH commands and run the install.

  1. Subdirectory name where Magento will be installed
  2. The database host name, localhost works for most
  3. The name of the database that Magento will use
  4. The username that has privileges to use the database
  5. The password for that 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 the word SUBDIRECTORY below (two times) to the name of the subdirectory where you want Magento installed, and DBHOST, DBNAME, DBUSER, and DBPASS.

  1. mkdir SUBDIRECTORY
  2. cd SUBDIRECTORY
  3. wget http://www.magentocommerce.com/downloads/assets/1.7.0.0/magento-downloader-1.7.0.0.tar.gz
  4. wget http://www.magentocommerce.com/downloads/assets/1.6.1.0/magento-sample-data-1.6.1.0.tar.gz
  5. tar -zxvf magento-downloader-1.7.0.0.tar.gz
  6. tar -zxvf magento-sample-data-1.6.1.0.tar.gz
  7. mv magento-sample-data-1.6.1.0/media/* magento/media/
  8. mv magento-sample-data-1.6.1.0/magento_sample_data_for_1.6.1.0.sql magento/data.sql
  9. mv magento/* magento/.htaccess .
  10. chmod -R o+w media
  11. mysql -h DBHOST -u DBUSER -pDBPASS DBNAME < data.sql
  12. ./pear mage-setup .
  13. ./pear install magento-core/Mage_All_Latest-stable
  14. touch var/.htaccess | mkdir app/etc
  15. chmod o+w var var/.htaccess app/etc
  16. rm -rf downloader/pearlib/cache/* downloader/pearlib/download/*
  17. rm -rf magento/ magento-sample-data-1.6.1.0/
  18. rm -rf magento-downloader-1.7.0.0.tar.gz magento-sample-data-1.6.1.0.tar.gz data.sql

Running the Web-Based Installer to Finish the Installation

After you have installed Magento via SSH, you can proceed through the web-based installer. You’ll use the same database details in that as well.

You can actually bypass the web-based installer and use the Command Line Interface (CLI) instead.

Alternatively, there’s an SSH script you can use that automates both the main steps of this article and the CLI installer.

Troubleshooting

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;

  1. find . -type f -exec chmod 644 {} ;
  2. 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.

URL Not Accessible

As mentioned in this thread, if you receive an error message that says URL not accessible, you’ll want to remove the following lines:

  1. ./pear mage-setup .
  2. ./pear install magento-core/Mage_All_Latest-stable

After you’ve gone through the web-based installer, then you can run those two commands to upgrade Magento to the lastest version, or use Magento Connect.

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.

Download An Archived Magento Connect Extension

If for some reason you need to download a Magento Connect extension archive from command line, use the following :

  1. wget http://connect.magentocommerce.com/TYPE/get/EXTENSION_NAME-X.X.X.tgz

TYPE must be replaced with real extension type(usually core or community), EXTENSION_NAME with real(machine readable) extension name and X.X.X must be replaced with the real version number. To retrieve real TYPE and the real machine readable EXTENSION_NAME simply look at it’s extension key and take into a count it’s format magento-TYPE/EXTENSION_NAME.

For example:

  1. wget http://connect.magentocommerce.com/core/get/Interface_Frontend_Default_Blank-1.4.1.1.tgz

Other example:

  1. wget http://connect.magentocommerce.com/community/get/Yoast_Blank_Seo_Theme-1.4.1.tgz

Guess it’s would be nice to have “Releases” tab with links and release notes at extension page? :-D

Use PEAR to download and install Magento Connect Extension

If you also need some extension to be installed from command line, then use following:

  1. ./pear install EXTENSION_KEY

And refresh the cache (System → Cache Management)

This way extension will be properly deployed(i.e. app, frontend template/layout, etc. will be copied to it’s places) and activated.

If you simply need to download archived extension package for some reason, use following:

  1. ./pear download EXTENSION_KEY

NOTE: in order to have properly functioning ./pear command, your magento instance must be installed following one of the steps explained at this page.

Other Pages You May Find Useful When Upgrading to 1.6 http://www.magentocommerce.com/boards/viewthread/248230/ http://www.magentocommerce.com/wiki/groups/227/installing_magento_via_shell_ssh http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/magento_1.5_to_1.6_upgrade http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/manual_upgrade_using_fresh_install_and_original_database#process




 

Magento 2 GitHub Repository

Magento Job Board - Some sort of tag line goes here

Latest Posts| View all Jobs