Installing Magento Via SSH
This article will outline a couple different ways to install the latest version of Magento via shell, and will take advantage of the PEAR downloader so you can use Magento Connect to upgrade Magento or add extensions.
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.
Alpha Release |
You can download and install the alpha release and use the instructions below by using the following file:
http://www.magentocommerce.com/downloads/assets/1.4.0.0/magento-1.4.0.0-alpha3.tar.gz
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.
- mkdir magento
- cd magento
- wget http://www.magentocommerce.com/downloads/assets/1.3.2.4/magento-1.3.2.4.tar.gz
- wget http://www.magentocommerce.com/downloads/assets/1.2.0/magento-sample-data-1.2.0.tar.gz
- tar -zxvf magento-1.3.2.4.tar.gz
- tar -zxvf magento-sample-data-1.2.0.tar.gz
- mv magento-sample-data-1.2.0/media/* magento/media/
- mv magento-sample-data-1.2.0/magento_sample_data_for_1.2.0.sql magento/data.sql
- mv magento/* magento/.htaccess .
- chmod o+w var var/.htaccess app/etc
- chmod -R o+w media
- mysql -h localhost -u root -p1324 magento_db < data.sql
- ./pear mage-setup .
- ./pear install magento-core/Mage_All_Latest-stable
- rm -rf downloader/pearlib/cache/* downloader/pearlib/download/*
- rm -rf magento/ magento-sample-data-1.2.0/
- rm -rf magento-1.3.2.4.tar.gz magento-sample-data-1.2.0.tar.gz data.sql
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.
- Subdirectory name where Magento will be installed
- The database host name, localhost works for most
- The name of the database that Magento will use
- The username that has privileges to use the database
- 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.
- mkdir SUBDIRECTORY
- cd SUBDIRECTORY
- wget http://www.magentocommerce.com/downloads/assets/1.3.2.4/magento-1.3.2.4.tar.gz
- wget http://www.magentocommerce.com/downloads/assets/1.2.0/magento-sample-data-1.2.0.tar.gz
- tar -zxvf magento-1.3.2.4.tar.gz
- tar -zxvf magento-sample-data-1.2.0.tar.gz
- mv magento-sample-data-1.2.0/media/* magento/media/
- mv magento-sample-data-1.2.0/magento_sample_data_for_1.2.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
- ./pear mage-setup .
- ./pear install magento-core/Mage_All_Latest-stable
- rm -rf downloader/pearlib/cache/* downloader/pearlib/download/*
- rm -rf magento/ magento-sample-data-1.2.0/
- rm -rf magento-1.3.2.4.tar.gz magento-sample-data-1.2.0.tar.gz data.sql
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.
- wget http://www.magentocommerce.com/downloads/assets/1.3.2.4/magento-1.3.2.4.tar.gz
- wget http://www.magentocommerce.com/downloads/assets/1.2.0/magento-sample-data-1.2.0.tar.gz
- tar -zxvf magento-1.3.2.4.tar.gz
- tar -zxvf magento-sample-data-1.2.0.tar.gz
- mv magento-sample-data-1.2.0/media/* magento/media/
- mv magento-sample-data-1.2.0/magento_sample_data_for_1.2.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
- ./pear mage-setup .
- ./pear install magento-core/Mage_All_Latest-stable
- rm -rf downloader/pearlib/cache/* downloader/pearlib/download/*
- rm -rf magento/ magento-sample-data-1.2.0/
- rm -rf magento-1.3.2.4.tar.gz magento-sample-data-1.2.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.
=
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.
- mkdir SUBDIRECTORY
- cd SUBDIRECTORY
- wget http://www.magentocommerce.com/downloads/assets/1.3.2.4/magento-1.3.2.4.tar.gz
- tar -zxvf magento-1.3.2.4.tar.gz
- mv magento/* magento/.htaccess .
- chmod o+w var var/.htaccess app/etc
- chmod -R o+w media
- ./pear mage-setup .
- ./pear install magento-core/Mage_All_Latest-stable
- rm -rf downloader/pearlib/cache/* downloader/pearlib/download/*
- rm -rf magento/ magento-1.3.2.4.tar.gz
Root Web Directory |
This is the easiest to install, because there’s nothing to change.
- wget http://www.magentocommerce.com/downloads/assets/1.3.2.4/magento-1.3.2.4.tar.gz
- tar -zxvf magento-1.3.2.4.tar.gz
- mv magento/* magento/.htaccess .
- chmod o+w var var/.htaccess app/etc
- chmod -R o+w media
- ./pear mage-setup .
- ./pear install magento-core/Mage_All_Latest-stable
- rm -rf downloader/pearlib/cache/* downloader/pearlib/download/*
- rm -rf magento/ magento-1.3.2.4.tar.gz
Web-Based Installer |
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.
Notes |
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:
- ./pear mage-setup .
- ./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 :
- wget http://connect.magentocommerce.com/community/get/EXTENSION_KEY-X.X.X.tgz
If the extension is from community channel and replacing EXTENSION_KEY with the real extension key and X.X.X with the real version number.





