In a new installation of Magento (Ubuntu LEMP) I'm unable to access the admin page.

Error.log says:

2014/08/20 12:04:30 [error] 7404#0: *6 rewrite or internal redirection cycle while processing "/index.php",

My site config file looks like this:

server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;

        root /var/www;
        index index.php index.html index.htm;

        server_name localhost;

location / {
        index index.html index.php; 
        try_files $uri $uri/ @handler; 
        expires 30d; 

    ## These locations would be hidden by .htaccess normally
    location ^~ /app/                { deny all; }
    location ^~ /includes/           { deny all; }
    location ^~ /lib/                { deny all; }
    location ^~ /media/downloadable/ { deny all; }
    location ^~ /pkginfo/            { deny all; }
    location ^~ /report/config.xml   { deny all; }
    location ^~ /var/                { deny all; }

    location /var/export/ { 
        auth_basic           "Restricted";           
        auth_basic_user_file htpasswd; 
        autoindex            on;

    location  /. { 
        return 404;

    location @handler { 
        rewrite / /index.php;

    location ~ .php/ { 
        rewrite ^(.*.php)/ $1 last;


        location ~ \.php$ {
                if (!-e $request_filename) { rewrite / /index.php last; } 
                expires        off; ## Do not cache dynamic content
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_param  MAGE_RUN_CODE default; 
                fastcgi_param  MAGE_RUN_TYPE store;
                include fastcgi_params;

It's been quite hard to install Magento with nginx and during installation there were problems with file permissions. So not sure if it may have something to do with it.

  • Have you looked at stackoverflow.com/questions/11951816/… ?
    – JasonS
    Commented Aug 20, 2014 at 16:55
  • @JasonS Thanks for the link but the solution suggested is already implemented in my virtual host nginx conf file. I'll edit my original post with the conf file
    – cortopy
    Commented Aug 20, 2014 at 18:46

1 Answer 1


I was finally able to sort this mess. Although I hadn't tried it, reading this other post error 404 after login to admin, nginx and index.php issue, how to solve made me realised that there may be something wrong with index.php

After being able to log in via the weird XXX.com/index.php/admin I moved installation from /magento to root public directory. When I did this, I could see nginx was still serving index.html because in my vhost nginx configuration I had index.html before index.php in case there's need to serve a static landing page in the future.

The tricky index.html was still there from previous testing with nginx root folders. I deleted index.html (as it was just the default nginx file saying nginx works). And this did the trick


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.