Step 1 : Need to check and verify the System Requirements
Before starting Magento 2 installation and setup we must need to check the Server and System requirement, that means we have the proper PHP, Apache and Database and our system is compatible to the Magento 2, please see the more details for Magento 2 system requirements : http://devdocs.magento.com/guides/v2.0/install-gde/system-requirements.html
Step 2 : In this step we will Install Composer
If all good and all the system requirement meets to the Magento 2 then we must have the composer installed in your system. You can get composer from : http://getcomposer.org Or you can install composer in Ubuntu/Linux by using the following command:
sudo apt-get install composer
Step 3 : Download Magento via Composer
So we have the System which is compatible to the Magento 2 and Composer is also setup now navigate to the root directory for me using Ubuntu 16.04, the root is at path /var/www/html/. So here I have created a folder named as my project like ewamagento2 and I will download Magento 2 over in this folder, path would be /var/www/html/ewamagento2.
Download Magento 2 CE edition by using Composer:
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition /var/www/html/ewamagento2
it will ask for username and password for repo.magento.com like this below:
Authentication required (repo.magento.com):
Username: Public Key will be your username
Password: Private Key will be your password
If you have already your account you can use this to generate the access keys from
https://account.magento.com/applications/customer/login/ here:
– Go to https://account.magento.com/applications/customer/login/ – Login – After you are logged in, click My Access Keys link – On My Access Keys page, click on Generate Keys button – Then, you will see two keys (Public and Private) – Public Key will be your username – Private Key will be your password
So latest Magento 2 has been downloaded on the server.
Step 4 : Set proper permission to the folders and file:
We need to set write permissions to vendor, app/etc, pub/static, pub/media, and var directories. We can set the permission to these folders with the following command:
cd /var/www/html/ewamagento2 && 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
Step 5 : Now navigate to the Magento 2 directory and run this commands below:
php bin/magento setup:install \ --base-url=http://xyz.com/ewamagento2/ \ --db-host=xyz.com \ --db-name=ewa-magento \ --db-user=root \ --backend-frontname=Admin \ --admin-firstname=EWA \ --admin-lastname=Admin \ --admin-email=ewaadmin@admin.com \ --admin-user=admin \ --admin-password=admin@123 \ --language=en_US \ --currency=USD \ --timezone=America/Chicago \ --use-rewrites=1
Just run this commands on the server and this will install the Magento 2 on server.
After successful installation, you will get message like this:
[SUCCESS]: Magento installation complete.
[SUCCESS]: Magento Admin URI: /admin_1cxab70d
So, in this case, Magento 2 admin URL is So, in this case, our Magento 2 admin URL is http://xyz.com/ewamagento2/admin_1cxab70d
Step 6 : Just make sure you have given the write permission to pub and var directory if you get cache write permission error, below is the command to do so.
sudo chmod -R 777 pub var
Now all set and you have done with the Magento 2 installation via Composer and Command Line (CLI). Stay tuned for the Magento 2 latest tutorial and updates, Hope you enjoyed reading, if you need the professional Magento 2 Development / PHP we can help you, just Click on the Link and send me your requirements.