0

I just installed Nginx with PHP 7.1-fpm on Ubuntu 16.04 and I have a problem. When I wan to visit for example http://example.dev it downloads index.php instead of showing homepage, but for example http://example.dev/registration works well.

This is my nginx config:

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

    root /var/www/example/www;

    index index.php index.html;

    server_name example.dev;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ /\. {
        access_log off;
        log_not_found off;
        deny all;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/run/php/php7.1-fpm.sock;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }
}

Thanks for your answers.

5
  • Try moving ` location / { try_files $uri $uri/ /index.php?$args; }` to the end Commented Aug 19, 2017 at 17:02
  • have you set 'cgi.fix_pathinfo' in php.ini file ? Commented Aug 19, 2017 at 17:21
  • @TarunLalwani I tried it but it didn't help. Commented Aug 19, 2017 at 17:49
  • @AshishTiwari Yes Commented Aug 19, 2017 at 17:50
  • Does http://example.dev and http://example.dev/ both result in download of index.php file? Commented Aug 19, 2017 at 17:57

1 Answer 1

3

Sometimes it can be as simple as clearing the browser cache. If there was some misconfiguration and it was indeed downloading files, after fixing the config the browser needs to be told to stop using the cached download.

Try Ctrl+Shift+R in your browser.

(From: https://askubuntu.com/questions/460710/why-is-the-index-php-downloaded-instead-of-rendered-by-nginx)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.