Nginx的vhost下载文件

我已经设置nginx和php 本教程build议。 我创build了第二个虚拟主机,如下所示:

server { listen 80; root /projects/mydomain/; index index.php index.html index.htm; server_name mydomain.gr; location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } 

PHP和Nginx的工作正常,如果我访问mydomain.gr/index.php但当我访问mydomain.gr它将下载一个文件与index.php的内容和名称是下载。 我究竟做错了什么?

使用try_files而不是索引:

 server { listen 80; root /projects/mydomain/; try_files $uri $uri/index.php $uri/index.html $uri/index.htm =404; server_name mydomain.gr; location ~ \.php$ { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }