Skip to content

Instantly share code, notes, and snippets.

@ananth-iyer
Last active November 29, 2020 13:46
Show Gist options
  • Save ananth-iyer/e318d587157dd87093f43b5b6456852d to your computer and use it in GitHub Desktop.
Save ananth-iyer/e318d587157dd87093f43b5b6456852d to your computer and use it in GitHub Desktop.
Setup Nginx to work with Magento 2

Below is the M2 virtual hosts config file in /etc/nginx/sites-available/m2.m235p1.local.conf

server {
  listen 80;
  server_name m2.m235p1.local;

  set $MAGE_ROOT /var/www/html/m2235-p1;
  # set $MAGE_MODE production;

  include /var/www/html/m2235-p1/nginx.conf.sample;
}

In nginx.conf, inside http {} block

    fastcgi_buffers 32 32k;
    fastcgi_buffer_size 64k;

In hosts file

127.0.0.1 m2.m235p1.local

Now restart nginx service and open Magento 2 store.

Click on star if it helped you.

## SET DEFAULT fastcgi_backend GLOBAL IN nginx.conf
## Ubuntu/Debian path: /etc/nginx/nginx.conf
## In this example I am setting PHP 7.3 FPM
http {
upstream fastcgi_backend {
server unix:/var/run/php/php7.3-fpm.sock; # Here you can set default PHP backend as supported by your current PHP
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment