Install Magento2 on Centos 7 with httpd, apache, mysql-server, phpmyadmin .

How to install Magento2 (M2) on centos7/REHL/Fedora ?

There are few easy steps to install Magento 2(M2) on Centos Distro.

Step 1-:
First of all we need to add few EPEL repositories for the php5.6, mysql-server5.6, and phpmyadmin.

# EPEL Repository for php5.6
$ rpm -iUvh
$ rpm -iUvh
# EPEL Repository for mysql-server5.6
$rpm -iUvh
# EPEL Repository for phpMyadmin on Centos 7
$ rpm -iUvh
$ yum -y update

Step 2-:

Install Require packages like apache, php5.6, mysql-server, phpmyadmin.

$ yum install -y httpd php mysql-server phpmyadmin php56w-mcrypt php56w-intl php56w-xsl git

To allow the phpmyadmin in apache 2.4 add the line

Require all granted

vi /etc/httpd/conf.d/phpMyAdmin.conf

<Directory /usr/share/phpMyAdmin/>
AddDefaultCharset UTF-8

<IfModule mod_authz_core.c>
# Apache 2.4
Require ip
Require ip ::1
Require all granted

To add the apache application on start up

$ systemctl enable httpd

Restart the apache server

$ systemctl restart httpd

Step 3-:
Set the mysql root password and allow firewall to access of port 80 and 443.

$ mysql
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('root');
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

mysql> quit

Allow port 80 and 443 in iptables public zone

$ firewall-cmd --zone=public --add-port=80/tcp --permanent
$ firewall-cmd --zone=public --add-port=443/tcp --permanent

Then remember to reload the firewall for changes to take effect.

$ firewall-cmd --reload

Step 4-:
Git clone Magento2 (M2) source code and Install dependencies via Composer.

$ cd /var/www/html/
$ git clone
$ cd magento2
$ composer install

if composer is not installed.
(use the below command to install composer)

$ curl -sS | php 
$ mv composer.phar /usr/local/bin/composer
$ sudo chmod 0755 /usr/local/bin/composer

To change the required ownership and permissions.

$ chown -R apache:apache /var/www/html/magento/
$ chmod -R 775 /var/www/html/magento/

Edit .htaccess file of main folder and set RewriteBase with your application directory name.

 RewriteBase /magento2/

Step 5-:

Follow the Magento Installer Steps.
Your Magento2 Setup is ready.

http://< ip > /magento2/setup/
http://< localhost >/magento2/setup/

Schedule Magento2 Cronjobs

Finally schedule the backgound cronjobs for your magento2 installation. These cronjobs does some activities like, re-indexing, Newsletters, Update of currency rates, sending automatic emails and generating sitemaps etc. To schedule these jobs edit crontab file

$ crontab -e

and add below cronjobs at the end of file and save it.

*/1 * * * * apache php /var/www/html/magento2/bin/magento cron:run
*/1 * * * * apache php /var/www/html/magento2/update/cron.php
*/1 * * * * apache php /var/www/html/magento2/bin/magento setup:cron:run

Visit to phpmyadmin


Leave a Reply