First of all, you misunderstand the try_files directive. There's no "last" argument and it doesn't work like you think. Please, check the documentation: http://nginx.org/r/try_files. It's technical documentation, read it literally, every word has meaning.
To solve your problem you have to remove two last arguments from try_files
:
try_files $uri $uri.php =404 last;
should be replaced with:
try_files $uri $uri.php;