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.
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:
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:
|–base-url||Base URL to use to access your Magento Admin and storefront||No|
|–db-host||Your database host. For ex. `localhost`||No|
|–db-user||Your database user. For ex. `root`||No|
|–db-password||Your database user’s password.||No|
|–admin-firstname||Magento admin user’s first name.||Yes|
|–admin-lastname||Magento admin user’s last name.||Yes|
|–admin-email||Magento admin user’s e-mail address.||Yes|
|–admin-user||Magento admin username.||Yes|
|–admin-password||Magento admin user password.||Yes|
|–backend-frontname||Uniform Resource Identifier (URI) to access the Magento Admin or omit this parameter to let Magento generate a random URI for you.||No|
|–language||Language code to use in the Admin and storefront.||No|
|–currency||Default currency to use in the storefront.||No|
|–timezone||Default time zone to use in the Admin and storefront.||No|
|–use-rewrites||1 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.
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
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 ?