YouTube Icon

Code Playground.

Install Magento 2 on CentOS 7

CFG

Install Magento 2 on CentOS 7

Magento is a main endeavor class online business stage based on open-source innovation joining amazing highlights with adaptability and easy to understand interface. 

With highlights like Engaging Shopping Experiences, Flexible Modular Architecture and Enterprise-grade Scalability and Performance Magento is a foundation of decision for most online dealers. 

This is the principal post in the arrangement How to introduce and design Magento 2 on CentOS 7 . In this instructional exercise, we will walk you through the means of introducing Magento 2 on your CentOS 7 machine. 

Prerequisites

As the essentials to follow this instructional exercise, you will require: 

  • CentOS 7 worker, as per the authority Magento 2 framework necessities you need at any rate 2G of RAM. On the off chance that you are utilizing a worker with under 2GB of RAM, you ought to make a trade document . 
  • Signed in as a client account with sudo advantages . 
  • An area name highlighting your public worker IP. In this instructional exercise, we will utilize example.com. 
  • Introduced and designed Nginx, MySQL and PHP 7.1. On the off chance that you haven't, allude to our LEMP on CentOS 7 guide . 
  • A substantial SSL endorsement. In the event that you don't have one, you can make a free Lets' Encrypt SSL testament by following Secure Nginx with Let's Encrypt on CentOS 7 . 

Magento Access Key Pair

We need to produce access keys to validate admittance to the Magento 2 code store and outsider augmentations and subjects. 

In the event that you don't have a Magento Marketplace account, you can make one here . When you make the record, if you don't mind check these guidelines on the most proficient method to produce another arrangement of access keys. 

Create MySQL Database

Magento 2 is viable with MySQL 5.6 and 5.7, MariaDB 10.x and Percona 5.7. On the off chance that you don't have MySQL or MariaDB introduced on your worker you can check this guide . 

Login to the MySQL shell: 

mysql -u root -p

What's more, run the accompanying orders to make another information base and client and award advantages to that client over the recently made information base: 

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

Install PHP extensions

We expect that you have just empowered PHP 7.1 Remi vault utilizing our guide. 

Introduce all necessary PHP expansions with the accompanying order: 

sudo yum install php-mysql php-opcache php-xml php-mcrypt php-gd php-soap php-redis php-bcmath php-intl php-mbstring php-json php-iconv php-fpm php-zip

When the establishment is finished, set the required and suggested PHP alternatives by altering the php.ini record with sed : 

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

Install Composer

Writer is a reliance director for PHP which is utilized for introducing, refreshing and overseeing libraries. 

To introduce writer internationally, download the Composer installer with twist and move the document to the/usr/neighborhood/receptacle registry: 

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

Create a new System User

Make another client and gathering, which will run our Magento establishment, for effortlessness we will name our client magento: 

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

Add the nginx client to the magento gathering and change the/select/magento index authorizations with the goal that the Nginx can get to our Magento establishment: 

sudo usermod -a -G magento nginx
sudo chmod 750 /opt/magento

Configure PHP FPM

Next, we need to arrange PHP and make a FPM pool for our magento client. 

Open your word processor and make the accompanying record: 

/etc/php-fpm.d/magento.conf

[magento]
user = magento
group = nginx
listen.owner = magento
listen.group = nginx
listen = /run/php-fpm/magento.sock
pm = ondemand
pm.max_children =  50
pm.process_idle_timeout = 10s
pm.max_requests = 500
chdir = /

Save the record and restart the PHP FPM administration for changes to produce results: 

sudo systemctl restart php-fpm
Install Magento

There are a few different ways to introduce Magento. Try not to introduce Magento from the Github storehouse since that adaptation is expected for advancement and not for creation establishments. In this instructional exercise, we will introduce Magento from their vaults utilizing author. 

Switch over to the client magento: 

sudo su - magento

Start the establishment by downloading magento records to the/select/magento/public_html catalog: 

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

During the venture creation, the author will request that you enter the entrance keys, duplicate the keys from your Magento commercial center record and store them in the auth.json document, so later when refreshing your establishment you don't need to add similar keys once more. 

    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]

 

When the venture is made we can begin the establishment. We can introduce Magento either by utilizing the order line or utilizing the web Setup Wizard. In this instructional exercise, we will introduce Magento utilizing the order line. 

We will utilize the accompanying alternatives to introduce our Magento store: 

Base a lot secure URLs are set to https://example.com, transform it with your area. 

Magento chairman: 

John Doe as first and last name. 

john@example.com as email. 

john as username and j0hnP4ssvv0rD as a secret phrase. 

Information base name magento, username magento, secret word P4ssvv0rD, and the data set worker is on a similar host as the web worker. 

en_US, US English as default language. 

USD dollars as default cash. 

America/Chicago as a time region. 

You can discover all the establishment alternatives here . 

Change to the Magento ~/public_html index: 

hn@example.com" \
                        --admin-user="john" \
                        --admin-password="j0hnP4ssvv0rD" \
                        --db-name="magento" \
                        --db-host="localhost" \
                        --db-user="magento" \
                        --currency=USD \
                        --timezone=America/Chicago \
                        --use-rewrites=1 \
                        --db-password="P4ssvv0rD"

Remember to change the secret key (j0hnP4ssvv0rD) to something safer. 

On the off chance that the establishment is fruitful you will be given a message that contains the URI to the Magento administrator dashboard. 

[Progress: 485 / 485]
[SUCCESS]: Magento installation complete.
[SUCCESS]: Magento Admin URI: /admin_1csalp
Nothing to import.

Create the Magento crontab

Magento utilizes cron responsibilities to plan assignments like re-ordering, warnings, sitemaps, messages and then some. 

To make the Magento crontab run the accompanying order as magento client: 

php ~/public_html/bin/magento cron:install

We can confirm that the crontab is introduced by running: 

crontab -l
#~ 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
#~ MAGENTO END adc062915d7b30804a2b340095af072d

Configure Nginx

On the off chance that you followed our LEMP on CentOS 7 guide you should as of now have Nginx introduced on your machine. Presently we just need to make another worker block for our Magento establishment. We will incorporate the default Nginx arrangement sent with magento: 

/etc/nginx/conf.d/example.com.conf

upstream fastcgi_backend {
  server   unix:/run/php-fpm/magento.sock;
}

server {
    listen 80;
    server_name example.com www.example.com;

    include snippets/letsencrypt.conf;
    return 301 https://example.com$request_uri;
}

server {
    listen 443 ssl http2;
    server_name www.example.com;

    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/example.com/chain.pem;
    include snippets/ssl.conf;

    return 301 https://example.com$request_uri;
}

server {
    listen 443 ssl http2;
    server_name example.com;

    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/example.com/chain.pem;
    include snippets/ssl.conf;

    set $MAGE_ROOT /opt/magento/public_html;
    set $MAGE_MODE developer; # or production

    access_log /var/log/nginx/example.com-access.log;
    error_log /var/log/nginx/example.com-error.log;

    include /opt/magento/public_html/nginx.conf.sample;
}

Reload the Nginx administration for changes to produce results: 

sudo systemctl reload nginx

At long last, you should have the option to login to your Magento establishment at https://example.com/admin_1csalp utilizing the administrator client you indicated when you run the Magento installer. 

Conclusion

In this instructional exercise, you introduced Magento 2 on your Centos 7 worker. You have likewise produced a free Let's e




CFG