How to install Magento 2 quickly using CLI

How to install Magento 2 quickly using CLI

Undoubtedly, the Magento 2 installation process using the wizard in a browser is quite cumbersome and time consuming, especially when we use sample data. To overcome that, we at KiwiCommerce have got a completely new tactic to install Magento 2 within minutes, and that is with the use of CLI.

Below is a couple of steps that lets you install and run Magento 2 in no time:

Step 1: Download Magento 2.

Here, we can get the Magento 2 Files using composer or directly get a zip file from https://magento.com/tech-resources/download.

Using composer

Get the latest Magento version by running the below command in the console:

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

Or to get a specific version of Magento, add an extra argument in command as below:

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

The <directory> is the location where you want to install Magento. If you do not specify <directory> then it creates project-community-edition.

Download direct Zip

We can download the agento 2 full release with or without sample data from https://magento.com/tech-resources/download and extract it to where you want to install. Please check the below screenshot to see this:

Magento2 Download

Step 2: Install using CLI

After setting up the Magento 2 file system, run the below command in CLI from the Magento 2 root folder to install it quickly:

php bin/magento setup:install \
--base-url=http://127.0.0.1/magento/ \
--db-host=localhost \
--db-name=magento \
--db-user=root \
--db-password=123456 \
--admin-firstname=root \
--admin-lastname=localhost \
[email protected] \
--admin-user=admin \
--admin-password=admin123 \
--backend-frontname=admin \
--language=en_US \
--currency=USD \
--timezone=America/Chicago \
--use-rewrites=1

Check the above options in detail below:

Option NameValueRequired?
–base-urlBase URL to use to access your Magento Admin and storefrontNo
–db-hostYour database host. For ex. `localhost`No
–db-userYour database user. For ex. `root`No
–db-passwordYour database user’s password.No
–admin-firstnameMagento admin user’s first name.Yes
–admin-lastnameMagento admin user’s last name.Yes
–admin-emailMagento admin user’s e-mail address.Yes
–admin-userMagento admin username.Yes
–admin-passwordMagento admin user password.Yes
–backend-frontnameUniform Resource Identifier (URI) to access the Magento Admin or omit this parameter to let Magento generate a random URI for you.No
–languageLanguage code to use in the Admin and storefront.No
–currencyDefault currency to use in the storefront.No
–timezoneDefault time zone to use in the Admin and storefront.No
–use-rewrites1 means you use web server rewrites for generated links in the storefront and Admin.
0 disables the use of web server rewrites. This is the default.
No

Here I’ve added some options in the above command which I think are required, but are not compulsory. The above command should be edited to your needs and executed from the Magento 2 root directory. If everything went correctly, you will be informed that the installation has been completed.

For more detail please refer to this link: https://devdocs.magento.com/guides/v2.2/install-gde/install/cli/install-cli-install.html#instgde-install-cli-magento

Conclusion

You’re done! Now you know the complete process to install Magento 2 using CLI, and of course the best bit it that you can do it quickly. If you get stuck somewhere while doing this, please connect with us and we will be glad to help you 🙂

No Comments

Leave a Reply

Your email address will not be published. Required fields are marked *