Posted in: Magento, SSH

Install Magento via SSH

There are many tutorials out there that show you how to install Magento using SSH, but in my experience, there is always something that is missing. Here’s a collection of what I’ve found to work. I am using the Magento Sample data on this installation as well. For those of you that aren’t needing the sample data, I will add this method to this post soon.

SSH into your site root where you want to install Magento. In this example we will be using /public_html/ as the site root.
Run the following commands from terminal: **CHANGE DBHOST DBUSER DBNAME to reflect your database information**
wget –content-disposition http://www.magentocommerce.com/downloads/assets/1.9.1.0/magento-1.9.1.0.tar.gz
wget http://www.magentocommerce.com/downloads/assets/1.9.0.0/magento-sample-data-1.9.0.0.tar.gz
tar xvf magento-1.9.1.0.tar.gz
tar xvf magento-sample-data-1.9.0.0.tar.gz
mv magento-sample-data-1.9.0.0/media/* magento/media/
mv magento-sample-data-1.9.0.0/magento_sample_data_for_1.9.0.0.sql magento/data.sql
mv magento/* magento/.htaccess .
mysql -h DBHOST -u DBUSER -p DBNAME < data.sql
**Enter database password at prompt
rm -rf *.sample magento/ magento-sample-data-1.9.0.0/
rm -rf magento-1.9.1.0.tar.gz magento-sample-data-1.9.0.0.tar.gz data.sql
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;

Install Magento.
You can now browse to your site and follow the web-based installation or you can use the Command Line Installer (CLI).
CLI Method:
Copy the following code into your preferred text editor and change the values to reflect your settings.

php-cli -f install.php -- \
--license_agreement_accepted "yes" \
--locale "en_US" \
--timezone "America/Phoenix" \
--default_currency "USD" \
--db_host "DB_HOST" \
--db_name "DB_NAME" \
--db_user "DB_USER" \
--db_pass "DB_PASS" \
--url "SITE_URL" \
--use_rewrites "yes" \
--use_secure "no" \
--secure_base_url "" \
--use_secure_admin "no" \
--admin_firstname "FIRST_NAME" \
--admin_lastname "LAST_NAME" \
--admin_email "EMAIL_ADDRESS" \
--admin_username "USERNAME" \
--admin_password "PASSWORD"

Then copy your edited version and paste it into your terminal prompt.
Once that’s finished run the following in terminal:
chmod 750 ./mage
./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
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;

That’s it. You should now have the latest version of Magento installed on your server.

Have your say