How to install Magento using command line?

Magento is one of the best e-commerce based open-source platform which is written in PHP. Magento provides three different platforms:

  1. Magento Community Edition
  2. Magento Enterprise Edition
  3. Magento Enterprise Cloud Edition

Here we will be learning how to install Magento using the command line(CLI). Command line installation of Magento is one of the most efficient ways of installing if we are installing it on servers.

Download Magento Community Edition 1.X

One can download the required version of the Magento from the official website of the magneto. Use below link to download your package.

https://magento.com/tech-resources/download

download-magento-community-edition

It will ask to login. If you do not have an account then create an account and proceed further.

Uncompressing the downloaded file

Move the file to a directory where you want to install it and uncompress it.

a) If it is a zip file then using following way:

Syntax:- unzip file_name

e.g –

unzip magento-1.9.3.10-2018-09-18-03-21-10.zip

b) If it is a tar file then use the following way:

Syntax:- tar xf file_name

e.g –

tar xf magento-1.9.3.10-2018-09-18-03-21-10.tar.bz2

Prerequisite for Magento installation:

For the installation of the Magento, you will need to meet the standard system requirements. As per the documentation of Magento you need to meet the following requirement for the installation of the Magento.

a) Environment:

LAMP (Linux, Apache, MySQL, and PHP) or LNMP stack

b) Operating System:

Linux x 86, x86-64

c) Web Server:

  • Apache 2.x
  • Nginx 1.7.x

d) Server Hosting:

  • Ability to run scheduled jobs (crontab) with PHP 5.
  • Ability to override options in .htaccess files.

e) PHP:

  • PHP 5.6
  • PHP 5.5
  • PHP 5.4

f) Required extensions:

  • PDO_MySQL
  • Simplexml
  • Mcrypt
  • Hash
  • GD
  • DOM
  • Iconv
  • Curl
  • SOAP (for Webservices API)

g) Additional configuration:

  • safe_mode off
  • memory_limit no less than 256 MB (512 MB recommended)

h) Database:

  • MySQL 5.6 (Oracle or Percona)

For detailed information please check:

https://docs.magento.com/m1/ce/user_guide/magento/system-requirements.html

Setup Database

Now we will set up the database for our Magento. For setting up database one must have following things

  1. DB Host
  2. DB Name
  3. DB Username
  4. DB Password

Steps for creating a database:

Step 1. Login to your MySQL:

MySQL -uDB_User -pDB_Password -hDB_Host

a) DB_User:- Username of the MySQL

b) DB_Password:- Password of the MySQL

c) DB_Host:- Hostname of the MySQL

login-to-mysql

Step 2. Create a database:

Syntax:- create database DB_NAME

E.g

create database kb_mage_db;

Here kb_mage_db is the name of the database which we are creating.

Step 3. Check the newly created database using below command

Show databases;

This will show the list of all the created database in your system. Here the name of the database which you created should show.

Step 3. Exit from your MySQL server using the following command

exit;

Installation of Magento

For CLI installation, we need to run the following command:

php -f install.php -- \
--license_agreement_accepted "yes" \
--locale "en_US" \
--timezone "America/Los_Angeles" \
--default_currency "USD" \
--db_host "DB_HOST" \
--db_name "DB_NAME" \
--db_user "DB_USER" \
--db_pass "DB_PASS" \
--db_prefix "DB_PREFIX" \
--admin_frontname "ADMIN_FRONT_NAME" \
--url "SITE_URL" \
--use_rewrites "yes" \
--use_secure "yes" \
--secure_base_url "SITE_URL" \
--use_secure_admin "yes" \
--admin_firstname "ADMIN_FIRST_NAME" \
--admin_lastname "ADMIN_FIRST_LAST_NAME" \
--admin_email "EMAIL" \
--admin_username "USERNAME" \
--admin_password "PASSWORD"

Explanation of the keywords used in the CLI command.

  1. Locale: Place language code like “en_US” which want to use in Magento.
  2. Timezone: Place timezone which wants to use in Magento. In this case, we have used “America/Los_Angeles”.
  3. Default_currency: Place currency which wants to use in Magento.
  4. DB_HOST – Database hostname, in case of a local system put localhost
  5. DB_NAME – The name of your database e.g. kb_mage_db
  6. DB_USER – The username with access rights to the database
  7. DB_PASS – The password for the database user
  8. SITE_URL – The path where Magento is installed, e.g. http://www.kbmagedomain.com/
  9. ADMIN_FIRST_NAME – First name of the admin
  10. ADMIN_LAST_NAME – Last name of the admin
  11. EMAIL – The store owner’s email address, e.g. email@knowband.com
  12. USERNAME – The administrator’s username. This will be used to login on magneto backend.
  13. PASSWORD – The administrator’s password. This will be used to login on magneto backend.

CLI-command

After the installation of the Magento, success message will show with the encryption id.

Now open your favorite browser and check you installed Magento using the URL you used.

Prashant Kumar

Prashant Kumar

Prashant is a passionate Magento developer. He loves exploring e-commerce and reading books.

Leave a Reply

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