Skip to content

Instantly share code, notes, and snippets.

@shoaibi
Created June 25, 2015 15:49
Show Gist options
  • Select an option

  • Save shoaibi/c900199faa49010f2c0b to your computer and use it in GitHub Desktop.

Select an option

Save shoaibi/c900199faa49010f2c0b to your computer and use it in GitHub Desktop.
Download and install magento
#!/bin/bash
clear
stty erase '^?'
installSampleData=1
installExtensions=0
downloader="aria2c"
baseDownloadUrl="http://www.magentocommerce.com/downloads/assets"
magentoVersion="1.9.0.0"
magentoName="magento-${magentoVersion}"
magentoSampleName="magento-sample-data-$magentoVersion"
docRoot="/srv/http"
installDir="magento"
downloadsDir="/home/shoaibi/Downloads"
databaseUser="magento"
databasePassword="magento"
databaseName="magento"
databaseHost="localhost"
magentoUrl="http://localhost/magento"
adminUserName="magento"
adminPassword="magento123"
adminFirstName="Magento"
adminLastName="Admin"
adminEmail="shoaibi+magento+local@domain.com"
licenseAgreementAccepted="yes"
locale="en_US"
timeZone="Asia/Karachi"
defaultCurrency="USD"
useRewrites="no" # yes
useSecure="no"
secureBaseUrl=""
useSecureAdmin="no"
sessionSave="files" #"db" # files
if [ ! -f "${downloadsDir}/${magentoName}.tar.bz2" ]; then
echo "Downloading Magento"
cd "${downloadsDir}"
"$downloader" "${baseDownloadUrl}/${magentoVersion}/${magentoName}.tar.bz2"
fi
if [ $installSampleData -eq 1 -a ! -f "${downloadsDir}/${magentoSampleName}.tar.bz2" ]; then
echo "Downloading Magento Sample Data"
cd "${downloadsDir}"
"$downloader" "${baseDownloadUrl}/${magentoVersion}/${magentoSampleName}.tar.bz2"
fi
cd "$docRoot"
echo "Getting rid of existing magento install"
rm -rf "$installDir"
echo "Dropping all existing tables"
drop-all-database-tables "${databaseName}"
echo "Extracting Magento"
tar -xjf "${downloadsDir}/${magentoName}.tar.bz2"
if [ $installSampleData -eq 1 ]; then
echo "Extracting Magento Sample Data"
tar -xjf "${downloadsDir}/${magentoSampleName}.tar.bz2"
echo "Copying Media from Magento Sample to Magento"
\cp -aruTf "${magentoSampleName}"/media "$installDir"/
echo "Installing Sample Data"
mysql -h "${databaseHost}" -u"$databaseUser" -p"$databasePassword" "$databaseName" < "${magentoSampleName}"/magento_sample_data_for_"${magentoVersion}".sql
fi
cd "$installDir"
echo "Setting media and var permissions"
chmod -R o+w media var
echo "Setting mage permissions"
chmod +x mage
echo "Setting var/.htaccess and app/etc permissions"
chmod o+w var var/.htaccess app/etc
if [ $installExtensions -eq 1 ]; then
echo "Initializing PEAR registry"
./mage mage-setup .
./mage config-set preferred_state stable
echo "Installing core extensions"
./mage install http://connect20.magentocommerce.com/community Mage_All_Latest --force
echo "Refreshing indexes..."
php -f shell/indexer.php reindexall
fi
echo "Running install script"
php -f install.php -- \
--license_agreement_accepted "${licenseAgreementAccepted}" \
--locale "${locale}" \
--timezone "${timeZone}" \
--default_currency "${defaultCurrency}" \
--db_host "${databaseHost}" \
--db_name "${databaseName}" \
--db_user "${databaseUser}" \
--db_pass "${databasePassword}" \
--url "${magentoUrl}" \
--use_rewrites "${useRewrites}" \
--use_secure "${useSecure}" \
--secure_base_url "${secureBaseUrl}" \
--use_secure_admin "${useSecureAdmin}" \
--admin_firstname "${adminFirstName}" \
--admin_lastname "${adminLastName}" \
--admin_email "${adminEmail}" \
--admin_username "${adminUserName}" \
--admin_password "${adminPassword}" \
--session_save "${sessionSave}" \
--enable_charts
cd "$docRoot"
echo "Removing Magento Sample extration and sample database"
rm -rf "${magentoSampleName}" "${installDir}"/data.sql
echo "Restarting all servers"
restart-web-related-servers 1 1
echo "+=================================================+"
echo "| MAGENTO LINKS"
echo "+=================================================+"
echo "|"
echo "| Store: ${magentoUrl}/index.php"
echo "| Admin: ${magentoUrl}/index.php/admin/"
echo "|"
echo "+=================================================+"
echo "| ADMIN ACCOUNT"
echo "+=================================================+"
echo "|"
echo "| Username: ${adminUserName}"
echo "| Password: ${adminPassword}"
echo "|"
echo "+=================================================+"
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment