5

Can you please help me to solve the same problem.? I'm trying the magento 2 with nginx on my local environment. I'm getting a problem when trying to call my project for installation htttp://radianstore/setup on browser i can see only a gray color bar, when i check with firebug i can see the url following requests throwing 404 (http://localhost/radianstore/setup/index.php/navigation , /index.php/side-menu etc). But all css and js files are loading. I have tried the fix you suggested in git hub https://github.com/magento/magento2/issues/2504 , but no luck ..

my /var/www/html/radianstore/nginx.conf.sample

===================

root $MAGE_ROOT/pub;
index index.php;
autoindex off;
charset UTF-8;
error_page 404 403 = /errors/404.php;

location ~* ^/setup($|/) {
    root $MAGE_ROOT;
    location ~ ^/setup/index.php {
     fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        fastcgi_pass   fastcgi_backend;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
    location ~ ^/setup/(?!pub/). {
        deny all;
    }
    location ~ ^/setup/pub/ {
        add_header X-Frame-Options "SAMEORIGIN";
    }
}

location ~* ^/update($|/) {
    root $MAGE_ROOT;
    location ~ ^/update/index.php {
        fastcgi_split_path_info ^(/update/index.php)(/.+)$;
        fastcgi_pass   fastcgi_backend;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param  PATH_INFO        $fastcgi_path_info;
        include        fastcgi_params;
    }
    location ~ ^/update/(?!pub/). {
        deny all;
    }
    location ~ ^/update/pub/ {
        add_header X-Frame-Options "SAMEORIGIN";
    }
}
location / {
    try_files $uri $uri/ /index.php?$args;
}

location /pub/ {
    location ~ ^/pub/media/(downloadable|customer|import|theme_customization/.*\.xml) {
        deny all;
    }
    alias $MAGE_ROOT/pub/;
    add_header X-Frame-Options "SAMEORIGIN";
}

location /static/ {
    location ~ ^/static/version {
        rewrite ^/static/(version\d*/)?(.*)$ /static/$2 last;
    }

    location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
        add_header Cache-Control "public";
        add_header X-Frame-Options "SAMEORIGIN";
        expires +1y;

        if (!-f $request_filename) {
            rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
        }
    }
    location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
        add_header Cache-Control "no-store";
        add_header X-Frame-Options "SAMEORIGIN";
        expires    off;

        if (!-f $request_filename) {
           rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
        }
    }
    if (!-f $request_filename) {
        rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
    }
    add_header X-Frame-Options "SAMEORIGIN";
}

location /media/ {
    try_files $uri $uri/ /get.php?$args;

    location ~ ^/media/theme_customization/.*\.xml {
        deny all;
    }

    location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
        add_header Cache-Control "public";
        add_header X-Frame-Options "SAMEORIGIN";
        expires +1y;
        try_files $uri $uri/ /get.php?$args;
    }
    location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
        add_header Cache-Control "no-store";
        add_header X-Frame-Options "SAMEORIGIN";
        expires    off;
        try_files $uri $uri/ /get.php?$args;
    }
    add_header X-Frame-Options "SAMEORIGIN";
}
location /media/customer/ {
    deny all;
}

location /media/downloadable/ {
    deny all;
}
location /media/import/ {
    deny all;
}

===============================================

My project hosts conf in /etc/nginx/sites-available/ file name=>radianstore [Same as my project folder name]

=====================================================

upstream fastcgi_backend {
        server  unix:/var/run/php/php7.0-fpm.sock;
}
server {

        listen 80;
        server_name localhost;
        set $MAGE_ROOT /var/www/html/radianstore;
        set $MAGE_MODE developer;
        include /var/www/html/radianstore/nginx.conf.sample;
}

my nginx default conf file /etc/nginx/site-available/default

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

    # SSL configuration
    #
    # listen 443 ssl default_server;
    # listen [::]:443 ssl default_server;
    #
    # Note: You should disable gzip for SSL traffic.
    # See: https://bugs.debian.org/773332
    #
    # Read up on ssl_ciphers to ensure a secure configuration.
    # See: https://bugs.debian.org/765782
    #
    # Self signed certs generated by the ssl-cert package
    # Don't use them in a production server!
    #
    # include snippets/snakeoil.conf;

    root /var/www/html;

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

    server_name localhost;

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

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
    #
    #   # With php7.0-cgi alone:
        #fastcgi_pass 127.0.0.1:9000;
    #   # With php7.0-fpm:
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
            include fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /\.ht {
        deny all;
    }
}

======================================================== I have set the cgi.fix_pathinfo to 1 in php.ini configration : ubuntu 16.04 lts php 7.0 fpm nginx-1.10 mysql 5.6

Regards, Rithin

  • 1
    Post content from your nginx error log too please. It will be located at /var/log/nginx/error.log – Reena Parekh Dec 19 '16 at 7:57
  • @ReenaParekh There is no error. :( – Rithin Prabhakar Dec 19 '16 at 10:59
  • Check folder permissions please. I see a similar output sometimes when the folder permissions are not set properly. Provide 777 permission to var, pub and setup directories – Reena Parekh Dec 20 '16 at 7:03
  • @ReenaParekh i did that tried it's same. I created another project instance and installed through command line , but again the same problem clean urls are not working like localhost/magento2test/contactus or localhost/magento2test/privacypolicy . Actually problem is nginx not able to route the url correctly. Where in apcahe it works when we enable mod_rewire and set directory allowOveride all . – Rithin Prabhakar Dec 20 '16 at 12:22
  • oh yes, also note that magento2 doesn't work properly with localhost/xyz type of URLs. You will have to create a hosting entry for the same and a conf file in /etc/nginx/sites-enabled/ – Reena Parekh Dec 20 '16 at 12:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.