How to Install Magento 2 on CentOS 7

How to Install Magento 2 on CentOS 7

 What is Magento?
A Magento is an e-commerce platform built on Opensource technology which provides online merchants with a flexible shopping cart system, as well as control over the look. content and functionality of their online store. Magento offers powerful marketing, search engine optimization, and catalog-management tools. We believe that Magento is one of the best e-commerce platforms available today.

First you install lamp with Magento requiement package.
Install and configure Apache Server.

#yum -y install httpd

Verify the installation:

# httpd -v
Output:-
Server version: Apache/2.2.15 (Unix)
Server built: Oct 16 2014 14:48:21

Open the following file for editing.

# vim /etc/httpd/conf/httpd.conf

Locate the block that starts with:
<Directory /var/www/html>
Change the value of AllowOverride to <value from Apache site>.

<Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride <value from Apache site>
    Order allow,deny
    Allow from all
<Directory>

Save and restart apache service with below command.

# sudo service httpd restart

Install and configure MySQL 5.7 on CentOS 7
Enter the following commands in the order
show:-

# yum -y update

# wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm && sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm

# yum -y install mysql-server

# service mysqld start

Verify the version with given command.   

#mysql --version
Output:-
mysql  Ver 14.14 Distrib 5.7.12, for Linux (x86_64) using  EditLine wrapper

Secure the installation:

# mysql_secure_installation

Also See:-  How to reset Mysql Root password

Create a MYSQL Database

Magento 2 is compatible with MySQL 5.6 and 5.7, MariaDB 10.x and Percona 5.7.

Login to the MySQL shell with below command:-

# mysql -u root -p

And run the following commands to create a new database and user and grant privileges to that user over the newly created database.

mysql> CREATE DATABASE magento
mysql> GRANT ALL ON magento * TO magento@localhost IDENTIFIED BY 'P4ssvv0rD';

That's it!  Database
There is more than one way to install PHP 7.1 on CentOS
magento successfully created.

Install PHP 7.1 with  php extension on centos 

Enter the following command with centos 7.

# yum install -y http://dl.iuscommunity.org/pub/ius/stable/CentOS/7/x86_64/ius-release-1.0-14.ius.centos7.noarch.rpm
# yum -y update

Install all required PHP extensions.

# yum -y install php71u php71u-pdo php71u-mysqlnd php71u-opcache php71u-xml php71u-gd php71u-devel php71u-mysql php71u-intl
php71u-mbstring php71u-bcmath php71u-json php71u-iconv php71u-soap

Once the installation is complete, set the required PHP options.

# sed -i "s/memory_limit = .*/memory_limit = 756M/" /etc/php.ini
# sed -i "s/upload_max_filesize = .*/upload_max_filesize = 256M/" /etc/php.ini
# sed -i "s/zlib.output_compression = .*/zlib.output_compression = on/" /etc/php.ini
# sed -i "s/max_execution_time = .*/max_execution_time = 18000/" /etc/php.ini
# sed -i "s/;date.timezone.*/date.timezone = UTC/" /etc/php.ini
# sed -i "s/;opcache.save_comments.*/opcache.save_comments = 1/" /etc/php.d/10-opcache.ini

Install composer
Composer is a dependency manager for PHP which is used for installing, updating and managing libraries.

# curl -sS https://getcomposer.org/installer | php
# mv composer.phar /usr/local/bin/composer

Create a new system user.

# useradd -m -U -r -d /opt/magento magento

Add the apache user to the magento group and change the /opt/magento directory permissions so that the apache access our magento installation.

# usermod -a -G magento apache
# chmod 750 /opt/magento

Configure Php Fpm
Open your text editor and create the following file.

# cd /etc/php-fpm.d/magento.conf
[magento]
user = apache
group = apache
listen.owner = magento
listen.group = apache
listen = /run/php-fpm/magento.sock
pm = ondemand
pm.max_children =  50
pm.process_idle_timeout = 10s
pm.max_requests = 500
chdir = /

Save the file and restart the PHP FPM service

# systemctl restart php-fpm

Install magento:
Switch over to the
magento user with given command.

# sudo su - magento

Start the installation by downloading magento files to the /opt/magento/public_html directory.

# composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition /opt/magento/public_html

During the project creation, the composer will ask you to enter the access keys, copy the keys from your Magento official website.

Authentication required (repo.magento.com):
      Username: e758ec1745d190520ca246e4e832e12c
      Password:

Do you want to store credentials for repo.magento.com in /opt/magento/.config/composer/auth.json ? [Yn] y
Once the project is created we can start the installation

 

Set file permissions.

# cd /var/www/html/<magento install directory>
# find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
# find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +
# chown -R apache:apache
# chmod u+x bin/magento

If the installation is successful then you will set selinux
selinux=disabled
Create the
magento
crontab.

#~ MAGENTO START adc062915d7b30804a2b340095af072d
* * * * * /usr/bin/php /opt/magento/public_html/bin/magento cron:run 2>&1 | grep -v "Ran jobs by schedule" >> /opt/magento/public_html/var/log/magento.cron.log
* * * * * /usr/bin/php /opt/magento/public_html/update/cron.php >> /opt/magento/public_html/var/log/update.cron.log
* * * * * /usr/bin/php /opt/magento/public_html/bin/magento setup:cron:run >> /opt/magento/public_html/var/log/setup.cron.log

 

That's it!   Thanks for visit hostingride
ALSO VISIT
How to install Apache server on Centos
How to install and configure Git on centos 7
How to clear cache Laravel

 

  

Blog type: 

Add new comment

Authored By

swati sharma

Am working in HCL since 2 yr. i am RHCE certified engineer, working since 4 yr as a Network Admin.

Follow us on

Facebook​  Twitter  LinkedIn  Google+