Magent 2 – Install via composer

This installation assumes that you have PHP, apache2, MySql, composer installed already.

1. Install via composer:

  composer create-project --repository=https://repo.magento.com/ magento/project-community-edition <install-directory-name>

2. Set file permissions

  cd <install-directory-name>
  sudo find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
  sudo find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +
  sudo chown -R :www-data . // Ubuntu
  sudo chmod u+x bin/magento

3. Create MySql database say: m2

4. Create new virtual host using script: vh

 vh new mage2 -p ~/<install-directory-name>

5. Run installation command

  php bin/magento setup:install \
--base-url="http://mage2.loc/" \
--db-host="localhost" \
--db-name="m2" \
--db-user="root" \
--db-password="root" \
--admin-firstname="admin" \
--admin-lastname="admin" \
--admin-email="admin@example.com" \
--admin-user="admin" \
--admin-password="admin123" \
--language="en_US" \
--currency="USD" \
--timezone="America/Chicago" \
--use-rewrites="1" \
--backend-frontname="admin"

6. Browse to http://mage2.loc

7. Install sample data

  php bin/magento sampledata:deploy