Automated Bash Script Installer
The following SSH script will automate the process of installing Magento, with or without sample data. It will walk you through everything, and the only thing you need to setup first is the database and assign a user to the database.
You will need SSH access to use this. SSH is similar to FTP, in that it requires software that you'll need to download in order to connect to your site. If you don't have an SSH client, you can download PuTTY for free.
Once you connect to your site via SSH, simply go to the directory where you want to install Magento.
By default, when you connect to your site you're placed in your home directory. Files and directories in here are usually not accessible from a browser, so you will need to change to a public HTML directory.
For cPanel users, you would simply type the following to get to your root web directory:
cd public_html/
So if you wanted Magento to be the first thing that came up when a visitor went to your site, you would stay in this directory.
If you wanted Magento installed in a subdirectory, you would need to create it first (assuming it didn't exist):
mkdir store/
And then change into that directory:
cd store/
Once you're in the directory where you want Magento installed, you'll need to copy and paste the following in to a file and set the permissions on it.
To create the file, type the following:
vi install
Hit the I key to insert data. Copy the following code and paste it in your SSH window, either by right-clicking or hitting Shift + Insert:
#!/bin/bash
clear
stty erase '^?'
echo -n "Database Name: "
read dbname
echo -n "Database User: "
read dbuser
echo -n "Database Password: "
read dbpass
echo -n "Admin Password: "
read adminpass
echo -n "Store URL (with trailing slash): "
read url
echo -n "Include Sample Data? (y/n) "
read sample
if [ "$sample" = "y" ]; then
echo
echo "Now installing Magento with sample data..."
echo
echo "Downloading packages..."
echo
wget http://www.magentocommerce.com/downloads/assets/1.6.0.0/magento-1.6.0.0.tar.gz
wget http://www.magentocommerce.com/downloads/assets/1.2.0/magento-sample-data-1.2.0.tar.gz
echo
echo "Extracting data..."
echo
tar -zxvf magento-1.6.0.0.tar.gz
tar -zxvf magento-sample-data-1.2.0.tar.gz
echo
echo "Moving files..."
echo
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 .
echo
echo "Setting permissions..."
echo
chmod 550 mage
echo
echo "Importing sample products..."
echo
mysql -h localhost -u $dbuser -p$dbpass $dbname < data.sql
echo
echo "Initializing PEAR registry..."
echo
./mage mage-setup .
echo
echo "Cleaning up files..."
echo
rm -rf magento/ magento-sample-data-1.2.0/
rm -rf magento-1.6.0.0.tar.gz magento-sample-data-1.2.0.tar.gz
rm -rf index.php.sample .htaccess.sample php.ini.sample data.sql *.txt
echo
echo "Installing Magento..."
echo
php-cli -f install.php -- \
--license_agreement_accepted "yes" \
--locale "en_US" \
--timezone "America/Los_Angeles" \
--default_currency "USD" \
--db_host "localhost" \
--db_name "$dbname" \
--db_user "$dbuser" \
--db_pass "$dbpass" \
--url "$url" \
--use_rewrites "yes" \
--use_secure "no" \
--secure_base_url "" \
--use_secure_admin "no" \
--admin_firstname "Store" \
--admin_lastname "Owner" \
--admin_email "email@address.com" \
--admin_username "admin" \
--admin_password "$adminpass"
echo
echo "Finished installing the latest stable version of Magento With Sample Data"
echo
echo "+=================================================+"
echo "| MAGENTO LINKS"
echo "+=================================================+"
echo "|"
echo "| Store: $url"
echo "| Admin: ${url}admin/"
echo "|"
echo "+=================================================+"
echo "| ADMIN ACCOUNT"
echo "+=================================================+"
echo "|"
echo "| Username: admin"
echo "| Password: $adminpass"
echo "|"
echo "+=================================================+"
echo "| ENCRYPTION KEY"
echo "+=================================================+"
echo "|"
echo "| PASTE-ENCRYPTION-KEY-HERE"
echo "|"
echo "+=================================================+"
echo "| DATABASE INFO"
echo "+=================================================+"
echo "|"
echo "| Database: $dbname"
echo "| Username: $dbuser"
echo "| Password: $dbpass"
echo "|"
echo "+=================================================+"
exit
else
echo "Now installing Magento without sample data..."
echo
echo "Downloading packages..."
echo
wget http://www.magentocommerce.com/downloads/assets/1.6.0.0/magento-1.6.0.0.tar.gz
echo
echo "Extracting data..."
echo
tar -zxvf magento-1.6.0.0.tar.gz
echo
echo "Moving files..."
echo
mv magento/* magento/.htaccess .
echo
echo "Setting permissions..."
echo
chmod 550 mage
echo
echo "Initializing PEAR registry..."
echo
./mage mage-setup .
echo
echo "Cleaning up files..."
echo
rm -rf magento/ magento-1.6.0.0.tar.gz
rm -rf index.php.sample .htaccess.sample php.ini.sample *.txt
echo
echo "Installing Magento..."
echo
php-cli -f install.php -- \
--license_agreement_accepted "yes" \
--locale "en_US" \
--timezone "America/Los_Angeles" \
--default_currency "USD" \
--db_host "localhost" \
--db_name "$dbname" \
--db_user "$dbuser" \
--db_pass "$dbpass" \
--url "$url" \
--use_rewrites "yes" \
--use_secure "no" \
--secure_base_url "" \
--use_secure_admin "no" \
--admin_firstname "Store" \
--admin_lastname "Owner" \
--admin_email "email@address.com" \
--admin_username "admin" \
--admin_password "$adminpass"
echo
echo "Finished installing the latest stable version of Magento Without Sample Data"
echo
echo "+=================================================+"
echo "| MAGENTO LINKS"
echo "+=================================================+"
echo "|"
echo "| Store: $url"
echo "| Admin: ${url}admin/"
echo "|"
echo "+=================================================+"
echo "| ADMIN ACCOUNT"
echo "+=================================================+"
echo "|"
echo "| Username: admin"
echo "| Password: $adminpass"
echo "|"
echo "+=================================================+"
echo "| ENCRYPTION KEY"
echo "+=================================================+"
echo "|"
echo "| PASTE-ENCRYPTION-KEY-HERE"
echo "|"
echo "+=================================================+"
echo "| DATABASE INFO"
echo "+=================================================+"
echo "|"
echo "| Database: $dbname"
echo "| Username: $dbuser"
echo "| Password: $dbpass"
echo "|"
echo "+=================================================+"
exit
fi
Hit the Esc key to exit out of insert mode.
Type the following to save the file and exit back to the prompt:
:x
Hit the Enter key after you've typed that in.
Now set the permissions:
chmod +x install
Password
Please make sure your database and admin passwords only contain alphanumeric characters! Also, the admin password must be at least 8 characters in length, and contain at least 1 number.
Next, run the installation script:
./install
When you're done, delete the installer script:
rm -f install
Related Articles
Sorry, no related entries exist for this article.