How to Install Magento on CentOS 7

r00t November 2, 2017

Install Magento on CentOS 7

In this tutorial we’ll learn how to install Magento on CentOS 7. We will also install and configure its prerequisites. Magento open source is a flexible e-commerce platform for both developers and smaller businesses. The free open source edition includes all the functionality and features to fulfill the demands of the businesses of today. It’s the perfect platform for developing small company websites or anybody who wishes to understand and experiment with building an online shop.

I recommend to use a minimal CentOS server setup as a basis for the tutorial, that can be a virtual or a root server image with an CentOS 7 minimal install from a web hosting company or you use our minimal server tutorial to install a server from scratch.

Install Magento on CentOS 7

Step 1. First, ensure your system is fully up-to-date by running the following:

yum -y update

Step 2. Installing LAMP on CentOS 7.

You should check out this LAMP stack install tutorial for CentOS 7, if you haven’t installed LAMP yet. Once it’s installed, come back here and read on. We also will install the required packages for LAMP stack and the important PHP extension that Magento relies on:

yum install php70w php70w-dom php70w-mbstring php70w-gd php70w-pdo php70w-json php70w-xml php70w-zip php70w-curl php70w-mcrypt php70w-pear

You will need to increase the memory limit of PHP and also set the timezone. You can do this by editing the php.ini file:

sudo nano /etc/php.ini

Change the following lines:

memory_limit = 500M
date.timezone = Asia/Kolkata

Step 3. Installing Composer.

To install composer simply run the following command:

curl -sS | php
sudo mv composer.phar /usr/bin/composer

Step 4. Configure Database for Magento.

Next, we need to create a database for the Magento installation:

mysql -uroot -p

Run the following command to create a database for Magento:

MariaDB> CREATE USER 'cloud'@'localhost' IDENTIFIED BY 'magentopasswd';
MariaDB> GRANT ALL PRIVILEGES ON magento.* TO 'cloud'@'localhost';
MariaDB> exit

Step 5. Installing Magento.

The best method to install Magento is to download the Magento using Git, then install it using composer:

cd /var/www/html/
sudo git clone

The above command will install the latest version of Magento software into your server, which is a development version by default. It is important to switch to a stable release, if you don’t then you won’t be able to upgrade the installation in future. If you wish to switch to a stable release, then run the following command:

cd magento2
sudo git checkout tags/2.1.0 -b 2.1.0

Move all the installation files to document root of Apache:

sudo shopt -s dotglob nullglob
sudo mv /var/www/html/magento2/* /var/www/html/

Now just set the right permissions for the folders:

sudo chown -R apache:apache /var/www/html/
sudo chmod -R 775 /var/www/html/

Finally step, install Magento using the following command:

cd /var/www/html
sudo composer install

Step 6. Accessing Magento Web Installation.

Now you can access the Magento web install wizard in your browser by entering the domain name or http://your_ip/ to continue your Magento installation.

Congratulation’s! You have successfully install and configure Magento server on your CentOS 7 server. Thanks for using this tutorial for installing Magento open source e-commerce on CentOS 7 system.

The Tags:

Leave a Comment

Comments are closed.