Skip to content

Instantly share code, notes, and snippets.

@shinesoftware
Last active November 9, 2020 08:41
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save shinesoftware/db05b12013e492a6dfb6c92648a4d953 to your computer and use it in GitHub Desktop.
Save shinesoftware/db05b12013e492a6dfb6c92648a4d953 to your computer and use it in GitHub Desktop.
Magento 2 - Bash Script - Install by cloning from Github repository and bash
#!/bin/bash
#title :magento2-setup.sh
#description :This script will install Magento from github
#author :Shine Software Italy
#date :20170202
#version :0.1
#usage :Set the execution permission for this file and then call it ./magento2-setup.sh
#notes :Install Composer and cURL to use this script.
process_install() {
echo "Which is the domain name of the Magento store? eg: mydomain.biz"
read DOMAIN
echo "Get the MAGENTO from GITHUB.COM"
git clone https://github.com/magento/magento2.git $DOMAIN
echo "Magento installation has been started!"
cd $DOMAIN
echo "Fixing the file and folder permissions"
find . -type f -exec chmod 660 {} \;
find . -type d -exec chmod 770 {} \;
chown www-data:www-data . -R
chmod u+x bin/magento
echo "Composer install the vendor libraries! Hold on ..."
composer install
echo "A new database must be created! Hold on a moment!"
echo "Please enter the name of the new database for Magento."
echo " --- (Warning! if it exists, it will be deleted!) ---"
read database
echo "Please enter the database password:"
read DB_PASS
echo "drop database $database;create database $database;" | mysql -u root -p
echo "Which is your store administration password?"
read MAGENTOPASS
echo "Magento 2 setup is started! Hold on ..."
php bin/magento setup:install --backend-frontname=admin --base-url=http://$DOMAIN/ --db-host=localhost --db-name=magento2 --db-user=root --db-password=$DB_PASS --admin-firstname=John --admin-lastname=Doe --admin-email=info@$DOMAIN --admin-user=admin --admin-password=$MAGENTOPASS --language=it_IT --currency=EUR --timezone=Europe/Rome --use-rewrites=1
echo "Almost done! I am cleaning the temporary files ... Just few moments ..."
rm -rf var/di var/generation pub/static/frontend var/view_preprocessed var/page_cache/* var/cache/*
echo "DONE";
}
echo "=== MAGENTO 2 SETUP ==="
while true; do
read -p "Do you wish to install Magento 2 from git?" yn
case $yn in
[Yy]* ) process_install; break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment