I'm going to try and make this as detailed as possible because I feel like I've tried everything and at this point just need another set of eyes on everything.

I'm running a cloud server and I've installed my LAMP stack via terminal. Additionally, this is a magento build. I've migrated all files to the proper folder. var/www/html and I've installed mysql and imported my DB.

I'm currently able to run mywebsite.com/info.php

tki@me:/$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
tki@me:/$ ls -al /etc/nginx/sites-enabled/
total 8
drwxr-xr-x 2 root root 4096 Feb  6 18:44 .
drwxr-xr-x 6 root root 4096 Feb  6 18:03 ..
lrwxrwxrwx 1 root root   34 Feb  4 15:48 default -> /etc/nginx/sites-available/default
tki@me:/$ sudo lsof -i -P | grep -i "listen"
sendmail-  1084               root    3u  IPv4  14208      0t0  TCP localhost:25 (LISTEN)
sendmail-  1084               root    5u  IPv4  14209      0t0  TCP localhost:587 (LISTEN)
sshd       1122               root    3u  IPv4  14322      0t0  TCP *:22 (LISTEN)
sshd       1122               root    4u  IPv6  14331      0t0  TCP *:22 (LISTEN)
mysqld    14732              mysql   19u  IPv4  76527      0t0  TCP localhost:3306 (LISTEN)

Here is my sites-available/default

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/html;
    index index.php index.html index.htm index.nginx-debian.html;   

    # Add index.php to the list if you are using PHP
    #index index.html index.htm index.nginx-debian.html;

    #server_name server_domain_or_IP;
     server_name mysite.com;
    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ =404;

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;

    location ~ /\.ht {
        deny all;

Here is my nginx.conf file:

user www-data;
worker_processes auto;
pid /run/nginx.pid;

events {
    worker_connections 768;
    # multi_accept on;

http {

    # Basic Settings

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;
    # fastcgi_param  MAGE_RUN_CODE default;
    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    # SSL Settings

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    gzip on;
    gzip_disable "msie6";

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;

Is there anything blatantly obvious that's wrong with my configurations?

1 Answer 1


If that Nginx configuration is for Magento 2 (you didn't specify which version of Magento is) then you should include into your:


this configuration:

nginx config for magento2

the best approach is to create an additional file and include it into your server defaul.

Update Answer

Crossed myself this problem couple days ago.

It was happening because these variables were receiving the following values from Nginx:

/* Store or website code */
$mageRunCode = 'default';

/* Run store or run website */
$mageRunType = 'store';

while my default customer store was english.

After carefully checking the configuration and passing the right values from Nginx:

set $MAGE_RUN_CODE english;
set $MAGE_RUN_TYPE store;

I went into the PHP-FPM configuration file, the one where the fastcgi params are passed further and had the surprise to find the values wrong hardcoded:

fastcgi_param  MAGE_RUN_CODE 'defaul'
fastcgi_param  MAGE_RUN_TYPE 'store';

In fact it should have been these:

fastcgi_param  MAGE_RUN_CODE $MAGE_RUN_CODE;
fastcgi_param  MAGE_RUN_TYPE $MAGE_RUN_TYPE;

Which allows you to pass the upper defined value from Nginx to Magento.

So in your case I would have a look in this file:

include snippets/fastcgi-php.conf;

you have it in your nginx conf.

  • It's not for magento 2, sorry that i didn't specify. I'll add that now.
    – Head Way
    Feb 11, 2017 at 18:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.