How to install Magento with NGINX and Letsencrypt


Buy Organic Traffic | Cheap Organic Traffic | Increase Organic Traffic | Organic Traffic

When you’ve got a necessity for an e-commerce resolution in your information middle, look no additional than Magento. Learn the way to put in this versatile device on Ubuntu Server 18.04.

Picture: Jack Wallen

In immediately’s world, you can’t danger serving up your organization web sites with out further layers of safety. I’ve demonstrated how you can set up the Magento e-commerce resolution with Apache on Ubuntu Server 18.04 (See: The way to set up Magento on Ubuntu 18.04). That specific set up works fantastic, but it surely comes with a value: No Safe Sockets Layer (SSL).

I wish to stroll you thru one other path of set up, one that features HTTPS. This course of will go for NGINX (over Apache) and makes use of letsencrypt for SSL.

SEE: Catastrophe restoration and enterprise continuity plan (Tech Professional Analysis)

What you want

The one stuff you want for this set up are:

  • A Ubuntu Server 18.04 set up up and working.
  • A Absolutely Certified Area Identify (FQDN).
  • A consumer account with sudo privileges.

I’ll display the arrange utilizing the area You will have to substitute your FQDN anyplace you see

And with that, let’s set up.


First, replace and improve your server. Do word that, ought to the kernel be up to date within the course of, a restart of the server shall be required. Due to this, run the replace/improve course of throughout a time when an replace is feasible.

To run the replace/improve course of, log into your Ubuntu server and problem the next command:

sudo apt-update
sudo apt-get improve -y

Ought to your kernel be upgraded, reboot the server and prepare to put in.


Subsequent, we have to set up the NGINX internet server. Again at your terminal window, problem the next command:

sudo apt-get set up nginx -y

As soon as the set up completes, begin and allow the net server with the next instructions:

sudo systemctl begin nginx
sudo systemctl allow nginx

PHP elements

There are a variety of PHP elements that should be put in. In an effort to do that, first set up a third-party repository. Do that with the next instructions:

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

Set up the PHP elements with the command:

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

Earlier than persevering with, PHP should be configured. There are two recordsdata that should be modified:

  • /and so forth/php/7.1/fpm/php.ini
  • /and so forth/php/7.1/cli/php.ini

For every file, make the next configuration edits:

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

Restart and allow PHP FPM with the next instructions:

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

MySQL server

Magento relies upon upon the MySQL server. Set up this bundle with the command:

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

Begin and allow the service with the instructions:

sudo systemctl begin mysql
sudo systemctl allow mysql

Safe the MySQL set up with the command:

sudo mysql_secure_installation

Be certain that to create a robust/distinctive password for the MySQL admin consumer and reply “sure” for the remaining questions.

It is time to create the required database. Log onto the MySQL immediate with the command:

sudo mysql -u root -p

Create the database and a brand new consumer with the instructions:

CREATE USER 'magentouser'@'localhost' IDENTIFIED BY 'PASSWORD';
GRANT ALL PRIVILEGES ON magentodb.* TO 'magentouser'@'localhost' IDENTIFIED BY 'PASSWORD';

the place PASSWORD is a robust/distinctive password.

PHP composer

PHP Composer should even be put in. For this, problem the command:

sudo apt set up composer -y

Clone and set up Magento

Let’s seize the newest model of Magento. To do that, first set up git (if not already put in) with the command:

sudo apt-get set up git -y

Clone Magento with the command:

git clone

Grow to be the newly created listing with the command cd magento2 and set up Magento with the command:

sudo composer set up -v


It is now time to generate our SSL certificates. Earlier than we will do that, we should first set up Letsencrypt. Do that with the command:

sudo apt set up letsencrypt -y

After that set up completes, cease NGINX with:

sudo systemctl cease nginx

Generate the SSL certificates with the command:

sudo certbot certonly --standalone -d

When the above command completes, the certificates shall be positioned in /and so forth/letsencrypt/stay/ (the place is your FQDN).

Configure NGINX

Create a brand new configuration file with the command:

sudo nano /and so forth/nginx/sites-available/magento

Paste the next into that file (bear in mind to exchange along with your FQDN):

upstream fastcgi_backend 



Save and shut that file.

Activate the newly created web site with the command:

sudo ln -s /and so forth/nginx/sites-available/magento /and so forth/nginx/sites-enabled/

Restart NGINX with the instructions:

sudo systemctl restart php7.1-fpm
sudo systemctl begin nginx

Lastly, change the possession of the magento2 listing with the command:

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

Now you can level your browser to https://FQDN (the place FQDN is your Absolutely Certified Area Identify) and end the Magento arrange, through the web-based device.

Able to serve

And that is all there may be to establishing the Magento e-commerce resolution with NGINX and SSL. Should you plan on promoting merchandise for your enterprise, you owe it to your organization and prospects to take action over a safe HTTP (in any other case you danger the integrity of your safety and status).

Additionally see

Buy Website Traffic | Cheap Website Traffic | Increase Website Traffic | Website Traffic

Source link