There is a plethora of eCommerece software online. Sometimes it can be hard to pinpoint what system is the optimal choice. There is Shopify, Magento, WooCommerce and many more. Magento is an open source eCommerce software, now owned by eBay. Owing to its open source support base, it has gained immense popularity.

In today’s tutorial, we will walk you through setting up Magento Community on a CentOS 7 server.


Before we start with the actual Magento installation, we will install  Apache, MySql, and PHP. If you already have a LAMP setup ,you can skip steps 1-3 and move directly to step 4.

STEP 1 – Installing Apache web server

To install Apache web server, use command sudo yum install httpd.

Apache install

This will install the latest Apache version. Once installed, you can start the server using command- sudo systemctl start httpd.service

Apache start

If you want to start Apache server automatically on server reboot, then use command- sudo systemctl enable httpd.service.

Next, we will make some configuration changes in the file httpd.conf.

Navigate to the directory using the command- cd /etc/httpd/conf. Once you’re there, edit the file httpd.conf. In the file locate the content that goes between lines- </Directory “/var/www/”> </Directory>

Change this as shown below:

<Directory “/var/www/html”>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from alls

After saving the changes, you can restart the server using- sudo systemctl restart httpd. This completes the configuration of Apache.


To install MySql, use the command- sudo yum install mariadb-server mariadb

MariaDB install

This will take a while. After installation, we need to start the MariaDB/Mysql server using the command- sudo systemctl start mariadb.service


In case you want to start MariaDB automatically on every system boot, use command- sudo systemctl enable mariadb.service. Next, we have to configure the MySQL server. Use command- mysql_secure_installation, to start the configuration process. This will prompt you to create a new password.

password prompt

Since this is the first time you’re configuring it, press enter. After this you will be prompted to set a password. Choose option ‘Y’ wherever applicable. This completes the configuration of MySQL.


To install PHP, use the command- sudo yum install php php-gd php-mysql php-tidy php-xmlrpc php-common php-cli php-xml


While installing, choose ‘Y’ option to complete the installation. CentOS 7’s default repositories include PHP 5.4, which is not compatible with Magento 2. Install the IUS (Inline with Upstream Stable) repository to get PHP 7.

Use command- sudo wget -P /tmp

PHP download

Next install using command- sudo yum localinstall /tmp/ius-release-1.0-14.ius.centos7.noarch.rpm

PHP install

Once installed, update it using the command- sudo yum update. This will take a while.

PHP update

Install PHP 7 and its required extensions from the IUS repository using below command-

sudo yum install php70u php70u-pdo php70u-mysqlnd php70u-opcache php70u-xml php70u-mcrypt php70u-gd php70u-devel php70u-mysql php70u-intl php70u-mbstring php70u-json php70u-iconv

To modify the settings open file /etc/php.ini. You can edit the below mentioned values-

  • max_input_time = 30
  • memory_limit= 2G
  • error_log = /var/log/php/error.log
  • date.timezone = America/New_York

This completes PHP installation.


You can install Magento in different ways. The best way to install Magento is to download the system using Git, and then install it using composer.

First, download Magento with the following git command:

  • cd /var/www/html/
  • sudo git clone

The above command will install the latest version of Magento in Apache’s default document root directory. It is recommended to switch to a stable release of Magento. You can do this with the command:

  • cd magento2
  • sudo git checkout tags/2.1.0 -b 2.1.0

Now move all the installation files to the document root of Apache using command- sudo mv /var/www/html/magento2/* /var/www/html/

You will also need to set proper permissions to the files and folders of Magento using the following commands:

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

Now you can install Magento using this command:

  • cd /var/www/html
  • curl -sS | sudo php — –install-dir=/usr/local/bin –filename=composer

Next, we need to configure the Magento database. After we complete extracting our the software to Apache Web Server’s web root, we’ll need to create a new database for Magento. And we’ll also need to create a new database user for it.

Log into the database as a root user using the command- mysql -u root -p. Next, run the SQL statement below to create a database called magento. Use the command:


Then run the commands below to create a new database user called magentouser. Command:

CREATE USER [email protected];

Then grant all access and privileges to the new database to the database user, by using:

GRANT ALL ON magento.* TO [email protected] IDENTIFIED BY ‘password‘;


After completing all the above steps, you will need to restart your Apache2 Web Server so that all the changes take effect correctly. Use the command – sudo systemctl restart httpd.service

Next, we’ll need to open the firewall port for HTTP Traffic. This can be done using the following:

  • sudo firewall-cmd –permanent –zone=public –add-service=http
  • sudo firewall-cmd –permanent –zone=public –add-service=https
  • sudo firewall-cmd –reload

Finally, to test, you will have to open http://<ipaddress> on your browser. You should be able to see the Magento setup page as shown below:

Magento signup

Click on the Agree and Setup Magento button, and you should see the following page:

Magento second page

Just follow the setup wizard and you’re done!