Installing Magento 2 Using Composer

Install Magento

Standard Install

This will install Magento with no settings present – you will enter these from visiting your site’s URL.

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

Setup Install

This will install Magento pre-populated with settings, so that you won’t have to enter them in the setup process.

php -d memory_limit=4G  bin/magento setup:install \
--backend-frontname=admin --cleanup-database \
--db-host=localhost --db-name=DATABASE_NAME --db-user=DB_PASSWORD --admin-password=PASSWORD \
--admin-user=ADMIN_USERNAME --admin-firstname=ADMIN_FIRSTNAME --admin-lastname=ADMIN_LASTNAME --admin-email=ADMIN@EMAILADDRESS \
--currency=GBP --use-rewrites=1

bin/magento cron:run
bin/magento cron:run
bin/magento setup:static-content:deploy
bin/magento deploy:mode:set developer
rm -rf var/cache

If you are prompted to enter a username and password, you can retrieve or create these by logging into magentocommerce.com;

  • Click the ‘Connect’ Tab
  • Click ‘Secure Keys’ from the left navigation
  • If you don’t have a secure key listed, enter a name and click ‘Generate new’.
  • The username you need to enter is the Public Key, and the password is the Private Key.

Change the Directory Permissions

find var vendor pub/static pub/media app/etc -type f -exec chmod g+w {} \;
find var vendor pub/static pub/media app/etc -type d -exec chmod g+w {} \;
chmod u+x bin/magento

Complete Installation 

Visiting your website’s URL should walk you through the rest of the installation process. This step will be omitted if the ‘Setup Install’ section above was followed

Installing Sample Data 

The following will install Magento’s sample data with an increased memory limit, as it will tend to fail without it.

php -d memory_limit=2G bin/magento sampledata:deploy

Run Upgrade

bin/magento setup:upgrade