How to Install Magento nginx – Part 02

Before we continue our Part 02 on installing Magento ngnix, we must mention something very important. Right after the MySQL installation & configuration, we’ll need to setup Magento for processing further with nginx. So, if you have question on both of these topics hope you guys will might find our previous articles helpful. Just follow the links to do so.

Join us before Jan 10th 2018 to enjoy a 28% straight discount in your first invoice. So, enjoy an X-mas bonus from Aspiration hosting. Get your Promo Code now!!!                          

Tanzia Farin Chy – Aspiration Hosting  

Magento nginx

Here now we want to move straight to our topic. Also we’d like to mention that we prefer to use nginx.conf.sample file while editing nginx. Basically the file comes under Mage installation DIR and Magento nginx virtual host.
However we made an assumption about the default location of Ubuntu 16. For example following is the path Ubuntu 16 use as default:
Next Ubuntu 16 using the following path as their docroot:
By the way, we’ve have full access to change the default paths as per requirement. To avoid the complexity of the topic we’ll not discuss the topic further.

Magento nginx – Creating a virtual host

  • First find the below path and put on the following configuration to create a virtual host.
    vim /etc/nginx/sites-available/magento.
    Right after use these following config:
upstream fastcgi_backend {
server unix:/run/php/php7.0-fpm.sock;
server {
listen 80;
set $MAGE_ROOT /var/www/html/magento2;
include /var/www/html/magento2/nginx.conf.sample;
  • Secondly to include the directive in a Mage installation DIR, we need to point to the sample Magento nginx CONFIG file. Next we’ll replace our domain name with Because while installing Mage the URL should match the base URL.
  • Finally click save to exit the text editor.

Magento nginx – Activating the new virtual host

  • Simply activate the newly created virtual host just by creating a symlink. Now, navigate through path /etc/nginx/sites-enabled DIR and create the symlink.
  • By opening command prompt and enter following:
    ln -s /etc/nginx/sites-available/magento /etc/nginx/sites-enabled.
  • Thirdly verify the syntax by using the following commands:
    nginx -t.
  • Now restart nginx using following commands to complete the setup.
    systemctl restart nginx.

Finally we’ll need to open a web browser and by visiting the site’s base URL we can ensure the correct installation.

Currently viewing Part 02 | Part 01