How to Install Magento 2 using Command Line?

Installing Magento 2 Using CLI

Looking to upgrade Magento to the latest version?

There is no setup wizard now. You have to install Magento 2.4 using Command Line.

Magento 2.4 is the latest Magento version. As expected, it has better performance and scalability than the previous versions.

The upgraded version introduced new features:

  • Security-only patch available
  • More than 30 security enhancements to prevent remote code execution (RCE) and cross-site (XSS) vulnerabilities.
  • Inbuilt 2FA feature for the admin dashboard, magento.com users, and cloud SSH access
  • Data rendering for UI data providers are now disabled by default.
  • PHP 7.4 support was introduced, and PHP 7.1 and 7.2 were deprecated. 
  • Migration of dependencies on Zend Framework to the Laminas project
  • Removal of core integration of third-party payment methods. 
  • Inbuilt Lazy Loading
  • Support for PWA Studio

And many more.

Let’s see the Magento 2.4 installation process via Command-Line.

Installing Magento 2.4 using Command Line

  1. Log in to Magento Servers
  2. Useful Magento Commands
  3. Install the Magento Software using Command Line
  4. Verify the Installation

Step 1: Log in to Magento Servers

The first step is to log in to the server you prepared to install Magento. Make sure the server fulfils all the Magento 2 requirements.

You will need ‘Write’ permission to install the Magento.

Bash Shell users can use the following syntax to switch to the Magento file system owner and enter the commands simultaneously.

su <Magento file system owner> -s /bin/bash -c <command>

If you don’t have the Magento file system owner logins, use the following command:

sudo -u <Magento file system owner> <command>

Simply add <magento_root>/bin to your system PATH to run Magento commands from any directory.

Step 2: Useful Magento Commands

You will be working with the Command line. If you need the list of all commands, enter the following command:

bin/Magento list

Want help with any particular commands? Use the below command:

bin/magento help <command>

Step 3: Install the Magento Software from the Command Line

Magento installation Command line format: 

magento setup:install --<option>=<value> ... --<option>=<value>

You can add options and attach their value. For example:

A command to install Magento 2:

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

Here:

The base URL is localhost IP. DB’s name is m111.

And everything else is easily understandable from the example from Command Line.

Admin Credentials:

The following table shows the user information and credentials for the Magento admin user.

NAMEVALUEREQUIRED?
–admin-firstnameMagento administrator user’s first name.Yes
–admin-lastnameMagento administrator user’s last name.Yes
–admin-emailMagento administrator user’s e-mail address.Yes
–admin-userMagento administrator username.Yes
–admin-passwordMagento administrator user password.Yes

Find More Information.

Verify the Installation

#1 Verify the storefront

Open any latest browser and enter your Magento store URL to open the storefront.

If the Magento installation base URL is “http//www.example.com,” enter it into your preferred browser.

If the page loads up and looks like the image below, it means the installation is successful. 

Install Magento 2 using Command Line Storefront

#2 Verify the Magento Admin Page

Finally, you need to check if the Magento admin is working fine. Enter the Magento store base URL in your favourite browser.

For example: https://www.example.com/admin_breeze

Magento login Page

A login page will open. Enter the username and password. If everything goes as expected, the Magento admin dashboard will load up.

Your Magento installation is successfully done, and your store is ready if it looks like this:

Magento Dashboard

It is a good security practice not to use the default login URL. Follow the steps to change the Magento login URL.

Install Magento using Breeze

The CLI method is straightforward. Optimization of servers, however, is a different game.

You have to optimize the server for Magento, fulfil all the requirements, and then tweak it to run at high performance.

As your business scale, the server will demand more management. It takes a significant amount of time and resources from your business every day.

How about a product that does it all for you?

With Breeze, you only have to pick your store name and password – and your store will be built.

  • Store loading under 3 seconds with quick TTFB
  • Active security monitoring – mitigating DDoS attacks and BOT attacks
  • Uptime monitoring keeping your store always available
  • Quickly scalable in case of traffic spike during promotion
  • Use the dashboard to use one-click tools to manage & run your store efficiently

Want to take a Demo? Just sign up on the Breeze, and ask the live chat for Coupon Code to build your first store.

Wrap Up

Whether you install Magento using composer or using command line, you have to prepare the server for Magento.

If you do not want to hassle with server management, Breeze is for you. From server to Magento, we will take care of everything your store needs to be fast, secure, and always online.

In this quick tutorial, you learned to install Magento 2 using the Command line. If there is any question, please leave it in the comment section.

Latest Magento Tips, Guides, & News

Stay updated with new stuff in the Magento ecosystem including exclusive deals, how-to articles, new plugins, and more. 100% Magento Goodness, a promise!

Leave a Comment

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

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

Scroll to Top

🎉 CYBER MONDAY SAVINGS 🎉

75% OFF on
ALL PLANS

Receive the coupon as soon as you
submit the email address. 🚀