0

Magento is a extensively used Open Supply e-commerce software program and content material administration system for e-commerce web sites based mostly on the PHP Zend Framework. It makes use of MySQL or MariaDB as database backend. The Magento growth has been began in 2008 by Varien.

On this tutorial, I’ll present you learn how to set up Magento 2 with Nginx, PHP 7.1 FPM, and MySQL because the database. I’ll use ubuntu 18.04 (Bionic Beaver) as server working system. If you do not have a minimal server setup but, please see this tutorial to get a correct base setup.

Stipulations

  • Ubuntu 18.04
  • 2GB or extra RAM reminiscence
  • Root privileges

What we are going to do

  1. Set up Nginx on Ubuntu 18.04
  2. Set up and Configure PHP-FPM 7.1
  3. Set up and Configure MySQL Server
  4. Set up and Configure Magento 2
    1. Set up PHP Composer
    2. Obtain Magento 2
    3. Set up Magento Parts
    4. Generate SSL Letsencrypt
    5. Configure Nginx Digital Host for Magento
    6. Magento Publish-Set up
  5. Testing

Step 1 – Set up Nginx on Ubuntu 18.04 LTS

On this tutorial, we will probably be utilizing the Nginx net server for our Magento set up.

Log in to the server, replace the repository, and improve all packages.

sudo apt replace
sudo apt improve

Now set up the Nginx net server utilizing the apt command beneath.

sudo apt set up nginx -y

After the set up is full, begin the Nginx service and allow it to launch each time at system boot.

systemctl begin nginx
systemctl allow nginx

Nginx net server has been put in, test it utilizing netstat command and ensure the HTTP port 80 is on the ‘LISTEN’ state. One other manner is by utilizing curl command as beneath.

netstat -plntu
curl -I localhost

Install Nginx web server

Step 2 – Set up and Configure PHP-FPM 7.1

After the Nginx net server set up, we are going to set up PHP 7.1 on the server as Magento doesn’t help PHP 7.2 but. We’ll set up PHP-FPM with all extensions wanted by Magento 2.

Checklist of PHP extensions wanted for Magento 2 set up:

  • bc-math
  • ctype
  • curl
  • dom
  • gd, ImageMagick 6.3.7 (or later) or each
  • intl
  • mbstring
  • mcrypt
  • hash
  • openssl
  • PDO/MySQL
  • SimpleXML
  • cleaning soap
  • spl
  • libxml
  • xsl
  • zip
  • json
  • iconv

For this information, we are going to set up PHP-FPM packages from the PPA repository. We will probably be utilizing the ‘ondrej/php’ repository.

Set up the ‘software-properties-common’ bundle and add the ‘ondrej/php’ repository utilizing instructions beneath.

sudo apt set up software-properties-common -y
sudo add-apt-repository ppa:ondrej/php -y

Install PHP 7.1

Now set up PHP-FPM 7.1 with all extensions wanted.

sudo apt set up php7.1-fpm php7.1-mcrypt php7.1-curl php7.1-cli php7.1-mysql php7.1-gd php7.1-xsl php7.1-json php7.1-intl php-pear php7.1-dev php7.1-common php7.1-mbstring php7.1-zip php7.1-soap php7.1-bcmath -y

After the set up is full, test the PHP model and put in extensions utilizing PHP instructions.

php -v
php -me

Check PHP installation

Subsequent, we are going to configure the php.ini file for the PHP-FPM and PHP-CLI.

Edit the php.ini recordsdata utilizing vim.

vim /and so on/php/7.1/fpm/php.ini
vim /and so on/php/7.1/cli/php.ini

Change the worth of these traces as beneath.

memory_limit = 512M
 max_execution_time = 180
 zlib.output_compression = On

Save and exit.

Now restart the PHP-fpm service and allow it to launch each time at system boot.

systemctl restart php7.1-fpm
systemctl allow php7.1-fpm

The PHP-FPM 7.1 set up and configuration has been accomplished, test the service utilizing netstat command.

netstat -pl | grep php

And you’re going to get the PHP-fpm socks file as beneath.

Check PHP-FPM socket

Step 3 – Set up and Configure MySQL Server

The Magento software program requires MySQL 5.6.x, and the Magento 2.1.2 or later require the MySQL 5.7.x. On this tutorial, we are going to set up newest MySQL server 5.eight on the Ubuntu 18.04 system.

Set up MySQL 5.eight utilizing the apt command beneath.

sudo apt set up mysql-server mysql-client -y

After the set up is full, begin the MySQL service and allow it to launch each time at system boot.

systemctl begin mysql
systemctl allow mysql

Now we are going to configure the MySQL root password utilizing ‘mysql_secure_installation’ command.

mysql_secure_installation

On this MySQL 5.eight model, there’s a safety enchancment for the MySQL password coverage. It’s worthwhile to select the password coverage – zero for the LOW coverage, 1 for the MEDIUM coverage, and a pair of for a STRONG password coverage.

For this information, we will probably be utilizing the ‘MEDIUM’ password coverage, and it is really useful to make use of the ‘STRONG’ password coverage on the manufacturing server.

Select quantity ‘1’ and press Enter, then sort your new MySQL ‘root’ password.

Secure MySQL installation

 Take away nameless customers? (Press y|Y for Sure, another key for No) : Y
Disallow root login remotely? (Press y|Y for Sure, another key for No) : Y
Take away take a look at database and entry to it? (Press y|Y for Sure, another key for No) : Y
Reload privilege tables now? (Press y|Y for Sure, another key for No) : Y

The MySQL root password has been arrange.

Subsequent, we are going to create a brand new database for our Magento set up. We’ll create a brand new database named  ‘magentodb’ with person ‘magentouser’ and the password is ‘[email protected]#’.

Login to the MySQL shell utilizing the foundation person.

mysql -u root -p

Now run MySQL queries beneath to create the database and person.

create database magentodb;
create person [email protected] recognized by ‘[email protected]#’;
grant all privileges on magentodb.* to [email protected] recognized by ‘[email protected]#’;
flush privileges;

The MySQL server set up and configuration for the Magento set up has been accomplished.

Create MySQL database and user for Magento

Step 4 – Set up and Configure Magento 2

On this step, we are going to set up Magento 2.2.Four newest model from Github repository. We’ll set up the PHP composer for putting in the Magento elements, obtain Magento from Github repository, configure Nginx digital host for Magento, and set up Magento utilizing the web-based put up set up.

– Set up PHP Composer

Set up PHP Composer on ubuntu 18.04 utilizing the apt command beneath.

sudo apt set up composer -y

After the set up is full, test the composer model put in on the system.

composer -V

Install PHP composer

The most recent model PHP Composer has been put in.

– Obtain Magento 2

Go to the ‘/var/www’ listing and obtain the Magento archive supply code from Github utilizing wget command.

cd /var/www/
wget https://github.com/magento/magento2/archive/2.2.4.tar.gz

Now extract the Magento archive file and rename the listing to ‘magento2’.

tar -xf 2.2.4.tar.gz
mv magento2-2.2.4/ magento2/

The Magento supply code has been downloaded, and the ‘/var/www/magento2’ listing would be the net root for the Magento web site.

– Set up Magento Parts

Set up Magento elements utilizing the PHP composer. Go to the ‘magento2’ listing and set up all of the PHP elements wanted by Magento utilizing the ‘composer’ command.

cd /var/www/magento2
composer set up -v

After the set up is full, you’re going to get the outcome as proven beneath.

Check composer version

– Generate SSL Letsencrypt

We’ll safe our Magento set up utilizing SSL from Letsencrypt. Set up the Letsencrypt utilizing the apt command beneath.

sudo apt set up letsencrypt -y

After the set up is full, cease the nginx service.

systemctl cease nginx

Now generate the SSL certificates for the area identify utilizing certbot command as beneath.

certbot certonly –standalone -d magento.hakase-labs.pw

Kind your e-mail deal with, settle for the Letsencrypt TOS, then sort ‘N’ for e-mail sharing.

Enable Let's encrypt SSL certificate

When it is full, you’re going to get the outcome as beneath.

SSL cert issues successfully

The Letsencrypt SSL certificates recordsdata have been generated to the ‘/and so on/letsencrypt/stay’ listing.

– Configure Nginx Digital Host

Go to the ‘/and so on/nginx/sites-available’ listing and create new digital host file ‘magento’ utilizing vim.

cd /and so on/nginx/sites-available/
vim magento

Paste the next configuration there.

upstream fastcgi_backend {
         server  unix:/run/php/php7.1-fpm.sock;
 }
 
 server {
     pay attention 80;
     pay attention [::]:80;
     server_name magento.hakase-labs.pw;
     return 301 https://$server_name$request_uri;
 }
 
 server {
 
         pay attention 443 ssl;
         server_name magento.hakase-labs.pw;
 
         ssl on;
         ssl_certificate /and so on/letsencrypt/stay/magento.hakase-labs.pw/fullchain.pem;
         ssl_certificate_key /and so on/letsencrypt/stay/magento.hakase-labs.pw/privkey.pem;
 
         set $MAGE_ROOT /var/www/magento2;
         set $MAGE_MODE developer;
         embrace /var/www/magento2/nginx.conf.pattern;
 }

Save the configuration and exit.

Now activate the digital host by creating the symbolic hyperlink for the Magento digital host file to the ‘sites-enabled’ listing.

ln -s /and so on/nginx/sites-available/magento /and so on/nginx/sites-enabled/

Check nginx configuration file and ensure there isn’t any error.

nginx -t

Now restart the PHP-FPM and Nginx service.

systemctl restart php7.1-fpm
systemctl restart nginx

And alter the proprietor of Magento web-root listing to the ‘www-data’ person and group.

chown -R www-data:www-data /var/www/magento2/

The nginx digital host for Magento has been added.

– Magento Publish-Set up

Open the net browser and sort the Magento URL. Mine is:

https://magento.hakase-labs.pw/

For the ‘Phrases and Settlement’, click on the ‘Agree and Setup Magento’ button.

Magento web installer

Now test all system and server configuration for Magento ‘Readlines Examine’, and ensure it ‘passes’ all system and configuration test as beneath.

Check prerequisites

Now click on ‘Subsequent’ button.

Database configuration for Magento – sort all our database data and click on ‘Subsequent’.

Database configuration

For the net configuration, change the ‘retailer deal with’ to HTTPS, ‘Magento Admin Deal with’ along with your admin path URL and uncheck the ‘Apache Rewrites’, as a result of we’re utilizing the Nginx net server.

Web configuration

Click on the ‘Subsequent’ button once more.

Depart the ‘Customise Your Retailer’ as default and click on ‘Subsequent’.

Customize Magento store

Kind your admin person and password, then click on ‘Subsequent’.

Setup the admin account

And click on ‘Set up Now’ button to put in Magento.

Start Magento installation

And when set up is full, you’re going to get the ‘success’ outcome as beneath.

Magento installation successful

Now we have to disable write entry for the ‘/var/www/magento2/app/and so on’ listing. Run the command beneath.

sudo chmod -w /var/www/magento2/app/and so on

Magento has been put in on to the Ubuntu 18.04 Bionic Beaver server.

Step 5 – Testing

Kind the Magento URL residence deal with and ensure you get the Magento default residence web page. Mine is: https://magento.hakase-labs.pw/

Magento homepage

Now login to the Magento admin dashboard by visiting the URL outlined through the set up ‘admin_hakase’. Mine is:

https://magento.hakase-labs.pw/admin_hakase/

Magento backend login

Kind the username and password, then click on the ‘Register’ button.

And you’re going to get the Magento admin dashboard as beneath.

Magento dashboard

Magento 2 has been put in on Ubuntu 18.04 with Nginx net server, MySQL database, and PHP-FPM 7.1.

Further:

In the event you get an error a few lacking Magento indexer cronjob, then you possibly can clear up it by producing the crontab script utilizing the command beneath.:

cd /var/www/magento2
sudo -u www-data php bin/magento cron:set up –force

Now test the listing crontab script for the ‘www-data’ person.

crontab -u www-data -l

Setup Magento indexer cronjob

Examples of Unorthodox Cellular App Designs

Previous article

Six Conversion-Boosting Web Design Tips

Next article

You may also like

Comments

Leave a reply

Your email address will not be published. Required fields are marked *

More in Apache