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.
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 instance.com. You will have to substitute your FQDN anyplace you see instance.com.
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
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
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:
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 DATABASE magentodb; CREATE USER 'magentouser'@'localhost' IDENTIFIED BY 'PASSWORD'; GRANT ALL PRIVILEGES ON magentodb.* TO 'magentouser'@'localhost' IDENTIFIED BY 'PASSWORD'; FLUSH PRIVILEGES; exit
the place PASSWORD is a robust/distinctive password.
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 https://github.com/magento/magento2.git
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 instance.com
When the above command completes, the certificates shall be positioned in /and so forth/letsencrypt/stay/instance.com/ (the place instance.com is your FQDN).
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 instance.com along with your FQDN):
upstream fastcgi_backend server server
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).