Skip to main content

INSTALLING MAGENTO 2.X ON CENTOS 6/7


Here iam installing magento 2.1.1 on centos 6.9.
For magento prerequisites visit:
Here iam using apache 2.2.15 php 7.0 and mysql-community-server 5.6

First install apache
#yum install httpd

Go it apache configuration file and make sure AllowOverride directive is set to All
#vi /etc/httpd/conf/httpd.conf
AllowOverride All

Now install mysql-community-server.For that first create a mysql-community-server repo
#cd /etc/yum.repos.d/
#vi mysql.repo
------------------------------------------------------------------------------------------------------------------------------------------
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

--------------------------------------------------------------------------------------------------------------

For centos 7 use:
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
-----------------------------------------------------------------------------------------------------------------------------------------

#yum update
#yum install mysql-community-server
#service mysqld start
#cat /var/log/mysqld.log | grep temporay (we will get temporary password for root login)
>mysql -u root -p
>Set password for root@localhost = ‘newpassword’
>Create database magento;
>grant all on magento.* to root@localhost identified by 'REDhat@123';
>flush privileges;
>exit;
Now install php7.0
#wget http://dl.iuscommunity.org/pub/ius/stable/CentOS/6/x86_64/ius-release-1.0-14.ius.centos6.noarch.rpm -P /tmp
for centos7 use:
#wget http://dl.iuscommunity.org/pub/ius/stable/CentOS/7/x86_64/ius-release-1.0-14.ius.centos6.noarch.rpm -P /tmp


#yum localinstall /tmp/ius-release-1.0-14.ius.centos6.noarch.rpm
#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 php70u-soap

Edit php.ini file
#vi /etc/php.ini
memory limit=2G

Installing Composer:
To install composer simply run the following command:
#curl -sS https://getcomposer.org/installer | php
The above command will download the latest version of the composer.phar file in your home directory.
To use composer, you will need to move it to /usr/bin/ directory:
#mv composer.phar /usr/bin/composer
We can verify the version of the composer with the following command:
#composer -V


First, download the Magento with the git command:
#yum install git -y
#cd /var/www/html/
#git clone https://github.com/magento/magento2.git
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.
#cd magento2
#git checkout tags/2.1.0 -b 2.1.0
The above command will checkout to a stable version 2.1.0.

Move all the installation files to document root of Apache:
#shopt -s dotglob nullglob
#mv /var/www/html/magento2/* /var/www/html/
we will also need to set proper permissions to the files and folders of Magento:
#chown -R apache:apache /var/www/html/
#chmod -R 775 /var/www/html/
Install Magento using the following command:
#cd /var/www/html
#composer install

Now go to browser http://your ip












We will need to setup some cron jobs for Magento.
#crontab -u apache -e
Add the following lines:
*/5 * * * * php -c /etc /var/www/html/bin/magento cron:run
*/5 * * * * php -c /etc /var/www/html/update/cron.php
*/5 * * * * php -c /etc /var/www/html/bin/magento setup:cron:run
Save the file when you are finished.