How to install Magento-2.2.3 on RHEL / CentOS 7.6

Magento is a robust and powerful platform for eCommerce websites. It is built with a PHP Framework. It comes with two editions - Magento-2 Commerce (EE), formerly known as Enterprise Edition) and Magento-2 Open Source (formerly known as Community Edition). Magento-2 is a fully customizable and user-friendly interface, which can set up and control a fully operational e-commerce store in a few minutes.

In short, you can use Magento-2 EE/Commerce, which is a paid version where you can get all the advanced functionalities with a yearly subscription. You can choose a slab based on your business-level/stage and Magento-2 CE/Opensource is offered a free version where anyone can download and use it to build their own business, preferably (small business) where they can do the test on how to build an eCommerce Site. CE can modify based on your requirements, it also has the advantage of using Magento extensions to strengthen the functionality.

This step-by-step guide will help you install/configure the most recent stable Magento2 Community Edition (2.3) on CENTOS/RHEL 7.6. The same steps can be used for all the versions of CENTOS/RHEL/Fedora with a few minimal changes in commands.

Prerequisites :

Magento runs on Web Server as Apache or Nginx with a backend database (either MySQL or MariaDB)

Apache              :  Apache 2.4 or later
PHP                    :  7.2 or later
MYSQL              :  5.6 or later OR
MariaDB           :  MariaDB 10.1 or later
Server Ram      :  Minimum 2GB (according to the official Magento2)

My Lab Setup :

Server                   :  CentOS-7.6
Apache                 :   Apache/2.4.6
MariaDB              :  MariaDB 10.1 or later
PHP                       :  7.2.25
IP address            :
Domain name     :

To start the installation setup of Magento-2, we need to set up the LAMP (Linux, Apache MariaDB, and PHP) stack in our Centos 7.6 server.

Step 1: Install the LAMP stack

To complete the steps to install the LAMP stack in CentOS:- please click here:

First, let's update the latest current version of the package.

# yum update -y

Install the EPEL repository using the following command:

# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
# yum -y install epel-release

Install Apache Server using the following command:

# yum install httpd -y

Use the following command to Start httpd service and enable it to start automatically after every reboot

# systemctl enable httpd


# systemctl start httpd


# systemctl status httpd

Now, we need to add some additional configuration to the Apache Server in-order to install the Magento application.

(a)  Make sure the Apache version :

# httpd -v

Server version: Apache/2.4.6 (CentOS)
Server built: Aug 8 2019 11:41:18

(b) Magento will be hosted under the DocumentRoot of /var/www/html in Apache Server. (You can provide your path)

# mkdir -p /var/www/html/magento2

(c) If you have any normal user who needs to access/modify the files of Magento other than the root user, then you need to change the ownership of Magento directory (/var/www/html/magento). In my case, a normal user named "magento"

# chown -R magento:magento /var/www/html/magento2

Using the following command you can cross-check the ownership of the directory

# ls -ld /var/www/html/magento2/

drwxr-xr-x 2 magento magento 6 Dec 23 17:51 /var/www/html/magento2/

(d) We need to set permissions in the above directory to ensure that all files and folders are accessible through the Magento application

# chmod -R 755 /var/www/html/

# ls -ld /var/www/html/

drwxr-xr-x 3 root root 22 Dec 31 14:48 /var/www/html/

(e) Now create a new Virtual Host in Apache Server: This is mainly used for adding multiple domain requests in a single apache server.  To initialize this set-up, we need a directory to store our virtual host (this is nothing but to store individual websites in different directories), as well as we need to tell the path of virtual hosts to the Apache configuration file to serve the sites for the visitors.

(i) Here we will create two directories under Apache Server "/etc/httpd". One directory will save all the configuration files for the virtual host and the other directory will serve as a symbolic link for the newly created virtual host.

This directory is to store all the configuration files for  the virtual host

# mkdir /etc/httpd/available-virtualhosts

# mkdir /etc/httpd/enable-virtualhosts                                ## This will be served for the symbolic links

(ii) Create your first Virtual host file

# vi /etc/httpd/available-virtualhosts/magento.conf                  ## The virtual host file should be ended with ".conf"

<VirtualHost *:80>
DocumentRoot /var/www/html/magento2
ErrorLog /var/log/magento/error.log
CustomLog /var/log/magento/access.log combined

Save and exit.

(iii) Logs, you can create a folder "magento" under /var/log, so that it will not mix up with other logs

# mkdir /var/log/magento

(iv) Activate the symbolic link for the newly created virtual host configuration file

# ln -s /etc/httpd/available-virtualhosts/magento.conf /etc/httpd/enable-virtualhosts/magento.conf

(v) Add the following entry (including an optional directory) to the end of the Apache's configuration file. This is one of the easiest methods to activate and de-activate the virtual hosts in Apache. This concept was developed by Debain's well-wishers.

# vi /etc/httpd/conf/httpd.conf

IncludeOptional enable-virtualhosts/*.conf

Save and exit.

(vi) Create a dummy page for the newly added virtual host

# vi /var/www/html/magento2/index.html

This is a testing page for

Save and exit.

(vii) Use the following command to open Firewall ports  HTTP (80) and HTTPS (443) services OR simply disable the Firewall.

# firewall-cmd --permanent --add-port=80/tcp


# firewall-cmd --permanent --add-port=443/tcp


# firewall-cmd --reload


# systemctl disable firewalld.service

# systemctl stop firewalld.service

(ix) Disable the SELinux or click here to configure SELinux for apache.

(x) Now, it's time to restart the Apache Server.

# systemctl restart httpd.service

Note: Open your web browser  and hit "" to see the newly created dummy page

install magento 2 centos 7 apache

Install and Configure PHP 7.2

In Centos-7, the default repository built with PHP 5.4 version is not compatible with magento2 the latest version. It requires PHP 7.2 or higher versions. See the following steps to install and configure PHP 7.2.

(a) Activate EPEL and Remi "yum" repositories

This section discusses how to install and configure MySQL 5.6. CentOS 6.x repositories have MySQL 5.1; to install a different version of MySQL, see the MySQL documentation. # yum install epel-release

# rpm -Uvh

(b) Use the following command to install PHP 7.2 and it's a dependency on your CentOS-7 Server

# yum --enablerepo=remi-php72 install php php-bcmath php-dom php-gd php-intl php-mbstring php-pdo_mysql php-soap php-zip

# yum install -y php72-php-xmlrpc.x86_64

(c) PHP 7.2 is installed, check the following command to find the version of PHP

# php -v

PHP 7.2.26 (cli) (built: Dec 17 2019 14:06:22) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

(d) Tweaking PHP's default configuration file which is "php.ini". Based on our requirements we need to change the settings of PHP. These changes are related to uploading maximum size, display log errors, resource limits, setting the time zone, setting the maximum php execution time, etc.

Modify the following changes in your php.ini file. For the date, you can change it based on your zone

#  vi /etc/php.ini

max_input_time = 30
memory_limit= 2G
error_log = /var/log/php/error.log
date.timezone = Asia/Calcutta

Save and exit.

Note: After every change in the php.ini file, do not forget to restart your web server.

(e)  In CentOS-7 the mod_rewrite will be enabled by default,  in case if it is not enabled, then follow the steps to enable "mod_rewrite" manually

Open this file and add the following entry at the end of the file

# vi /etc/httpd/conf.modules.d/00-base.conf

LoadModule rewrite_module modules/

Save and exit.

Note: Restart your Apache Server!


Find the section <directory /var/www> and change AllowOverride None to AllowOverride All

<Directory /var/www>
AllowOverride All

Save and exit.

Note: Finally, Restart your Apache Server!

(g) Create an info.php file under /var/www/html/magento2 to check all the current PHP configurations from your Web Browser

# echo "<?php phpinfo(); ?>" > /var/www/html/magento2/info.php

Note: Open your web browser and hit:  Once you're confirmed, then delete the info.php file

magento 2 php 7.2

Install and Configure Maria DB (Replacement of MySQL)

This section will show you how to install and configure the Database Management System (DBMS) for Magento2. As all we know, the launch of RHEL/CENTOS-7 RedHat has switched their default database management system from MySQL to MariaDB and the default MariaDB version is 5.5 which is not compatible with Magento2. As mentioned above, the compatible version is 10.1 or later. It can be upgraded through the MariaDB yum repository. Follow these steps to install and configure MariaDB 10.1 from yum repository:

(a) Create a repository configuration file for MariaDB 10.1

# cat > /etc/yum.repos.d/mariadb.repo << EOF

(b) Import GPG public key

# rpm --import

(c) Enable yum cache for the recently added repo

# yum makecache fast

(d) Install MariaDB 10.1 version

# yum install -y mariadb-server

(e) Use the following command to start MariaDB service and enable it to start automatically after every reboot

# systemctl enable mariadb.service


# systemctl start mariadb.service

(f) Configure Maria DB

# mysql_secure_installation

magento with mariadb

(g) Connect to MariaDB database instance using root credentials.

# mysql -u root -pXXXXXX (XXXXX is your root DB password )

Welcome to the MariaDB monitor.

Your MariaDB Server version: 10.1.43-MariaDB MariaDB Server

MariaDB [(none)]>

(h) Create a new mysql user and database for Magento Applications.

MariaDB [(none)]> create database magento2;
Query OK, 1 row affected (0.00 sec)


MariaDB [(none)]> create user magento2@localhost identified by 'Magento1@123';
Query OK, 0 rows affected (0.01 sec)


MariaDB [(none)]> grant all privileges on magento2.* to magento2@localhost identified by 'Magento1@123';
Query OK, 0 rows affected (0.00 sec)


MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)


MariaDB [(none)]> quit


Step 2: Install Composer

(a) Use the following yum command to install PHP Composer

# yum --enablerepo=remi-php72 install php composer

(b) After installation check the version of the composer

# composer -V

Composer version 1.9.1 2019-11-01 17:20:17

Step 3: Install  Magento CE

(a) Download magento2-2.3 Community Edition from Magento Official Website. Click here to download:

(b) After downloading, extract the tar file of Magento2 into your Document Root (/var/www/html/magento2)

# tar -xvf magento2-2.3.2.tar.gz -C /var/www/html/magento2/

Note: Make sure after extraction all the Magento2 cores files should be placed under /var/www/html/magento2 and remove any previously created dummy "index.html and info.php" from the same folder.

# pwd



# ls


app                                composer.json            generated                                   pub        vendor
auth.json.sample    composer.lock           grunt-config.json.sample     lib          nginx.conf.sample
bin                                 COPYING.txt            Gruntfile.js.sample                 LICENSE_AFL.txt package.json.sample     setup  dev                                 index.php                                    LICENSE.txt             phpserver var

(c) To install the Magento2 application via browser we need to change the ownership of /var/www/html/magento2 to apache user and group. Follow the below command to do the same.

# chown -R apache:apache /var/www/html/magento2/

# ls -ld /var/www/html/magento2/


drwxr-xr-x 13 apache apache 4096 Jan 2 13:55 /var/www/html/magento2/

(d) Now use the following command to download all the packages and their dependencies of Maento2 using composer from Terminal.

# composer install

install magento 2 using composer

Note: This will download all Magento components and their dependencies. Once you have successfully installed magento2 using composer you will see a line ending with "Generating Autoload Files".

Access Magento Web Installation Wizard

(a) Now open your browser and hit "" and you will get the WEB wizard setup. Follow these screenshots for further steps:

The first page will redirect you to the License Agreement Page of Magento2.

(i) Click on Agree and Setup Magento

install magento 2 enterprise composer

(ii) Click on Start Readiness Check

magento installation guide

(iii) If there are any fails found during the Readiness Check, then you need to rectify before click Next. In our case there are no failures,  so click Next

magento installation steps

(iv) Now fill in the Database details which you have created above and click on Next

magento database configuration

(v) Make the changes to the Web Configuration based on your needs and click on Next

magento 2 server configuration

(vi) Customize your Store and click on Next

magento 2.3 installation in centos 7

(vii) Create an Admin Account and click on Next

magento commerce installation

(viii) Click on Install Now

magento 2 server setup

(ix) Magento2 installation on CentOS 7 server in progress

download and install magento

(x) Magento2 installation has been completed.

install magento 2.3

(b) Due to the security measures of Magento2 application, we need to revoke the permission of the following directories:
'/var/www/html/magento2/app/etc'. The following command will remove the write permission

# chmod -w /var/www/html/magento2/app/etc


chmod: /var/www/html/magento2/app/etc: new permissions are r-xrwxr-x, not r-xr-xr-x

(c) Now Click on Launch Magento Admin

Launch Magento Admin

(d) Once you log in as an Admin User (linuxteck) , you’ll see the Magento2 dashboard, which will appear something like this:

install magento dashboard


Congratulations, you have successfully installed Magento2 Community Edition on RHEL/CentOS 7.6. During the installation of your Magento setup, if you face any difficulties, just let us know through the comment box.

I hope this article will help you to set up a 'magento2 application on RHEL/CentOS-7. Drop me your feedback/comments.

Thank you!

Support My Work

Thank you for your support and for being a part of my journey, I would be very grateful if you could consider buying me a coffee. The contributions you make will help me to continue to produce quality content and enhance my readers' experience.

Buy Me A Coffee

Thank you for your endless support!


Leave a Reply

Your email address will not be published.