Skip to content

Instantly share code, notes, and snippets.

@wsakaren
Last active December 15, 2017 17:22
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save wsakaren/3ce55df87aa93a63251c to your computer and use it in GitHub Desktop.
Save wsakaren/3ce55df87aa93a63251c to your computer and use it in GitHub Desktop.
Install script for magento2 with database, assumes you are running from www.localhost.com/20
#!/bin/bash
# Sets up a database with a magento2 installation. This assumes you are running from under your httpdocs/<release> location and have www.localhost.com in your /etc/hosts file
# To run type : install_magento2 <dirname> <password> <release>
# password is used for the datbase user and the magento admin password
if [ $# -eq 0 ]; then
echo "No arguments supplied"
echo "Usage: `basename $0` <dirname> <password> <release>"
echo "e.g install_magento2.sh mage2 password 21"
exit 1
fi
if [ "$1" == "-h" ]; then
echo "Usage: `basename $0` <dirname> <password> <release>"
exit 0
fi
Q1="CREATE DATABASE IF NOT EXISTS $1$3;"
Q2="CREATE USER $1$3@'localhost' IDENTIFIED by '$2';"
Q3="GRANT USAGE ON *.* TO $1$3@localhost IDENTIFIED BY '$2';"
Q4="GRANT ALL PRIVILEGES ON $1$3.* TO $1$3@localhost;"
Q5="FLUSH PRIVILEGES;"
SQL="${Q1}${Q2}${Q3}${Q4}${Q5}"
echo $SQL;
MYSQL -uroot -p -e "$SQL"
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition $1
cd $1
chmod -R 775 *
bin/magento setup:install --base-url=http://www.localhost.com/$3/$1/ --db-host=localhost --db-name=$1$3 --db-user=$1$3 --db-password=$2 --admin-firstname=Magento --admin-lastname=User --admin-email=sales@webshopapps.com --admin-user=admin --admin-password=$2 --backend-frontname=admin --language=en_US --currency=USD --timezone=America/Chicago --use-sample-data --use-rewrites=1
bin/magento deploy:mode:set developer
# run this after you have setup phpstorm
#bin/magento dev:urn-catalog:generate .idea/misc.xml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment