Download and Install Magento 2 using CLI

At the drop of a hat I would like to write this post because, for the developers, downloading and installing Magento is just a frequent and unpredictable task along with his/her routine. Here is handy solution to do the same using CLI, it’s quick and you need not check browser to fill forms and install Magento.

Download magento using composer

composer create-project –repository-url=https://repo.magento.com/ magento/project-community-edition=[version] [installation_directory_name]

Example : composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.2.4 magento224os

composer create-project –repository-url=https://repo.magento.com/ magento/project-community-edition=[version]+Samples.* [installation_directory_name]

Example : composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.2.4+Samples.* magento224os

Create a MySQL database to connect

mysql -u[mysql_username] -p
CREATE DATABASE IF NOT EXISTS ,database_name];

Start installation

php bin/magento setup:install
–base-url=”[base_url]”
–db-host=”localhost”
–db-name=”[database_name]”
–db-user=”[database_user]”
–db-password=”[database_password]”
–db-prefix=”[database_prefix]”
–cleanup-database
–admin-firstname=”[admin_firstname]”
–admin-lastname=”[admin_lastname]”
–admin-email=”[admin_email]”
–admin-user=”[admin_username]”
–admin-password=”[admin_password]”
–language=”en_US”
–currency=”USD”
–timezone=”America/Chicago”
–use-rewrites=”1″
–backend-frontname=”admin”
–sales-order-increment-prefix=”[order_prefix]”

php bin/magento setup:install --base-url="http://127.0.0.1/magento224os/" --db-host="localhost" --db-name="magento224os" --db-user="root" --db-password="root" --db-prefix="mos_" --cleanup-database --admin-firstname="Magento2" --admin-lastname="Admin" --admin-email="admin@magento2.com"  --admin-user="admin" --admin-password="admin123"  --language="en_US" --currency="USD" --timezone="America/Chicago" --use-rewrites="1" --backend-frontname="admin" --sales-order-increment-prefix="MOS"

Install sample data after installing magento if required

php bin/magento sampledata:deploy
php bin/magento setup:upgrade

Set Magento2 application to developer mode

php bin/magento deploy:mode:set developer

Create admin user using command line(If you forgot the created one)

php bin/magento admin:user:create –admin-user='[admin_username]’ –admin-password='[admin_password]’ –admin-email='[admin_email]’ –admin-firstname='[admin_firstname]’ –admin-lastname='[admin_lastname]’

php bin/magento admin:user:create --admin-user='developer' --admin-password='developer123' --admin-email='developer@magento2.com' --admin-firstname='Magento2' --admin-lastname='Developer'

I hope this gonna a small help developers to get,set & go with Magento 2!!!

Advertisements

Post your Queries or Suggesions

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.