php完整路径正常下载nginx,Nginx 访问目录下载问题

nginx虚拟主机,在本地做的测试,部分配置如下:

server {

listen 80;

server_name www.myblog.com;

error_page 404 /404.html;

error_page 500 503 504 /50x.html;

# server_name_in_redirect off;

root /usr/share/nginx/www/myblog;

# default_type application/octet-stream;

index index.html index.php;

location / {

try_files $uri $uri/ /index.html;

}

location ~*\.(gif|jpg|png)$ {

expires 30d;

}

location ~ \.php {

fastcgi_index index.php;

include fastcgi_params;

fastcgi_param PATH_INFO $fastcgi_script_name;

fastcgi_pass unix:/var/run/php5-fpm.sock;

}

}

现在的问题是当我访问www.myblog.com的时候会下载index.php,而不是执行。但我访问www.myblog.com/index.php的时候却是ok的。

请问这个问题怎么解决?

多谢各位!

回复内容:

nginx虚拟主机,在本地做的测试,部分配置如下:

server {

listen 80;

server_name www.myblog.com;

error_page 404 /404.html;

error_page 500 503 504 /50x.html;

# server_name_in_redirect off;

root /usr/share/nginx/www/myblog;

# default_type application/octet-stream;

index index.html index.php;

location / {

try_files $uri $uri/ /index.html;

}

location ~*\.(gif|jpg|png)$ {

expires 30d;

}

location ~ \.php {

fastcgi_index index.php;

include fastcgi_params;

fastcgi_param PATH_INFO $fastcgi_script_name;

fastcgi_pass unix:/var/run/php5-fpm.sock;

}

}

现在的问题是当我访问www.myblog.com的时候会下载index.php,而不是执行。但我访问www.myblog.com/index.php的时候却是ok的。

请问这个问题怎么解决?

多谢各位!

问题解决了,原来是浏览器缓存的问题,清除一下缓存就可以了!!!泪奔啊。。。

可以参考这里:http://serverfault.com/questions/315224/why-are-my-php-files-downloading-instead-of-processing-with-nginx?rq=1

多谢各位的回答了!

在try_files最后添加index.php试试看

try_files $uri $uri/ /index.html; 这里是不是少了 index.php呢?

本文原创发布php中文网,转载请注明出处,感谢您的尊重!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值